1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-08 09:35:23 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-01-14 20:00:57 -08:00
parent da85a41850
commit 773eb90b41
13 changed files with 105 additions and 117 deletions
core
org.eclipse.cdt.core/parser/org/eclipse/cdt
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename

View file

@ -20,13 +20,13 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
*/
public interface ICCompositeTypeScope extends ICScope {
/**
* get the binding for the member that has been previous added to this scope
* Returns the binding for the member that has been previous added to this scope
* and that matches the given name.
*/
public IBinding getBinding(char[] name);
/**
* Get the type this scope is associated with
* Returns the type this scope is associated with.
* @since 4.0
*/
public ICompositeType getCompositeType();

View file

@ -131,8 +131,8 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory,
IIndex index, int options, IParserLogService log) throws CoreException {
return getASTTranslationUnit(FileContent.adapt(reader), scanInfo, IncludeFileContentProvider
.adapt(codeReaderFactory), index, options, log);
return getASTTranslationUnit(FileContent.adapt(reader), scanInfo,
IncludeFileContentProvider.adapt(codeReaderFactory), index, options, log);
}
@Override
@ -178,7 +178,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
if (scanner.getLocationResolver() != null)
tuName = scanner.getLocationResolver().getTranslationUnitPath();
log.traceLog(e.getMessage() + (tuName == null ? new String() : (" while parsing " + tuName))); //$NON-NLS-1$
log.traceLog(e.getMessage() + (tuName == null ? "" : (" while parsing " + tuName))); //$NON-NLS-1$ //$NON-NLS-2$
}
return null;
} finally {
@ -241,7 +241,8 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
* @return an instance of ISourceCodeParser
* @since 5.6
*/
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options, IParserSettings settings) {
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index,
boolean forCompletion, int options, IParserSettings settings) {
ParserMode mode = createParserMode(forCompletion, options);
return createParser(scanner, mode, log, index, options, settings);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 IBM Corporation and others.
* Copyright (c) 2004, 2015 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
@ -8,6 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -149,24 +150,24 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
return ParserLanguage.CPP;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLinkage()
*/
@Override
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
*/
@Override
public void skippedFile(int offset, InternalFileContent fileContent) {
super.skippedFile(offset, fileContent);
fScopeMapper.registerAdditionalDirectives(offset, fileContent.getUsingDirectives());
}
// Namespace scopes from the index have to be mapped back to the AST (bug 217102).
/**
* Maps an index scope to the AST.
*
* @param scope a scope, possibly from index
* @return the corresponding scope in the AST, or the original scope if it doesn't have
* a counterpart in the AST.
*/
public IScope mapToASTScope(IScope scope) {
if (scope instanceof IIndexScope) {
return fScopeMapper.mapToASTScope((IIndexScope) scope);
@ -174,7 +175,14 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
return scope;
}
// Class types from the index have to be mapped back to the AST (bug 262719).
/**
* Maps a class type to the AST.
*
* @param binding a class type, possibly from index
* @param point a lookup point in the AST
* @return the corresponding class in the AST, or the original class type if it doesn't have
* a counterpart in the AST.
*/
public ICPPClassType mapToAST(ICPPClassType binding, IASTNode point) {
return fScopeMapper.mapToAST(binding, point);
}

View file

@ -26,7 +26,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
* Represents a using-directive found in the AST.
*/
public class CPPUsingDirective implements ICPPUsingDirective {
private IASTName fNamespaceName;
/**
@ -43,9 +42,6 @@ public class CPPUsingDirective implements ICPPUsingDirective {
fNamespaceName= nsdef.getName();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getNamespaceScope()
*/
@Override
public ICPPNamespaceScope getNominatedScope() throws DOMException {
IBinding binding= fNamespaceName.resolveBinding();
@ -55,18 +51,12 @@ public class CPPUsingDirective implements ICPPUsingDirective {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getPointOfDeclaration()
*/
@Override
public int getPointOfDeclaration() {
final ASTNode astNode = (ASTNode) fNamespaceName;
return astNode.getOffset() + astNode.getLength();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getContainingScope()
*/
@Override
public IScope getContainingScope() {
return CPPVisitor.getContainingScope(fNamespaceName);

View file

@ -1005,14 +1005,14 @@ public class CPPSemantics {
// Nominate using-directives found in this block or namespace.
if (scope instanceof ICPPNamespaceScope) {
final ICPPNamespaceScope blockScope= (ICPPNamespaceScope) scope;
final ICPPNamespaceScope namespaceScope= (ICPPNamespaceScope) scope;
if (data.qualified && blockScope.getKind() != EScopeKind.eLocal) {
lookupInlineNamespaces(data, blockScope);
if (data.qualified && namespaceScope.getKind() != EScopeKind.eLocal) {
lookupInlineNamespaces(data, namespaceScope);
}
if (data.contentAssist || !data.hasResults() || !data.qualified) {
// Nominate namespaces
nominateNamespaces(data, blockScope);
nominateNamespaces(data, namespaceScope);
}
}
}

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexName;
/**
* Interface for scopes returned via the index
* @since 4.0
@ -24,12 +23,12 @@ public interface IIndexScope extends IScope {
IIndexScope[] EMPTY_INDEX_SCOPE_ARRAY = {};
/**
* Get the binding associated with scope
* Returns the binding associated with the scope.
*/
IIndexBinding getScopeBinding();
/**
* Returns the parent scope or <code>null</code> if the scope is nested in the global scope.
* Returns the parent scope or {@code null} if the scope is nested in the global scope.
*/
@Override
IIndexScope getParent();

View file

@ -38,7 +38,9 @@ public abstract class CompositeScope implements IIndexScope {
protected final IIndexFragmentBinding rbinding;
public CompositeScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
if (cf == null || rbinding == null)
if (cf == null)
throw new NullPointerException();
if (rbinding == null)
throw new NullPointerException();
this.cf = cf;
this.rbinding = rbinding;
@ -66,7 +68,6 @@ public abstract class CompositeScope implements IIndexScope {
throw new CompositingNotImplementedError();
}
public IBinding getRawScopeBinding() {
return rbinding;
}
@ -84,8 +85,7 @@ public abstract class CompositeScope implements IIndexScope {
return binding;
} else if (binding instanceof CPPCompositeBinding /* AST composite */) {
return new CPPCompositeBinding(
processUncertainBindings(((CPPCompositeBinding) binding).getBindings())
);
processUncertainBindings(((CPPCompositeBinding) binding).getBindings()));
} else if (binding instanceof CPPUsingDeclaration) {
return binding;
} else if (binding == null) {
@ -98,8 +98,10 @@ public abstract class CompositeScope implements IIndexScope {
}
/**
* A convenience method for processing an array of bindings with {@link CompositeScope#processUncertainBinding(IBinding)}
* Returns an empty array if the input parameter is null
* A convenience method for processing an array of bindings with
* {@link CompositeScope#processUncertainBinding(IBinding)}.
* Returns an empty array if the input parameter is null.
*
* @param frgBindings
* @return a non-null IBinding[]
*/
@ -125,7 +127,7 @@ public abstract class CompositeScope implements IIndexScope {
}
/**
* The c++-name resolution stores scopes in hash-maps, we need to make sure equality is detected
* The c++ name resolution stores scopes in hash-maps, we need to make sure equality is detected
* in order to prevent infinite loops.
*/
@Override
@ -137,7 +139,7 @@ public abstract class CompositeScope implements IIndexScope {
}
/**
* The c++-name resolution stores scopes in hash-maps, we need to make sure equality is detected
* The c++ name resolution stores scopes in hash-maps, we need to make sure equality is detected
* in order to prevent infinite loops.
*/
@Override

View file

@ -46,9 +46,6 @@ public class CCompositesFactory extends AbstractCompositeFactory {
super(index);
}
/*
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
*/
@Override
public IIndexScope getCompositeScope(IIndexScope rscope) {
if (rscope == null)
@ -61,12 +58,8 @@ public class CCompositesFactory extends AbstractCompositeFactory {
throw new CompositingNotImplementedError();
}
/*
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType)
*/
@Override
public IType getCompositeType(IType rtype) {
if (rtype instanceof IIndexFragmentBinding) {
return (IType) getCompositeBinding((IIndexFragmentBinding) rtype);
}
@ -159,7 +152,7 @@ public class CCompositesFactory extends AbstractCompositeFactory {
} else if (rbinding instanceof IIndexMacroContainer) {
result= new CompositeMacroContainer(this, rbinding);
} else {
throw new CompositingNotImplementedError("composite binding unavailable for "+rbinding+" "+rbinding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
throw new CompositingNotImplementedError("Composite binding unavailable for " + rbinding + " " + rbinding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
}
return result;

View file

@ -102,9 +102,6 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope#getInlineNamespaces()
*/
@Override
public ICPPNamespaceScope[] getInlineNamespaces() {
IIndexFragmentBinding[][] preresult = new IIndexFragmentBinding[namespaces.length][];

View file

@ -284,8 +284,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
}
} catch (DOMException e) {
} catch (CoreException ce) {
CCorePlugin.log(ce);
} catch (CoreException e) {
CCorePlugin.log(e);
}
return null;
}

View file

@ -45,7 +45,6 @@ import org.eclipse.core.runtime.Status;
/**
* @author Doug Schaefer
*
*/
public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCompositeTypeScope, IPDOMMemberOwner, IIndexType, IIndexScope {
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
@ -58,7 +57,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
super(linkage, parent, compType.getNameCharArray());
setKind(compType);
setAnonymous(compType);
// linked list is initialized by malloc zeroing allocated storage
// Linked list is initialized by malloc zeroing allocated storage.
}
public PDOMCStructure(PDOMLinkage linkage, long record) {
@ -88,7 +87,6 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
@ -126,7 +124,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
}
private static class GetFields implements IPDOMVisitor {
private final List<IPDOMNode> fields = new ArrayList<IPDOMNode>();
private final List<IPDOMNode> fields = new ArrayList<>();
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IField) {
@ -156,16 +154,18 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
return fields.getFields();
} catch (CoreException e) {
CCorePlugin.log(e);
return new IField[0];
return IField.EMPTY_FIELD_ARRAY;
}
}
public static class FindField implements IPDOMVisitor {
private IField field;
private final String name;
public FindField(String name) {
this.name = name;
}
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IField) {
@ -183,10 +183,14 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
}
return false;
}
@Override
public void leave(IPDOMNode node) throws CoreException {
}
public IField getField() { return field; }
public IField getField() {
return field;
}
}
@Override

View file

@ -338,7 +338,7 @@ public class ASTManager implements IDisposable {
IASTNode node1= ASTInternal.getPhysicalNodeOfScope(s1);
IASTNode node2= ASTInternal.getPhysicalNodeOfScope(s2);
// forward declarations do not have parent scopes.
// Forward declarations do not have parent scopes.
if (s1 == null) {
if (!fileStatic && node2 instanceof IASTTranslationUnit) {
return TRUE;
@ -389,7 +389,7 @@ public class ASTManager implements IDisposable {
return FALSE;
}
// classes
// Classes.
if (s1 instanceof ICPPClassScope || s1 instanceof ICCompositeTypeScope) {
if (s2 instanceof ICPPClassScope || s2 instanceof ICCompositeTypeScope) {
return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
@ -758,8 +758,7 @@ public class ASTManager implements IDisposable {
// eliminate global bindings when looking up in a class type
if (removeGlobalsWhenClassScope &&
(scope instanceof ICPPClassScope ||
scope instanceof ICCompositeTypeScope)) {
(scope instanceof ICPPClassScope || scope instanceof ICCompositeTypeScope)) {
int count= 0;
for (int i = 0; i < result.length; i++) {
IBinding binding = result[i];
@ -782,7 +781,7 @@ public class ASTManager implements IDisposable {
}
}
// try to find constructors
// Try to find constructors.
if (scope instanceof ICPPBlockScope) {
for (int i = 0; i < result.length; i++) {
IBinding binding = result[i];
@ -805,9 +804,6 @@ public class ASTManager implements IDisposable {
fArgument= arg;
}
/**
* @see IDisposable#dispose()
*/
@Override
public void dispose() {
Assert.isTrue(!fDisposed, "ASTManager.dispose() called more than once"); //$NON-NLS-1$
@ -899,16 +895,14 @@ public class ASTManager implements IDisposable {
return null;
}
while (offset > 0) {
if (Character.isJavaIdentifierPart(sig[offset-1]))
offset--;
else
if (!Character.isJavaIdentifierPart(sig[offset - 1]))
break;
offset--;
}
while (end < sig.length) {
if (Character.isJavaIdentifierPart(sig[end]))
end++;
else
if (!Character.isJavaIdentifierPart(sig[end]))
break;
end++;
}
return rawSignature.substring(offset, end);
}
@ -1497,7 +1491,7 @@ public class ASTManager implements IDisposable {
protected void classifyConflictingBindings(IASTTranslationUnit tu, Set<IBinding> shadows,
Collection<IBinding> redecl, Collection<IBinding> barriers, RefactoringStatus status) {
// collect bindings on higher or equal level
// Collect bindings on higher or equal level.
String name= fArgument.getName();
IBinding[] newBindingsAboverOrEqual= null;
IScope oldBindingsScope= null;
@ -1523,7 +1517,7 @@ public class ASTManager implements IDisposable {
newBindingsAboverOrEqual= IBinding.EMPTY_BINDING_ARRAY;
}
// check conflicting bindings for being from above or equal level.
// Check conflicting bindings for being from above or equal level.
for (IBinding conflictingBinding : fConflictingBinding) {
if (conflictingBinding != null) {
boolean isAboveOrEqual= false;
@ -1543,7 +1537,7 @@ public class ASTManager implements IDisposable {
}
}
// find bindings on same level
// Find bindings on same level.
for (IBinding aboveBinding : newBindingsAboverOrEqual) {
IScope aboveScope;
try {