Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-02-06 23:03:57 +0000
committerMike Kucera2008-02-06 23:03:57 +0000
commite885c18bc41ffd1f8a0467fb786ab8549196462c (patch)
tree44f71271d7f1cd74e09e9e15e0dd0933f31879c4 /core/org.eclipse.cdt.core/parser
parente6ce9e4053247289df59902d83b36ec4c6d49785 (diff)
downloadorg.eclipse.cdt-e885c18bc41ffd1f8a0467fb786ab8549196462c.tar.gz
org.eclipse.cdt-e885c18bc41ffd1f8a0467fb786ab8549196462c.tar.xz
org.eclipse.cdt-e885c18bc41ffd1f8a0467fb786ab8549196462c.zip
minor code cleanup
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java20
3 files changed, 22 insertions, 53 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java
index e4904e1b3c4..baa316c70b0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -16,62 +16,41 @@ import java.util.List;
import org.eclipse.cdt.core.parser.IToken;
/**
- *
* @author Doug Schaefer
*/
public class ASTCompletionNode implements IASTCompletionNode {
- private IToken completionToken;
+ private final IToken completionToken;
+ private final List<IASTName> names = new ArrayList<IASTName>();
+ private final IASTTranslationUnit translationUnit;
- private List names = new ArrayList();
- private IASTTranslationUnit translationUnit;
-
-
- /**
- * Only constructor.
- *
- * @param completionToken the completion token
- * @param translationUnit the translation unit for this completion
- */
public ASTCompletionNode(IToken completionToken, IASTTranslationUnit translationUnit) {
this.completionToken = completionToken;
this.translationUnit = translationUnit;
}
- /**
- * Add a name to node.
- *
- * @param name
- */
+
public void addName(IASTName name) {
names.add(name);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getPrefix()
- */
+
public String getPrefix() {
- return completionToken.getType() != IToken.tEOC ? completionToken.getImage() : ""; //$NON-NLS-1$
+ return completionToken.getType() == IToken.tEOC ? "" : completionToken.getImage(); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getLength()
- */
+
public int getLength() {
return completionToken.getLength();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getNames()
- */
+
public IASTName[] getNames() {
- return (IASTName[]) names.toArray(new IASTName[names.size()]);
+ return names.toArray(new IASTName[names.size()]);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getTranslationUnit()
- */
+
public IASTTranslationUnit getTranslationUnit() {
return translationUnit;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java
index 83bb6aeda73..1f1bc78b238 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java
@@ -151,16 +151,14 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
* @return an instance of ISourceCodeParser
*/
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) {
- ParserMode mode= null;
- if (forCompletion) {
+ ParserMode mode;
+ if(forCompletion)
mode= ParserMode.COMPLETION_PARSE;
- }
- else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) {
+ else if((options & OPTION_SKIP_FUNCTION_BODIES) != 0)
mode= ParserMode.STRUCTURAL_PARSE;
- }
- else {
+ else
mode= ParserMode.COMPLETE_PARSE;
- }
+
return createParser(scanner, mode, log, index);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index a4444cec8d4..ead967abe83 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -127,9 +127,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
if (logService instanceof AbstractParserLogService) {
return (AbstractParserLogService) logService;
}
- else {
- return new ParserLogServiceWrapper(logService);
- }
+ return new ParserLogServiceWrapper(logService);
}
protected final void throwBacktrack(int offset, int length) throws BacktrackException {
@@ -150,12 +148,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
// Use to create the completion node
protected ASTCompletionNode createCompletionNode(IToken token) {
// the preprocessor may deliver tokens for literals or header-names.
- if (completionNode == null && token != null)
- switch(token.getType()) {
- case IToken.tCOMPLETION:
- completionNode = new ASTCompletionNode(token, getTranslationUnit());
- break;
- }
+ if(completionNode == null && token != null && token.getType() == IToken.tCOMPLETION) {
+ completionNode = new ASTCompletionNode(token, getTranslationUnit());
+ }
return completionNode;
}
@@ -264,8 +259,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected static int parseCount = 0;
- protected void handleOffsetLimitException(
- OffsetLimitReachedException exception) throws EndOfFileException {
+ protected void handleOffsetLimitException(OffsetLimitReachedException exception) throws EndOfFileException {
if (mode != ParserMode.COMPLETION_PARSE)
throw new EndOfFileException();
createCompletionNode(exception.getFinalToken());
@@ -283,9 +277,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
* If there are no more tokens.
*/
protected IToken mark() throws EndOfFileException {
- if (currToken == null)
- currToken = fetchToken();
- return currToken;
+ return currToken == null ? currToken = fetchToken() : currToken;
}
/**

Back to the top