1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-26 20:19:51 -07:00
parent 181907f2fd
commit 52ac0596f6
3 changed files with 41 additions and 37 deletions

View file

@ -57,7 +57,7 @@ public class ObjectSet<T> extends ObjectTable<T> {
* @param key the item to add (may be null) * @param key the item to add (may be null)
*/ */
public void checkPut(T key) { public void checkPut(T key) {
if (key!=null) if (key != null)
add(key); add(key);
} }

View file

@ -39,7 +39,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/ */
public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateId, IASTAmbiguityParent { public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateId, IASTAmbiguityParent {
private IASTName templateName; private IASTName templateName;
private IASTNode[] templateArguments = null; private IASTNode[] templateArguments;
public CPPASTTemplateId() { public CPPASTTemplateId() {
} }
@ -57,8 +57,9 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
public CPPASTTemplateId copy(CopyStyle style) { public CPPASTTemplateId copy(CopyStyle style) {
CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ? CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ?
null : templateName.copy(style)); null : templateName.copy(style));
for (IASTNode arg : getTemplateArguments()) for (IASTNode arg : getTemplateArguments()) {
copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style)); copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style));
}
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) { if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this); copy.setCopyLocation(this);
@ -215,7 +216,8 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
@Override @Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if (templateArguments == null) return; if (templateArguments == null)
return;
for (int i = 0; i < templateArguments.length; ++i) { for (int i = 0; i < templateArguments.length; ++i) {
if (child == templateArguments[i]) { if (child == templateArguments[i]) {
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());

View file

@ -51,7 +51,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* Base class for c++-scopes of the ast. * Base class for c++-scopes of the AST.
*/ */
abstract public class CPPScope implements ICPPASTInternalScope { abstract public class CPPScope implements ICPPASTInternalScope {
protected static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$ protected static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
@ -60,13 +60,14 @@ abstract public class CPPScope implements ICPPASTInternalScope {
private IASTNode physicalNode; private IASTNode physicalNode;
private boolean isCached = false; private boolean isCached = false;
protected CharArrayObjectMap<Object> bindings = null; protected CharArrayObjectMap<Object> bindings;
private ICPPNamespace fIndexNamespace= UNINITIALIZED; private ICPPNamespace fIndexNamespace= UNINITIALIZED;
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope { public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
public CPPScopeProblem(IASTNode node, int id, char[] arg) { public CPPScopeProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg); super(node, id, arg);
} }
public CPPScopeProblem(IASTName name, int id) { public CPPScopeProblem(IASTName name, int id) {
super(name, id); super(name, id);
} }
@ -89,7 +90,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
@Override @Override
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public void addName(IASTName name) { public void addName(IASTName name) {
// don't add inactive names to the scope // Don't add inactive names to the scope.
if (!name.isActive()) if (!name.isActive())
return; return;
@ -101,7 +102,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
return; return;
} }
// name belongs to a different scope, don't add it here except it names this scope // Name belongs to a different scope, don't add it here except if it names this scope.
if (!canDenoteScopeMember((ICPPASTQualifiedName) name)) if (!canDenoteScopeMember((ICPPASTQualifiedName) name))
return; return;
} }
@ -111,7 +112,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
Object o = bindings.get(c); Object o = bindings.get(c);
if (o != null) { if (o != null) {
if (o instanceof ObjectSet) { if (o instanceof ObjectSet) {
((ObjectSet<Object>)o).put(name); ((ObjectSet<Object>) o).put(name);
} else { } else {
ObjectSet<Object> temp = new ObjectSet<Object>(2); ObjectSet<Object> temp = new ObjectSet<Object>(2);
temp.put(o); temp.put(o);
@ -125,16 +126,17 @@ abstract public class CPPScope implements ICPPASTInternalScope {
public boolean canDenoteScopeMember(ICPPASTQualifiedName name) { public boolean canDenoteScopeMember(ICPPASTQualifiedName name) {
IScope scope= this; IScope scope= this;
IASTName[] na= name.getNames(); IASTName[] segments= name.getNames();
try { try {
for (int i= na.length - 2; i >= 0; i--) { for (int i= segments.length - 1; --i >= 0;) {
if (scope == null) if (scope == null)
return false; return false;
IName scopeName = scope.getScopeName(); IName scopeName = scope.getScopeName();
if (scopeName == null) if (scopeName == null)
return false; return false;
if (!CharArrayUtils.equals(scopeName.getSimpleID(), na[i].getSimpleID())) IASTName segmentName = segments[i];
if (!CharArrayUtils.equals(scopeName.getSimpleID(), segmentName.getSimpleID()))
return false; return false;
scope= scope.getParent(); scope= scope.getParent();
} }
@ -155,7 +157,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
IIndex index = tu == null ? null : tu.getIndex(); IIndex index = tu == null ? null : tu.getIndex();
if (index != null) { if (index != null) {
final char[] nchars = name.getLookupKey(); final char[] nchars = name.getLookupKey();
// Try looking this up in the PDOM // Try looking this up in the index.
if (physicalNode instanceof IASTTranslationUnit) { if (physicalNode instanceof IASTTranslationUnit) {
try { try {
IBinding[] bindings= index.findBindings(nchars, IBinding[] bindings= index.findBindings(nchars,
@ -166,7 +168,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
binding= CPPSemantics.resolveAmbiguities(name, bindings); binding= CPPSemantics.resolveAmbiguities(name, bindings);
if (binding instanceof ICPPUsingDeclaration) { if (binding instanceof ICPPUsingDeclaration) {
binding= CPPSemantics.resolveAmbiguities(name, binding= CPPSemantics.resolveAmbiguities(name,
((ICPPUsingDeclaration)binding).getDelegates()); ((ICPPUsingDeclaration) binding).getDelegates());
} }
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
@ -234,7 +236,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
try { try {
IIndexBinding binding = index.findBinding(ns.getName()); IIndexBinding binding = index.findBinding(ns.getName());
if (binding instanceof ICPPNamespace) { if (binding instanceof ICPPNamespace) {
ICPPNamespaceScope indexNs = ((ICPPNamespace)binding).getNamespaceScope(); ICPPNamespaceScope indexNs = ((ICPPNamespace) binding).getNamespaceScope();
IBinding[] bindings = indexNs.getBindings(name, resolve, prefixLookup); IBinding[] bindings = indexNs.getBindings(name, resolve, prefixLookup);
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
@ -297,7 +299,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
if (checkPointOfDecl) { if (checkPointOfDecl) {
IASTTranslationUnit tu= name.getTranslationUnit(); IASTTranslationUnit tu= name.getTranslationUnit();
if (!CPPSemantics.declaredBefore(candidate, name, tu != null && tu.getIndex() != null)) { if (!CPPSemantics.declaredBefore(candidate, name, tu != null && tu.getIndex() != null)) {
if (!(this instanceof ICPPClassScope) || ! LookupData.checkWholeClassScope(name)) if (!(this instanceof ICPPClassScope) || !LookupData.checkWholeClassScope(name))
return result; return result;
} }
} }
@ -310,7 +312,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
simpleName= ((ICPPASTTemplateId) simpleName).getTemplateName(); simpleName= ((ICPPASTTemplateId) simpleName).getTemplateName();
} }
if (forceResolve && candName != name && simpleName != name) { if (forceResolve && candName != name && simpleName != name) {
candName.resolvePreBinding(); // make sure to resolve the template-id candName.resolvePreBinding(); // Make sure to resolve the template-id
binding = simpleName.resolvePreBinding(); binding = simpleName.resolvePreBinding();
} else { } else {
binding = simpleName.getPreBinding(); binding = simpleName.getPreBinding();
@ -386,7 +388,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
Object o = bindings.get(c); Object o = bindings.get(c);
if (o != null) { if (o != null) {
if (o instanceof ObjectSet) { if (o instanceof ObjectSet) {
((ObjectSet<Object>)o).put(binding); ((ObjectSet<Object>) o).put(binding);
} else { } else {
ObjectSet<Object> set = new ObjectSet<Object>(2); ObjectSet<Object> set = new ObjectSet<Object>(2);
set.put(o); set.put(o);