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

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -30,7 +30,6 @@ import org.eclipse.core.runtime.IAdaptable;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomination, IAdaptable { public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomination, IAdaptable {
/** /**
* <code>OWNED_DECLARATION</code> represents the relationship between an <code>IASTTranslationUnit</code> and * <code>OWNED_DECLARATION</code> represents the relationship between an <code>IASTTranslationUnit</code> and
* it's nested <code>IASTDeclaration</code>'s. * 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. * Returns the array of definitions in this translation unit for the given binding.
* The array contains the IASTName nodes that define the 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 * @param binding
* @return Array of IASTName nodes for the binding's declaration * @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 * Returns the list of references in this translation unit to the given
* binding. This list contains the IASTName nodes that represent a use of * 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. * the index.
* *
* @param binding * @param binding

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* 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;
@ -31,22 +31,27 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
public class ASTQueries { public class ASTQueries {
private static class NameSearch extends ASTVisitor { private static class NameSearch extends ASTVisitor {
private boolean fFound; private boolean fFound;
NameSearch() { NameSearch() {
super(false); super(false);
shouldVisitAmbiguousNodes= true; shouldVisitAmbiguousNodes= true;
shouldVisitNames= true; shouldVisitNames= true;
} }
public void reset() { public void reset() {
fFound= false; fFound= false;
} }
public boolean foundName() { public boolean foundName() {
return fFound; return fFound;
} }
@Override @Override
public int visit(IASTName name) { public int visit(IASTName name) {
fFound= true; fFound= true;
return PROCESS_ABORT; return PROCESS_ABORT;
} }
@Override @Override
public int visit(ASTAmbiguousNode node) { public int visit(ASTAmbiguousNode node) {
IASTNode[] alternatives= node.getNodes(); IASTNode[] alternatives= node.getNodes();

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
@ -24,12 +24,11 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; 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 { public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStandardFunctionDeclarator {
private IASTParameterDeclaration[] parameters;
private IASTParameterDeclaration [] parameters = null; private int parametersPos= -1;
private int parametersPos=-1;
private boolean varArgs; private boolean varArgs;
private IScope scope; private IScope scope;
@ -51,8 +50,9 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
copyBaseDeclarator(copy, style); copyBaseDeclarator(copy, style);
copy.varArgs = varArgs; copy.varArgs = varArgs;
for(IASTParameterDeclaration param : getParameters()) for (IASTParameterDeclaration param : getParameters()) {
copy.addParameterDeclaration(param == null ? null : param.copy(style)); copy.addParameterDeclaration(param == null ? null : param.copy(style));
}
if (style == CopyStyle.withLocations) { if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this); copy.setCopyLocation(this);
@ -62,8 +62,9 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
@Override @Override
public IASTParameterDeclaration[] getParameters() { public IASTParameterDeclaration[] getParameters() {
if( parameters == null ) return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY; if (parameters == null)
parameters = ArrayUtil.trimAt( IASTParameterDeclaration.class, parameters, parametersPos ); return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
parameters = ArrayUtil.trimAt(IASTParameterDeclaration.class, parameters, parametersPos);
return parameters; return parameters;
} }
@ -73,7 +74,7 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
if (parameter != null) { if (parameter != null) {
parameter.setParent(this); parameter.setParent(this);
parameter.setPropertyInParent(FUNCTION_PARAMETER); parameter.setPropertyInParent(FUNCTION_PARAMETER);
parameters = ArrayUtil.appendAt( IASTParameterDeclaration.class, parameters, ++parametersPos, parameter ); parameters = ArrayUtil.appendAt(IASTParameterDeclaration.class, parameters, ++parametersPos, parameter);
} }
} }
@ -100,7 +101,7 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
@Override @Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( parameters != null ) { if (parameters != null) {
for (int i = 0; i < parameters.length; ++i) { for (int i = 0; i < parameters.length; ++i) {
if (child == parameters[i]) { if (child == parameters[i]) {
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());
@ -120,7 +121,7 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
// introduce a scope for function declarations and definitions, only. // introduce a scope for function declarations and definitions, only.
IASTNode node= getParent(); IASTNode node= getParent();
while(!(node instanceof IASTDeclaration)) { while (!(node instanceof IASTDeclaration)) {
if (node==null) if (node==null)
return null; return null;
node= node.getParent(); node= node.getParent();

View file

@ -6,11 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion) * Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist; package org.eclipse.cdt.internal.ui.text.contentassist;
@ -100,7 +100,6 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
protected List<ICompletionProposal> computeCompletionProposals( protected List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext context, CContentAssistInvocationContext context,
IASTCompletionNode completionNode, String prefix) { IASTCompletionNode completionNode, String prefix) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if (inPreprocessorDirective(context)) { if (inPreprocessorDirective(context)) {
@ -202,10 +201,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private void addMacroProposals(CContentAssistInvocationContext context, String prefix, private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
List<ICompletionProposal> proposals) { List<ICompletionProposal> proposals) {
IASTCompletionNode completionNode = context.getCompletionNode(); IASTCompletionNode completionNode = context.getCompletionNode();
addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit() addMacroProposals(context, prefix, proposals,
.getMacroDefinitions()); completionNode.getTranslationUnit().getMacroDefinitions());
addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit() addMacroProposals(context, prefix, proposals,
.getBuiltinMacroDefinitions()); completionNode.getTranslationUnit().getBuiltinMacroDefinitions());
} }
private void addMacroProposals(CContentAssistInvocationContext context, String prefix, private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
@ -496,11 +495,11 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
String repString = repStringBuff.toString(); String repString = repStringBuff.toString();
Image image = getImage(variable); Image image = getImage(variable);
final int relevance = isLocalVariable(variable) final int relevance = isLocalVariable(variable) ?
? RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE :
: isField(variable) isField(variable) ?
? RelevanceConstants.FIELD_TYPE_RELEVANCE RelevanceConstants.FIELD_TYPE_RELEVANCE :
: RelevanceConstants.VARIABLE_TYPE_RELEVANCE; RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
CCompletionProposal proposal = createProposal(repString, dispString, idString, CCompletionProposal proposal = createProposal(repString, dispString, idString,
context.getCompletionNode().getLength(), image, baseRelevance + relevance, context); context.getCompletionNode().getLength(), image, baseRelevance + relevance, context);
proposals.add(proposal); proposals.add(proposal);
@ -508,8 +507,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
private IType unwindTypedefs(final IType t) { private IType unwindTypedefs(final IType t) {
IType r= t; IType r= t;
while (r instanceof ITypedef) while (r instanceof ITypedef) {
r= ((ITypedef) r).getType(); r= ((ITypedef) r).getType();
}
return r != null ? r : t; return r != null ? r : t;
} }
@ -541,12 +541,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return false; return false;
} }
private void handleNamespace(ICPPNamespace namespace, private void handleNamespace(ICPPNamespace namespace, IASTCompletionContext astContext,
IASTCompletionContext astContext, CContentAssistInvocationContext cContext, int baseRelevance,
CContentAssistInvocationContext cContext,
int baseRelevance,
List<ICompletionProposal> proposals) { List<ICompletionProposal> proposals) {
if (astContext instanceof ICPPASTQualifiedName) { if (astContext instanceof ICPPASTQualifiedName) {
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext) IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
.getCompletionContext(); .getCompletionContext();
@ -652,8 +649,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return getImage(delegates[0]); return getImage(delegates[0]);
} }
return imageDescriptor != null return imageDescriptor != null ?
? CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor) CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor) : null;
: null;
} }
} }