1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-02-22 20:12:37 -08:00
parent 948494892a
commit d7ed01e939
4 changed files with 101 additions and 100 deletions

View file

@ -30,7 +30,6 @@ import org.eclipse.core.runtime.IAdaptable;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomination, IAdaptable {
/**
* <code>OWNED_DECLARATION</code> represents the relationship between an <code>IASTTranslationUnit</code> and
* it's nested <code>IASTDeclaration</code>'s.
@ -107,7 +106,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
/**
* Returns the array of definitions in this translation unit for the given binding.
* The array contains the IASTName nodes that define the binding.
* These are part of the AST no definitions are pulled in from the index.
* These are part of the AST, no definitions are pulled in from the index.
*
* @param binding
* @return Array of IASTName nodes for the binding's declaration
@ -117,7 +116,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
/**
* Returns the list of references in this translation unit to the given
* binding. This list contains the IASTName nodes that represent a use of
* the binding. These are part of the AST no definitions are pulled in from
* the binding. These are part of the AST, no definitions are pulled in from
* the index.
*
* @param binding

View file

@ -31,22 +31,27 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
public class ASTQueries {
private static class NameSearch extends ASTVisitor {
private boolean fFound;
NameSearch() {
super(false);
shouldVisitAmbiguousNodes= true;
shouldVisitNames= true;
}
public void reset() {
fFound= false;
}
public boolean foundName() {
return fFound;
}
@Override
public int visit(IASTName name) {
fFound= true;
return PROCESS_ABORT;
}
@Override
public int visit(ASTAmbiguousNode node) {
IASTNode[] alternatives= node.getNodes();

View file

@ -24,11 +24,10 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
/**
* Models function declarators for plain c.
* A function declarator for plain C.
*/
public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStandardFunctionDeclarator {
private IASTParameterDeclaration [] parameters = null;
private IASTParameterDeclaration[] parameters;
private int parametersPos= -1;
private boolean varArgs;
private IScope scope;
@ -51,8 +50,9 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
copyBaseDeclarator(copy, style);
copy.varArgs = varArgs;
for(IASTParameterDeclaration param : getParameters())
for (IASTParameterDeclaration param : getParameters()) {
copy.addParameterDeclaration(param == null ? null : param.copy(style));
}
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
@ -62,7 +62,8 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
@Override
public IASTParameterDeclaration[] getParameters() {
if( parameters == null ) return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
if (parameters == null)
return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
parameters = ArrayUtil.trimAt(IASTParameterDeclaration.class, parameters, parametersPos);
return parameters;
}

View file

@ -100,7 +100,6 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
protected List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext context,
IASTCompletionNode completionNode, String prefix) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if (inPreprocessorDirective(context)) {
@ -202,10 +201,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
List<ICompletionProposal> proposals) {
IASTCompletionNode completionNode = context.getCompletionNode();
addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit()
.getMacroDefinitions());
addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit()
.getBuiltinMacroDefinitions());
addMacroProposals(context, prefix, proposals,
completionNode.getTranslationUnit().getMacroDefinitions());
addMacroProposals(context, prefix, proposals,
completionNode.getTranslationUnit().getBuiltinMacroDefinitions());
}
private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
@ -496,11 +495,11 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
String repString = repStringBuff.toString();
Image image = getImage(variable);
final int relevance = isLocalVariable(variable)
? RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE
: isField(variable)
? RelevanceConstants.FIELD_TYPE_RELEVANCE
: RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
final int relevance = isLocalVariable(variable) ?
RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE :
isField(variable) ?
RelevanceConstants.FIELD_TYPE_RELEVANCE :
RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
CCompletionProposal proposal = createProposal(repString, dispString, idString,
context.getCompletionNode().getLength(), image, baseRelevance + relevance, context);
proposals.add(proposal);
@ -508,8 +507,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private IType unwindTypedefs(final IType t) {
IType r= t;
while (r instanceof ITypedef)
while (r instanceof ITypedef) {
r= ((ITypedef) r).getType();
}
return r != null ? r : t;
}
@ -541,12 +541,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return false;
}
private void handleNamespace(ICPPNamespace namespace,
IASTCompletionContext astContext,
CContentAssistInvocationContext cContext,
int baseRelevance,
private void handleNamespace(ICPPNamespace namespace, IASTCompletionContext astContext,
CContentAssistInvocationContext cContext, int baseRelevance,
List<ICompletionProposal> proposals) {
if (astContext instanceof ICPPASTQualifiedName) {
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
.getCompletionContext();
@ -652,8 +649,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return getImage(delegates[0]);
}
return imageDescriptor != null
? CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor)
: null;
return imageDescriptor != null ?
CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor) : null;
}
}