1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 03:05:39 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-12-02 20:56:08 -08:00
parent bd0e88a3e2
commit 090345f405
9 changed files with 1158 additions and 1170 deletions

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Cortell - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.alltests; package org.eclipse.cdt.alltests;
import junit.framework.Test; import junit.framework.Test;
@ -13,20 +23,20 @@ public class AllTests extends TestSuite {
public static Test suite() throws Exception { public static Test suite() throws Exception {
final AllTests suite = new AllTests(); final AllTests suite = new AllTests();
suite.addTest(org.eclipse.cdt.autotools.tests.AllAutotoolsTests.suite()); suite.addTest(org.eclipse.cdt.autotools.tests.AllAutotoolsTests.suite());
// // There are intermittent failures in these tests. No pattern to failures. Seems like indexer is interrupted // // There are intermittent failures in these tests. No pattern to failures. Seems like indexer is interrupted
if (System.getProperty("cdt.skip.known.test.failures") == null) { //$NON-NLS-1$ if (System.getProperty("cdt.skip.known.test.failures") == null) { //$NON-NLS-1$
suite.addTest(org.eclipse.cdt.codan.core.test.AutomatedIntegrationSuite.suite()); suite.addTest(org.eclipse.cdt.codan.core.test.AutomatedIntegrationSuite.suite());
suite.addTest(org.eclipse.cdt.core.lrparser.tests.LRParserTestSuite.suite()); suite.addTest(org.eclipse.cdt.core.lrparser.tests.LRParserTestSuite.suite());
suite.addTest(org.eclipse.cdt.core.parser.xlc.tests.suite.XlcTestSuite.suite()); suite.addTest(org.eclipse.cdt.core.parser.xlc.tests.suite.XlcTestSuite.suite());
suite.addTest(org.eclipse.cdt.core.parser.upc.tests.UPCParserTestSuite.suite()); suite.addTest(org.eclipse.cdt.core.parser.upc.tests.UPCParserTestSuite.suite());
} }
suite.addTest(org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.suite()); suite.addTest(org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.suite());
// These tests fail intermittently due to gdb not shutting down and thus // These tests fail intermittently due to gdb not shutting down and thus
// not being able to delete the project (exe locked) // not being able to delete the project (exe locked)
if (System.getProperty("cdt.skip.known.test.failures") == null) { //$NON-NLS-1$ if (System.getProperty("cdt.skip.known.test.failures") == null) { //$NON-NLS-1$
suite.addTest(org.eclipse.cdt.debug.core.tests.AllDebugTests.suite()); suite.addTest(org.eclipse.cdt.debug.core.tests.AllDebugTests.suite());
} }
suite.addTest(org.eclipse.cdt.errorparsers.xlc.tests.AllXlcErrorParserTests.suite()); suite.addTest(org.eclipse.cdt.errorparsers.xlc.tests.AllXlcErrorParserTests.suite());
suite.addTest(org.eclipse.cdt.make.core.tests.AutomatedIntegrationSuite.suite()); suite.addTest(org.eclipse.cdt.make.core.tests.AutomatedIntegrationSuite.suite());
suite.addTest(org.eclipse.cdt.managedbuilder.tests.suite.AllManagedBuildTests.suite()); suite.addTest(org.eclipse.cdt.managedbuilder.tests.suite.AllManagedBuildTests.suite());

View file

@ -40,10 +40,7 @@ import org.eclipse.core.runtime.content.IContentType;
* @author dsteffle * @author dsteffle
*/ */
public class DOMSearchUtil { public class DOMSearchUtil {
private static final IASTName[] BLANK_NAME_ARRAY = new IASTName[0]; public static final int DECLARATIONS = 1;
// private static final IASTName[] EMPTY_NAME_LIST = BLANK_NAME_ARRAY;
public static final int DECLARATIONS = 1;
public static final int DEFINITIONS = 2; public static final int DEFINITIONS = 2;
public static final int DECLARATIONS_DEFINITIONS = 3; public static final int DECLARATIONS_DEFINITIONS = 3;
public static final int REFERENCES = 4; public static final int REFERENCES = 4;
@ -135,7 +132,7 @@ public class DOMSearchUtil {
IASTTranslationUnit tu = searchName.getTranslationUnit(); IASTTranslationUnit tu = searchName.getTranslationUnit();
if (tu == null) { if (tu == null) {
return BLANK_NAME_ARRAY; return IASTName.EMPTY_NAME_ARRAY;
} }
IBinding binding = searchName.resolveBinding(); IBinding binding = searchName.resolveBinding();
@ -162,7 +159,7 @@ public class DOMSearchUtil {
// fix for 86829, 95224 // fix for 86829, 95224
if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor())) if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor()))
&& binding.getScope() instanceof ICPPClassScope) { && binding.getScope() instanceof ICPPClassScope) {
binding = ((ICPPClassScope)binding.getScope()).getClassType(); binding = ((ICPPClassScope) binding.getScope()).getClassType();
names = getNames(tu, binding, limitTo); names = getNames(tu, binding, limitTo);
} }
} catch (DOMException e) { } catch (DOMException e) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IScope;
*/ */
public interface ICPPFunctionScope extends ICPPScope { public interface ICPPFunctionScope extends ICPPScope {
/** /**
* Get the scope representing the function body. returns null if there is no * Returns the scope representing the function body, or {@code null} if there is no
* function definition * function definition.
* *
* @throws DOMException * @throws DOMException
*/ */

View file

@ -127,7 +127,7 @@ public class CharTable extends HashTable {
if (i < 0 || i > currEntry) if (i < 0 || i > currEntry)
return null; return null;
return keyTable[ i ]; return keyTable[i];
} }
public final boolean containsKey(char[] key, int start, int len) { public final boolean containsKey(char[] key, int start, int len) {
@ -143,7 +143,7 @@ public class CharTable extends HashTable {
if (idx == -1) if (idx == -1)
return null; return null;
return keyTable[ idx ]; return keyTable[idx];
} }
public int lookup(char[] buffer) { public int lookup(char[] buffer) {
@ -177,7 +177,7 @@ public class CharTable extends HashTable {
} }
public Object[] keyArray() { public Object[] keyArray() {
Object[] keys = new Object[ size() ]; Object[] keys = new Object[size()];
System.arraycopy(keyTable, 0, keys, 0, keys.length); System.arraycopy(keyTable, 0, keys, 0, keys.length);
return keys; return keys;
} }

View file

@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
@ -56,8 +56,8 @@ public class ASTInternal {
if (scope instanceof IASTInternalScope) { if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).addName(name); ((IASTInternalScope) scope).addName(name);
} }
} }
public static boolean isStatic(IFunction func, boolean resolveAll) { public static boolean isStatic(IFunction func, boolean resolveAll) {
if (func instanceof ICPPInternalFunction) { if (func instanceof ICPPInternalFunction) {
return ((ICPPInternalFunction) func).isStatic(resolveAll); return ((ICPPInternalFunction) func).isStatic(resolveAll);
@ -103,7 +103,7 @@ public class ASTInternal {
if (node != null) { if (node != null) {
if (!isPartOfSource(node)) if (!isPartOfSource(node))
return null; return null;
if ((result= resolveConflict(result, node)) == null) if ((result= resolveConflict(result, node)) == null)
return null; return null;
} }
} }
@ -140,7 +140,7 @@ public class ASTInternal {
return n2; return n2;
IASTFileLocation loc2= n2.getFileLocation(); IASTFileLocation loc2= n2.getFileLocation();
if (loc2 != null && loc1.getContextInclusionStatement() != loc2.getContextInclusionStatement()) if (loc2 != null && loc1.getContextInclusionStatement() != loc2.getContextInclusionStatement())
return null; return null;
return n1; return n1;
@ -167,7 +167,7 @@ public class ASTInternal {
if (decls != null) { if (decls != null) {
for (final IASTNode node : decls) { for (final IASTNode node : decls) {
if (node != null) { if (node != null) {
if ((result= resolveConflict(result, node)) == null) if ((result= resolveConflict(result, node)) == null)
return null; return null;
} }
} }
@ -194,14 +194,14 @@ public class ASTInternal {
return true; return true;
IASTNode[] decls= internal.getDeclarations(); IASTNode[] decls= internal.getDeclarations();
return decls != null && decls.length > 0 && decls[0] != null; return decls != null && decls.length > 0 && decls[0] != null;
} }
if (binding instanceof IIndexBinding) { if (binding instanceof IIndexBinding) {
try { try {
return IndexFilter.ALL_DECLARED.acceptBinding(binding); return IndexFilter.ALL_DECLARED.acceptBinding(binding);
} catch (CoreException e) { } catch (CoreException e) {
} }
return false; return false;
} }
return binding != null; return binding != null;
} }
} }

View file

@ -20,18 +20,18 @@ import org.eclipse.cdt.core.dom.ast.IScope;
*/ */
public interface IASTInternalScope extends IScope { public interface IASTInternalScope extends IScope {
/** /**
* Return the physical IASTNode that this scope was created for * Returns the physical IASTNode that this scope was created for
*/ */
public IASTNode getPhysicalNode(); public IASTNode getPhysicalNode();
/** /**
* This adds an IBinding to the scope. It is primarily used by the parser to add * Adds an IBinding to the scope. It is primarily used by the parser to add
* implicit IBindings to the scope (such as GCC built-in functions). * implicit IBindings to the scope (such as GCC built-in functions).
*/ */
public void addBinding(IBinding binding); public void addBinding(IBinding binding);
/** /**
* Add an IASTName to be cached in this scope * Adds an IASTName to be cached in this scope
*/ */
public void addName(IASTName name); public void addName(IASTName name);
@ -47,5 +47,4 @@ public interface IASTInternalScope extends IScope {
* node from the cache. * node from the cache.
*/ */
public void removeNestedFromCache(IASTNode container); public void removeNestedFromCache(IASTNode container);
} }

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
* Scope of a function, containing labels. * Scope of a function, containing labels.
*/ */
public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
private CharArrayObjectMap<IBinding> labels = CharArrayObjectMap.emptyMap(); private CharArrayObjectMap<IBinding> labels = CharArrayObjectMap.emptyMap();
/** /**
@ -52,9 +51,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
return EScopeKind.eLocal; return EScopeKind.eLocal;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#addBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/
@Override @Override
public void addBinding(IBinding binding) { public void addBinding(IBinding binding) {
//3.3.4 only labels have function scope //3.3.4 only labels have function scope
@ -67,16 +63,10 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
labels.put(binding.getNameCharArray(), binding); labels.put(binding.getNameCharArray(), binding);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
*/
public IBinding getBinding(IASTName name) { public IBinding getBinding(IASTName name) {
return labels.get(name.getLookupKey()); return labels.get(name.getLookupKey());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/
@Override @Override
public IBinding[] find(String name) { public IBinding[] find(String name) {
char[] n = name.toCharArray(); char[] n = name.toCharArray();
@ -106,9 +96,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
return CPPVisitor.getContainingNonTemplateScope(name); return CPPVisitor.getContainingNonTemplateScope(name);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope()
*/
@Override @Override
public IScope getBodyScope() { public IScope getBodyScope() {
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode(); IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
@ -121,9 +108,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
*/
@Override @Override
public IName getScopeName() { public IName getScopeName() {
IASTNode node = getPhysicalNode(); IASTNode node = getPhysicalNode();

View file

@ -375,26 +375,24 @@ public class CPPVisitor extends ASTQueries {
} }
private static IBinding createBinding(IASTGotoStatement gotoStatement) { private static IBinding createBinding(IASTGotoStatement gotoStatement) {
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(gotoStatement.getName());
IASTName name = gotoStatement.getName(); IASTName name = gotoStatement.getName();
IBinding binding; ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(name);
binding = functionScope.getBinding(name, false); IBinding binding = functionScope.getBinding(name, false);
if (binding == null || !(binding instanceof ILabel)) { if (binding == null || !(binding instanceof ILabel)) {
binding = new CPPLabel(name); binding = new CPPLabel(name);
ASTInternal.addName(functionScope, name); ASTInternal.addName(functionScope, name);
} }
return binding; return binding;
} }
private static IBinding createBinding(IASTLabelStatement labelStatement) { private static IBinding createBinding(IASTLabelStatement labelStatement) {
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(labelStatement.getName());
IASTName name = labelStatement.getName(); IASTName name = labelStatement.getName();
IBinding binding; ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(name);
binding = functionScope.getBinding(name, false); IBinding binding = functionScope.getBinding(name, false);
if (binding == null || !(binding instanceof ILabel)) { if (binding == null || !(binding instanceof ILabel)) {
binding = new CPPLabel(name); binding = new CPPLabel(name);
ASTInternal.addName(functionScope, name); ASTInternal.addName(functionScope, name);
} else { } else {
((CPPLabel) binding).setLabelStatement(name); ((CPPLabel) binding).setLabelStatement(name);
} }