diff options
author | Anton Leherbauer | 2007-03-22 14:28:35 +0000 |
---|---|---|
committer | Anton Leherbauer | 2007-03-22 14:28:35 +0000 |
commit | 34cf7052a6c2f81b08352c6055878526a357508d (patch) | |
tree | 217a4b30782707af0345e3c53f520519b4a1ab7c | |
parent | b0bdfa4229a32c0997a47160247f5ed2a9889ab9 (diff) | |
download | org.eclipse.cdt-34cf7052a6c2f81b08352c6055878526a357508d.tar.gz org.eclipse.cdt-34cf7052a6c2f81b08352c6055878526a357508d.tar.xz org.eclipse.cdt-34cf7052a6c2f81b08352c6055878526a357508d.zip |
Fix for 178577: need IASTCompletionNode interface in dom parser (patch by Mike Kucera)
21 files changed, 129 insertions, 95 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java index 99a8a396653..f75d79503f8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.prefix; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunction; @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable; public class BasicCompletionTest extends CompletionTestBase { - private void testVar(ASTCompletionNode node) throws Exception { + private void testVar(IASTCompletionNode node) throws Exception { IASTName[] names = node.getNames(); assertEquals(1, names.length); IBinding[] bindings = names[0].getCompletionContext().findBindings( @@ -44,7 +44,7 @@ public class BasicCompletionTest extends CompletionTestBase { code.append("void func2() { fu"); // C++ - ASTCompletionNode node = getGPPCompletionNode(code.toString()); + IASTCompletionNode node = getGPPCompletionNode(code.toString()); IASTName[] names = node.getNames(); // There are three names, one as an expression, one that isn't connected, one as a declaration assertEquals(3, names.length); @@ -82,7 +82,7 @@ public class BasicCompletionTest extends CompletionTestBase { code.append("bl"); // C++ - ASTCompletionNode node = getGPPCompletionNode(code.toString()); + IASTCompletionNode node = getGPPCompletionNode(code.toString()); IASTName[] names = node.getNames(); assertEquals(2, names.length); assertNull(names[0].getTranslationUnit()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java index 82243bc5174..ff42f62472c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java @@ -15,7 +15,7 @@ import java.util.Comparator; import junit.framework.TestCase; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; @@ -44,7 +44,7 @@ public class CompletionTestBase extends TestCase { private static final IParserLogService NULL_LOG = new NullLogService(); - protected ASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException { + protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException { CodeReader codeReader = new CodeReader(code.toCharArray()); ScannerInfo scannerInfo = new ScannerInfo(); IScannerExtensionConfiguration configuration = null; @@ -84,11 +84,11 @@ public class CompletionTestBase extends TestCase { return parser.getCompletionNode(); } - protected ASTCompletionNode getGPPCompletionNode(String code) throws ParserException { + protected IASTCompletionNode getGPPCompletionNode(String code) throws ParserException { return getCompletionNode(code, ParserLanguage.CPP, true); } - protected ASTCompletionNode getGCCCompletionNode(String code) throws ParserException { + protected IASTCompletionNode getGCCCompletionNode(String code) throws ParserException { return getCompletionNode(code, ParserLanguage.C, true); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java index 95f0f35d69a..bd4f90f706a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.model; import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; @@ -95,7 +95,7 @@ public interface ILanguage extends IAdaptable { * @return * @throws CoreException */ - public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException; + public IASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException; /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java index 80c8e2bfc93..3064a87cdc0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.core.model; import java.util.Map; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.parser.CodeReader; @@ -479,5 +479,5 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource * @return * @throws CoreException */ - public ASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException; + public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 05e179a34fc..32fd140cb00 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -24,7 +24,7 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.CModelException; @@ -750,7 +750,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } - public ASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException { + public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException { ICodeReaderFactory codeReaderFactory; if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) { ICodeReaderFactory fallbackFactory; 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 459f34adfc0..bf025edb807 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 @@ -16,19 +16,10 @@ import java.util.List; import org.eclipse.cdt.core.parser.IToken; /** - * This class represents the node that would occur at the point of a context - * completion. - * - * This node may contain the prefix text of an identifer up to the point. If - * there is no prefix, the completion occurred at the point where a new token - * would have begun. - * - * The node points to the parent node where this node, if replaced by a proper - * node, would reside in the tree. * * @author Doug Schaefer */ -public class ASTCompletionNode { +public class ASTCompletionNode implements IASTCompletionNode { private IToken completionToken; @@ -36,8 +27,6 @@ public class ASTCompletionNode { private IASTTranslationUnit translationUnit; - // used for debug - public int count; /** * Only constructor. @@ -59,38 +48,29 @@ public class ASTCompletionNode { names.add(name); } - /** - * If the point of completion was at the end of a potential identifier, this - * string contains the text of that identifier. - * - * @return the prefix text up to the point of completion + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getPrefix() */ public String getPrefix() { return completionToken.getType() != IToken.tEOC ? completionToken.getImage() : ""; //$NON-NLS-1$ } - /** - * Get the length of the completion point. - * - * @return length of completion token + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getLength() */ public int getLength() { return completionToken.getLength(); } - /** - * Get a list of names that fit in this context. - * - * @return array of IASTName's + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IASTCompletionNode#getNames() */ public IASTName[] getNames() { return (IASTName[]) names.toArray(new IASTName[names.size()]); } - /** - * Get the translation unit for this completion - * - * @return the translation unit + /* (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/ast/IASTCompletionNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompletionNode.java new file mode 100644 index 00000000000..76d21301994 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompletionNode.java @@ -0,0 +1,45 @@ +package org.eclipse.cdt.core.dom.ast; + +/** + * This represents the node that would occur at the point of a context + * completion. + * + * This node may contain the prefix text of an identifer up to the point. If + * there is no prefix, the completion occurred at the point where a new token + * would have begun. + * + * The node points to the parent node where this node, if replaced by a proper + * node, would reside in the tree. + */ +public interface IASTCompletionNode { + + /** + * If the point of completion was at the end of a potential identifier, this + * string contains the text of that identifier. + * + * @return the prefix text up to the point of completion + */ + public String getPrefix(); + + /** + * Get the length of the completion point. + * + * @return length of completion token + */ + public int getLength(); + + /** + * Get a list of names that fit in this context. + * + * @return array of IASTName's + */ + public IASTName[] getNames(); + + /** + * Get the translation unit for this completion + * + * @return the translation unit + */ + public IASTTranslationUnit getTranslationUnit(); + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java index dc252f2e423..906b73c8a88 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/ISourceCodeParser.java @@ -10,8 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.parser; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.parser.ParseError; /** * Interface for an AST source code parser. @@ -49,11 +50,11 @@ public interface ISourceCodeParser { public boolean encounteredError(); /** - * Compute an {@link ASTCompletionNode} for code completion. + * Compute an {@link IASTCompletionNode} for code completion. * @return a completion node or <code>null</code> if none could be computed * * @throws ParseError if parsing has been cancelled or for other reasons */ - public ASTCompletionNode getCompletionNode(); + public IASTCompletionNode getCompletionNode(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java index 55a85168011..bbfe685bede 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/AbstractCLanguage.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Set; import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -27,8 +27,8 @@ import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.AbstractLanguage; -import org.eclipse.cdt.core.model.IContributedModelBuilder; import org.eclipse.cdt.core.model.ICLanguageKeywords; +import org.eclipse.cdt.core.model.IContributedModelBuilder; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IParserLogService; @@ -98,7 +98,7 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa return ast; } - public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, + public IASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { IScanner scanner= createScanner(reader, scanInfo, fileCreator, log); @@ -108,10 +108,7 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa // Run the parse and return the completion node parser.parse(); - ASTCompletionNode node= parser.getCompletionNode(); - if (node != null) { - node.count= scanner.getCount(); - } + IASTCompletionNode node= parser.getCompletionNode(); return node; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java index 766d3410972..f4a0f98f543 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPLanguage.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Set; import org.eclipse.cdt.core.dom.ICodeReaderFactory; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -97,7 +97,7 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC return ast; } - public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, + public IASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { IScanner scanner= createScanner(reader, scanInfo, fileCreator, log); scanner.setContentAssistMode(offset); @@ -106,10 +106,7 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC // Run the parse and return the completion node parser.parse(); - ASTCompletionNode node= parser.getCompletionNode(); - if (node != null) { - node.count= scanner.getCount(); - } + IASTCompletionNode node= parser.getCompletionNode(); return node; } 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 6bb1731b037..ac48f4cd9bf 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 @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTBreakStatement; import org.eclipse.cdt.core.dom.ast.IASTCaseStatement; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression; import org.eclipse.cdt.core.dom.ast.IASTContinueStatement; @@ -147,7 +148,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { * * @see org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser#getCompletionNode() */ - public ASTCompletionNode getCompletionNode() { + public IASTCompletionNode getCompletionNode() { return completionNode; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java index b0378263ff1..ba3c8e96ca4 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java @@ -9,7 +9,7 @@ * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopyProvider; import org.eclipse.cdt.internal.core.dom.InternalASTServiceProvider; @@ -139,14 +139,14 @@ public class CDOM implements IASTServiceProvider { return defaultService.getTranslationUnit(fileToParse, fileCreator, configuration ); } - public ASTCompletionNode getCompletionNode(IFile fileToParse, int offset, + public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly //In the future, we may need to delegate based upon context provided return defaultService.getCompletionNode(fileToParse, offset, fileCreator); } - public ASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, + public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly //In the future, we may need to delegate based upon context provided diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IASTServiceProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IASTServiceProvider.java index 3432db83382..98151954c1f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IASTServiceProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/IASTServiceProvider.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -95,7 +95,7 @@ public interface IASTServiceProvider { * @return syntactical parse tree * @throws UnsupportedDialectException */ - public ASTCompletionNode getCompletionNode( IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException; + public IASTCompletionNode getCompletionNode( IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException; /** * Returns a parse tree that represents the content provided as parameters. @@ -107,6 +107,6 @@ public interface IASTServiceProvider { * @return syntactical parse tree * @throws UnsupportedDialectException */ - public ASTCompletionNode getCompletionNode( IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException; + public IASTCompletionNode getCompletionNode( IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java index 50113667040..2132734bd5d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java @@ -14,7 +14,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IASTServiceProvider; import org.eclipse.cdt.core.dom.ICodeReaderFactory; import org.eclipse.cdt.core.dom.IParserConfiguration; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; @@ -171,17 +171,17 @@ public class InternalASTServiceProvider implements IASTServiceProvider { return parser.parse(); } - public ASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, + public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return getCompletionNode(fileToParse.getFullPath().toOSString(), project, offset, fileCreator); } - public ASTCompletionNode getCompletionNode(IFile fileToParse, int offset, + public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return getCompletionNode(fileToParse.getLocation().toOSString(), fileToParse, offset, fileCreator); } - public ASTCompletionNode getCompletionNode(String filename, IResource infoProvider, int offset, + public IASTCompletionNode getCompletionNode(String filename, IResource infoProvider, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { // Get the scanner info IScannerInfo scanInfo = null; @@ -223,10 +223,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider { // Run the parse and return the completion node parser.parse(); - ASTCompletionNode node = parser.getCompletionNode(); - if (node != null) { - node.count = scanner.getCount(); - } + IASTCompletionNode node = parser.getCompletionNode(); return node; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java index 788ace7cc58..63b6f66bc9a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java @@ -18,7 +18,7 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.ui.IEditorPart; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.ICProject; @@ -47,7 +47,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont private boolean fTUComputed= false; private int fParseOffset= -1; private boolean fParseOffsetComputed= false; - private ASTCompletionNode fCN= null; + private IASTCompletionNode fCN= null; private boolean fCNComputed= false; private IIndex fIndex = null; private int fContextInfoPosition; @@ -104,7 +104,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont return unit == null ? null : unit.getCProject(); } - public ASTCompletionNode getCompletionNode() { + public IASTCompletionNode getCompletionNode() { if (fCNComputed) return fCN; fCNComputed = true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java index 108993f4485..5861a7b30bb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java @@ -20,10 +20,10 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextUtilities; import org.eclipse.swt.graphics.Image; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -75,7 +75,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer protected List computeCompletionProposals( CContentAssistInvocationContext context, - ASTCompletionNode completionNode, String prefix) { + IASTCompletionNode completionNode, String prefix) { List proposals = new ArrayList(); @@ -138,7 +138,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer private void addMacroProposals(CContentAssistInvocationContext context, String prefix, List proposals) { char[] prefixChars= prefix.toCharArray(); - ASTCompletionNode completionNode = context.getCompletionNode(); + IASTCompletionNode completionNode = context.getCompletionNode(); IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions(); if (macros != null) for (int i = 0; i < macros.length; ++i) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java index 0429b833ddc..ef9a4c3d64a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java @@ -18,7 +18,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.graphics.Image; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -33,7 +33,7 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer protected List computeCompletionProposals( CContentAssistInvocationContext cContext, - ASTCompletionNode completionNode, String prefix) + IASTCompletionNode completionNode, String prefix) throws CoreException { boolean handleHelp = false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java index 39225c59d95..8c29c9d52fa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java @@ -21,7 +21,7 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextUtilities; import org.eclipse.swt.graphics.Image; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -37,7 +37,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu protected List computeCompletionProposals( CContentAssistInvocationContext context, - ASTCompletionNode completionNode, String prefix) + IASTCompletionNode completionNode, String prefix) throws CoreException { // No prefix, no completions @@ -82,7 +82,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu * @param context the content assist invocation context * @return <code>false</code> if the given invocation context looks like a field reference */ - private boolean isValidContext(ASTCompletionNode completionNode) { + private boolean isValidContext(IASTCompletionNode completionNode) { IASTName[] names = completionNode.getNames(); for (int i = 0; i < names.length; ++i) { IASTName name = names[i]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/LegacyCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/LegacyCompletionProposalComputer.java index 9090d33c497..92c2a6cb1d2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/LegacyCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/LegacyCompletionProposalComputer.java @@ -24,13 +24,14 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.text.ITextViewer; import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor; /** - * A proposal computer for handling the legacy extension from the - * completionContributors extension point. + * A proposal computer for handling the legacy extensions from the + * <tt>org.eclipse.cdt.core.completionContributors</tt> extension point. * * @since 4.0 */ @@ -44,8 +45,12 @@ public class LegacyCompletionProposalComputer extends ParsingBasedProposalComput protected List computeCompletionProposals( CContentAssistInvocationContext context, - ASTCompletionNode completionNode, String prefix) throws CoreException { + IASTCompletionNode completionNode, String prefix) throws CoreException { + if (!(completionNode instanceof ASTCompletionNode)) { + // unsupported IASTCompletionNode implementation + return Collections.EMPTY_LIST; + } if (context.isContextInformationStyle()) { // context information cannot be supported by completionContributors return Collections.EMPTY_LIST; @@ -70,7 +75,9 @@ public class LegacyCompletionProposalComputer extends ParsingBasedProposalComput if (!(contribObject instanceof ICompletionContributor)) continue; ICompletionContributor contributor = (ICompletionContributor)contribObject; - contributor.contributeCompletionProposals(viewer, offset, workingCopy, completionNode, prefix, proposals); + contributor.contributeCompletionProposals(viewer, offset, + workingCopy, (ASTCompletionNode) completionNode, + prefix, proposals); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java index ac70af4cfff..ecb8589b742 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java @@ -22,7 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext; import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer; @@ -42,7 +42,7 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa if (context instanceof CContentAssistInvocationContext) { CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context; - ASTCompletionNode completionNode = cContext.getCompletionNode(); + IASTCompletionNode completionNode = cContext.getCompletionNode(); if (completionNode == null) return Collections.EMPTY_LIST; String prefix = completionNode.getPrefix(); if (prefix == null) { @@ -60,7 +60,7 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa protected abstract List computeCompletionProposals( CContentAssistInvocationContext context, - ASTCompletionNode completionNode, + IASTCompletionNode completionNode, String prefix) throws CoreException; public List computeContextInformation( diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java index da63304ceea..f07d5e68894 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 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 @@ -12,10 +12,19 @@ package org.eclipse.cdt.ui.text.contentassist; import java.util.List; +import org.eclipse.jface.text.ITextViewer; + import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.model.IWorkingCopy; -import org.eclipse.jface.text.ITextViewer; +/** + * This interface must be implemented by clients extending the extension point + * <tt>org.eclipse.cdt.core.completionContributors</tt>. + * + * @deprecated Clients should extend the new extension point + * <tt>completionProprosalComputer</tt> and implement interface + * {@link ICompletionProposalComputer} + */ public interface ICompletionContributor { /** @@ -24,7 +33,7 @@ public interface ICompletionContributor { * @param viewer the text viewer where completion is occuring * @param offset the offset into the text where the completion is occuring * @param completionNode the completion node produced by the parser for the offset - * @param proposals the current list of proposals. This method should any additional + * @param proposals the current list of proposals. This method should add any additional * proposals to this list. */ void contributeCompletionProposals(ITextViewer viewer, |