[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: REJECTED Re: [cdt-patch] Code Assist bug fixes
|
Resubmitted.
Thanks,
Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group
| John Camelon/Ottawa/IBM@IBMCA
Sent by: cdt-patch-admin@xxxxxxxxxxx
09/22/2003 10:53 AM
Please respond to cdt-patch
|
To:
cdt-patch@xxxxxxxxxxx
cc:
Subject:
REJECTED Re: [cdt-patch] Code Assist
bug fixes |
Deja vu all over again! This patch has the same
problem as Andrew's.
JUnit runs clean on Windows, but we get a failure on Linux. Both
JREs are
1.3.
The offending null object is an array called results.
assertEquals(results.length, 7);
This looks similar to the problems Bogdan had previously in one of his
tests, maybe he could shed some light on what's going on.
java.lang.NullPointerException
at
org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest.testCompletionProposals(CompletionProposalsTest.java:119)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.run(AutomatedIntegrationSuite.java:116)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at
org.eclipse.pde.internal.junit.ui.RemotePluginTestRunner.main(RemotePluginTestRunner.java:30)
at
org.eclipse.pde.internal.junit.ui.UITestApplication.runEventLoop(UITestApplication.java:35)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
at
org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:431)
at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24)
Fix this and give it another shot.
JohnC
cdt-patch-admin@xxxxxxxxxxx wrote on 09/19/2003 04:14:52 PM:
>
> Core :
> Solution to bug#43162 : Code Assist not
showing the right
> return value:
> Saved a function return value string in
the BasicSearchMatch
object.
> Created a new package org.eclipse.cdt.internal.core.parser.util
and
> added ASTUtil class with static methods
to help convert an
> ASTFunction
> return type from IASTAbstractDeclaration
to String. Note that
this was
> previously implemented in the CModelBuilder.
I just moved it
> to a common
> library for others (BasicSearchMatch)
to use.
> UI:
> Solutions to
> bug#43162 : Code Assist not showing the
right return value
> Bug#43145 : foo function still showing
in Code Assist even
> if "f" is deleted
> Bug#42810 : Code Assist adding characters
after pressing <enter>
> Bug#42861 : Code Assist should be case
insensitive.
>
> Tests:
> Solution to bug#43162 : Code Assist not
showing the right
> return value.
> Solution to Bug#42861 : Code Assist should
be case insensitive.
> Modified the CompletionProposalsTest to
include upper and lower
cases
> and to include functions with different
return values.
>
> Sorry John, but the rest are visual bugs
and could not add
> test cases for them.
>
> Thanks,
> Hoda Amer
> Staff Software Engineer
> Rational Software - IBM Software Group
>
> [attachment "core.sep.19.txt" deleted by John Camelon/Ottawa/IBM]
> [attachment "tests.sep.19.txt" deleted by John Camelon/Ottawa/IBM]
> [attachment "ui.sep.19.txt" deleted by John Camelon/Ottawa/IBM]
_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.182
diff -u -r1.182 ChangeLog
--- ChangeLog 22 Sep 2003 18:38:30 -0000 1.182
+++ ChangeLog 22 Sep 2003 21:40:14 -0000
@@ -1,3 +1,14 @@
+<<<<<<< ChangeLog
+<<<<<<< ChangeLog
+2003-09-19 Hoda Amer
+ Solutions to
+ bug#43162 : Code Assist not showing the right return value
+ Bug#43145 : foo function still showing in Code Assist even if "f" is deleted
+ Bug#42810 : Code Assist adding characters after pressing <enter>
+ Bug#42861 : Code Assist should be case insensitive.
+
+=======
+=======
2003-09-22 Andrew Niefer
fix for bug 43327 Code Complete finds local variables
- update calls to SearchEngine.search. CodeCompletion passes true for excludeLocalDeclarations
@@ -15,6 +26,7 @@
* plugin.xml
+>>>>>>> 1.181
2003-09-21 Alain Magloire
Patch contributed by Keith Campbell.
@@ -43,6 +55,7 @@
* src/org/eclipse/cdt/internal/ui/editor/asm/AsmPartitionScanner.java
+>>>>>>> 1.179
2003-09-18 Hoda Amer
Solution to bug#42611 : New Class Wizard should be hidden for C projects
Index: src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java,v
retrieving revision 1.10
diff -u -r1.10 CEditorPreferencePage.java
--- src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 28 Jun 2003 19:48:06 -0000 1.10
+++ src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 22 Sep 2003 21:40:15 -0000
@@ -14,6 +14,7 @@
import java.util.Map;
import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@@ -58,6 +59,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
+import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
@@ -352,6 +354,7 @@
*/
public void createControl(Composite parent) {
super.createControl(parent);
+ WorkbenchHelp.setHelp(parent, ICHelpContextIds.C_EDITOR_PREF_PAGE);
}
protected void handleListSelection() {
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java,v
retrieving revision 1.11
diff -u -r1.11 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 22 Sep 2003 18:38:30 -0000 1.11
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 22 Sep 2003 21:40:15 -0000
@@ -12,7 +12,6 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.index.TagFlags;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunction;
@@ -161,7 +160,7 @@
/**
* @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
*/
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
return null;
}
@@ -206,6 +205,7 @@
* @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
+
IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
ITranslationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput());
@@ -242,7 +242,6 @@
fTemplateEngine[i].reset();
fTemplateEngine[i].complete(viewer, documentOffset, null);
} catch (Exception x) {
- System.out.println("Template Exception");
CUIPlugin.getDefault().log(x);
}
@@ -313,11 +312,11 @@
return order (evalProposals(document, pos, length, getCurrentScope (unit, pos)));
}
- private ICCompletionProposal[] evalProposals(IDocument document, int pos, int length, ICElement currentScope) {
+ private ICCompletionProposal[] evalProposals(IDocument document, int startPos, int length, ICElement currentScope) {
boolean isDereference = false;
IRegion region;
String frag = "";
-
+ int pos = startPos;
// TODO: Do all possible scopes
// possible scopes include IStructure, INamespace, and ITranslationUnit
if( ( !(currentScope instanceof IMethod))
@@ -372,7 +371,8 @@
}
try {
- frag = document.get(region.getOffset(), region.getLength());
+ //frag = document.get(region.getOffset(), region.getLength());
+ frag = document.get(region.getOffset(), startPos - region.getOffset());
frag = frag.trim();
} catch (BadLocationException ex) {
return null; //Bail out on error
@@ -403,7 +403,7 @@
// Based on the frag name, build a list of completion proposals
ArrayList completions = new ArrayList();
-
+
// Look in index manager
addProposalsFromModel(region, frag,currentScope, completions);
@@ -431,7 +431,7 @@
proposal = new CCompletionProposal(fname,
region.getOffset(),
region.getLength(),
- getTagImage(TagFlags.T_FUNCTION),
+ CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION),
fproto.getPrototypeString(true),
2);
@@ -447,34 +447,6 @@
}
}
-// It is not needed to follow referenced projects since search does this for us now
-/* private void addProposalsFromModel(IRegion region, String frag, ICElement currentScope, ArrayList completions) {
- IProject project = null;
- IEditorInput input = fEditor.getEditorInput();
- if (input instanceof IFileEditorInput) {
- project = ((IFileEditorInput) input).getFile().getProject();
-
- // Bail out quickly, if the project was deleted.
- if (!project.exists()) {
- project = null;
- }
- }
- if (project != null) {
- addProjectCompletions(project, region, frag, currentScope, completions);
- // Now query referenced projects
- IProject referenced[];
- try {
- referenced = project.getReferencedProjects();
- if (referenced.length > 0) {
- for (int i = 0; i < referenced.length; i++) {
- addProjectCompletions(referenced[i], region, frag, currentScope, completions);
- }
- }
- } catch (CoreException e) {
- }
- }
- }
-*/
private FunctionPrototypeSummary getPrototype (BasicSearchMatch match) {
switch(match.getElementType()){
case ICElement.C_FUNCTION:
@@ -482,7 +454,7 @@
case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION:
{
- return (new FunctionPrototypeSummary ( match.getName() ));
+ return (new FunctionPrototypeSummary ( match.getReturnType() + " " + match.getName() ));
}
default:
return null;
@@ -529,28 +501,18 @@
ICSearchScope scope = SearchEngine.createCSearchScope(projectScopeElement, true);
OrPattern orPattern = new OrPattern();
// search for global variables, functions, classes, structs, unions, enums and macros
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DEFINITIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, true ));
- orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true ));
+
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false ));
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.FUNCTION, ICSearchConstants.DEFINITIONS, false ));
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false ));
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false ));
+ orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
elementsFound.addAll(resultCollector.getSearchResults());
if((currentScope instanceof IMethod) || (currentScope instanceof IMethodDeclaration) ){
// add the methods and fields of the parent class
-/* // use search with CElement Scope
- ICElement[] classScopeElements = new ICElement[1];
- classScopeElements[0] = currentScope.getParent();
- ICSearchScope classScope = SearchEngine.createCSearchScope(classScopeElements);
- OrPattern classOrPattern = new OrPattern();
- classOrPattern.addPattern(SearchEngine.createSearchPattern(prefix, ICSearchConstants.FIELD, ICSearchConstants.DECLARATIONS, true));
- classOrPattern.addPattern(SearchEngine.createSearchPattern(prefix, ICSearchConstants.METHOD, ICSearchConstants.DECLARATIONS, true));
- classOrPattern.addPattern(SearchEngine.createSearchPattern(prefix, ICSearchConstants.METHOD, ICSearchConstants.DEFINITIONS, true));
- searchEngine.search(CUIPlugin.getWorkspace(), classOrPattern, classScope, resultCollector);
- elementsFound.addAll(resultCollector.getSearchResults());
-*/
// Work around until CElement scope is implemented
IStructure parentClass = (IStructure) currentScope.getParent();
ArrayList children = new ArrayList();
@@ -576,6 +538,7 @@
childMatch.setStatic(child.isStatic());
if(child instanceof IMethodDeclaration){
childMatch.setName(((IMethodDeclaration)child).getSignature());
+ childMatch.setReturnType( ((IMethodDeclaration)child).getReturnType() );
}
else {
childMatch.setName(child.getElementName());
@@ -613,7 +576,7 @@
infoString.append(" - Parent: ");
infoString.append(match.getParentName());
}
-
+
proposal = new CCompletionProposal(
replaceString, // Replacement string
region.getOffset(),
@@ -638,94 +601,4 @@
proposal.setAdditionalProposalInfo(infoString.toString());
}
}
-
-// Search (and the new indexer) is used now instead of the old indexer and CTags
-/* private void addProjectCompletions(IProject project, IRegion region, String frag, ArrayList completions) {
- IndexModel model = IndexModel.getDefault();
-
- ITagEntry[] tags = model.query(project, frag + "*", false, false);
- if (tags != null && tags.length > 0) {
- for (int i = 0; i < tags.length; i++) {
- FunctionPrototypeSummary fproto = null;
- String fargs = null;
- String fdisplay = null;
- String fdesc = null;
- String fname = tags[i].getTagName();
- int kind = tags[i].getKind();
-
- //No member completion yet
- if (kind == TagFlags.T_MEMBER) {
- continue;
- }
-
- //This doesn't give you a nice "function" look to macros, but is safe
- if (kind == TagFlags.T_FUNCTION || kind == TagFlags.T_PROTOTYPE) {
- fname = fname + "()";
-
- String pattern = tags[i].getPattern();
- if(pattern != null) {
- fproto = new FunctionPrototypeSummary(pattern);
- }
-
- if(fproto == null) {
- fproto = new FunctionPrototypeSummary(fname);
- }
- }
-
- if(fproto != null) {
- fargs = fproto.getArguments();
- fdisplay = fproto.getPrototypeString(true);
- } else {
- fdisplay = fname;
- }
-
- //@@@ In the future something more usefull could go in here (ie Doxygen/JavaDoc)
- fdesc = "<b>" + fname + "</b><br>" + "Defined in:<br> " + tags[i].getFileName();
- if(tags[i].getClassName() != null) {
- fdesc = fdesc + "<br>Class:<br> " + tags[i].getClassName();
- }
-
- //System.out.println("tagmatch " + fname + " proto " + proto + " type" + tags[i].getKind());
- CCompletionProposal proposal;
- proposal = new CCompletionProposal(fname,
- region.getOffset(),
- region.getLength(),
- getTagImage(kind),
- fdisplay,
- 3);
- completions.add(proposal);
-
- if(fdesc != null) {
- proposal.setAdditionalProposalInfo(fdesc);
- }
-
- if(fargs != null && fargs.length() > 0) {
- proposal.setContextInformation(new ContextInformation(fname, fargs));
- }
- }
- }
- }
-*/
- private Image getTagImage(int kind) {
- switch (kind) {
- case TagFlags.T_PROTOTYPE :
- return CPluginImages.get(CPluginImages.IMG_OBJS_DECLARATION);
- case TagFlags.T_CLASS :
- return CPluginImages.get(CPluginImages.IMG_OBJS_CLASS);
- case TagFlags.T_ENUM :
- case TagFlags.T_VARIABLE :
- case TagFlags.T_MEMBER :
- return CPluginImages.get(CPluginImages.IMG_OBJS_FIELD);
- case TagFlags.T_FUNCTION :
- return CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION);
- case TagFlags.T_STRUCT :
- return CPluginImages.get(CPluginImages.IMG_OBJS_STRUCT);
- case TagFlags.T_UNION :
- return CPluginImages.get(CPluginImages.IMG_OBJS_UNION);
- case TagFlags.T_MACRO :
- return CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
- }
- return CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION);
- }
-
}
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProposal.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProposal.java,v
retrieving revision 1.2
diff -u -r1.2 CCompletionProposal.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProposal.java 24 Jun 2003 14:22:14 -0000 1.2
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProposal.java 22 Sep 2003 21:40:15 -0000
@@ -165,11 +165,11 @@
int functionBracketIndex;
boolean isBeforeBracket;
String replacementStringCopy = fReplacementString;
-
+ fReplacementLength = offset - fReplacementOffset;
//If just providing context information, then don't move the cursor
- if(offset != (fReplacementOffset + fReplacementLength)) {
- fCursorPosition = offset - fReplacementOffset;
- }
+// if(offset != (fReplacementOffset + fReplacementLength)) {
+// fCursorPosition = offset - fReplacementOffset;
+// }
try {
functionBracketIndex = fReplacementString.indexOf("()");
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.149
diff -u -r1.149 ChangeLog
--- ChangeLog 17 Sep 2003 02:11:24 -0000 1.149
+++ ChangeLog 22 Sep 2003 21:39:29 -0000
@@ -1,3 +1,12 @@
+2003-09-19 Hoda Amer
+ Solution to bug#43162 : Code Assist not showing the right return value:
+ Saved a function return value string in the BasicSearchMatch object.
+ Created a new package org.eclipse.cdt.internal.core.parser.util and
+ added ASTUtil class with static methods to help convert an ASTFunction
+ return type from IASTAbstractDeclaration to String. Note that this was
+ previously implemented in the CModelBuilder. I just moved it to a common
+ library for others (BasicSearchMatch) to use.
+
2003-09-16 Alain Magloire
Putting the draft work to do a special binary parser
Index: model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.17
diff -u -r1.17 CModelBuilder.java
--- model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 15 Sep 2003 22:50:25 -0000 1.17
+++ model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 22 Sep 2003 21:39:29 -0000
@@ -11,10 +11,8 @@
package org.eclipse.cdt.internal.core.model;
import java.io.StringReader;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.model.CoreModel;
@@ -23,19 +21,17 @@
import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IQuickParseCallback;
-import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
-import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTField;
@@ -45,33 +41,30 @@
import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
-import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
-import org.eclipse.cdt.internal.core.parser.ast.ASTArrayModifier;
+import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
import org.eclipse.core.resources.IProject;
public class CModelBuilder {
- protected org.eclipse.cdt.internal.core.model.TranslationUnit translationUnit;
- protected Map newElements;
- protected IQuickParseCallback quickParseCallback;
- protected IASTCompilationUnit compilationUnit;
+ private org.eclipse.cdt.internal.core.model.TranslationUnit translationUnit;
+ private Map newElements;
+ private IQuickParseCallback quickParseCallback;
+ private IASTCompilationUnit compilationUnit;
public CModelBuilder(org.eclipse.cdt.internal.core.model.TranslationUnit tu) {
this.translationUnit = tu ;
this.newElements = new HashMap();
}
- protected IASTCompilationUnit parse( String code, boolean hasCppNature, boolean quick, boolean throwExceptionOnError ) throws ParserException
+ private IASTCompilationUnit parse( String code, boolean hasCppNature, boolean quick, boolean throwExceptionOnError ) throws ParserException
{
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
quickParseCallback = ParserFactory.createQuickParseCallback();
@@ -86,7 +79,7 @@
return quickParseCallback.getCompilationUnit();
}
- protected IASTCompilationUnit parse( String code, boolean hasCppNature )throws ParserException
+ private IASTCompilationUnit parse( String code, boolean hasCppNature )throws ParserException
{
return parse( code, hasCppNature, true, true );
}
@@ -135,7 +128,7 @@
}
- protected void generateModelElements(){
+ private void generateModelElements(){
Iterator i = quickParseCallback.iterateOffsetableElements();
while (i.hasNext()){
IASTOffsetableElement offsetable = (IASTOffsetableElement)i.next();
@@ -153,7 +146,7 @@
}
}
- protected void generateModelElements (Parent parent, IASTDeclaration declaration) throws ASTNotImplementedException
+ private void generateModelElements (Parent parent, IASTDeclaration declaration) throws ASTNotImplementedException
{
if(declaration instanceof IASTNamespaceDefinition ) {
generateModelElements(parent, (IASTNamespaceDefinition) declaration);
@@ -174,7 +167,7 @@
createSimpleElement(parent, declaration, false);
}
- protected void generateModelElements (Parent parent, IASTNamespaceDefinition declaration) throws ASTNotImplementedException{
+ private void generateModelElements (Parent parent, IASTNamespaceDefinition declaration) throws ASTNotImplementedException{
// IASTNamespaceDefinition
IParent namespace = createNamespace(parent, declaration);
Iterator nsDecls = declaration.getDeclarations();
@@ -184,13 +177,13 @@
}
}
- protected void generateModelElements (Parent parent, IASTAbstractTypeSpecifierDeclaration abstractDeclaration) throws ASTNotImplementedException
+ private void generateModelElements (Parent parent, IASTAbstractTypeSpecifierDeclaration abstractDeclaration) throws ASTNotImplementedException
{
// IASTAbstractTypeSpecifierDeclaration
CElement element = createAbstractElement(parent, abstractDeclaration, false);
}
- protected void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws ASTNotImplementedException
+ private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws ASTNotImplementedException
{
// Template Declaration
IASTDeclaration declaration = (IASTDeclaration)templateDeclaration.getOwnedDeclaration();
@@ -200,7 +193,7 @@
// set the element position
element.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
// set the template parameters
- String[] parameterTypes = getTemplateParameters(templateDeclaration);
+ String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
ITemplate classTemplate = (ITemplate) element;
classTemplate.setTemplateParameterTypes(parameterTypes);
}
@@ -212,12 +205,12 @@
// set the element position
element.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
// set the template parameters
- String[] parameterTypes = getTemplateParameters(templateDeclaration);
+ String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
template.setTemplateParameterTypes(parameterTypes);
}
}
- protected void generateModelElements (Parent parent, IASTTypedefDeclaration declaration) throws ASTNotImplementedException
+ private void generateModelElements (Parent parent, IASTTypedefDeclaration declaration) throws ASTNotImplementedException
{
TypeDef typeDef = createTypeDef(parent, declaration);
IASTAbstractDeclaration abstractDeclaration = declaration.getAbstractDeclarator();
@@ -266,7 +259,7 @@
return element;
}
- protected Include createInclusion(Parent parent, IASTInclusion inclusion){
+ private Include createInclusion(Parent parent, IASTInclusion inclusion){
// create element
Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
element.setFullPathName(inclusion.getFullFileName());
@@ -280,7 +273,7 @@
return element;
}
- protected Macro createMacro(Parent parent, IASTMacro macro){
+ private Macro createMacro(Parent parent, IASTMacro macro){
// create element
org.eclipse.cdt.internal.core.model.Macro element = new Macro(parent, macro.getName());
// add to parent
@@ -293,7 +286,7 @@
return element;
}
- protected Namespace createNamespace(Parent parent, IASTNamespaceDefinition nsDef){
+ private Namespace createNamespace(Parent parent, IASTNamespaceDefinition nsDef){
// create element
String type = "namespace";
String nsName = (nsDef.getName() == null )
@@ -310,7 +303,7 @@
return element;
}
- protected Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier){
+ private Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier){
// create element
String type = "enum";
String enumName = (enumSpecifier.getName() == null )
@@ -334,7 +327,7 @@
return element;
}
- protected Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef){
+ private Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef){
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
// add to parent
enum.addChild(element);
@@ -346,7 +339,7 @@
return element;
}
- protected Structure createClass(Parent parent, IASTClassSpecifier classSpecifier, boolean isTemplate){
+ private Structure createClass(Parent parent, IASTClassSpecifier classSpecifier, boolean isTemplate){
// create element
String className = "";
String type = "";
@@ -413,13 +406,13 @@
return element;
}
- protected TypeDef createTypeDef(Parent parent, IASTTypedefDeclaration typeDefDeclaration){
+ private TypeDef createTypeDef(Parent parent, IASTTypedefDeclaration typeDefDeclaration){
// create the element
String name = typeDefDeclaration.getName();
TypeDef element = new TypeDef( parent, name );
- StringBuffer typeName = new StringBuffer(getType(typeDefDeclaration.getAbstractDeclarator()));
+ StringBuffer typeName = new StringBuffer(ASTUtil.getType(typeDefDeclaration.getAbstractDeclarator()));
element.setTypeName(typeName.toString());
// add to parent
@@ -433,7 +426,7 @@
return element;
}
- protected VariableDeclaration createVariableSpecification(Parent parent, IASTVariable varDeclaration, boolean isTemplate)throws ASTNotImplementedException
+ private VariableDeclaration createVariableSpecification(Parent parent, IASTVariable varDeclaration, boolean isTemplate)throws ASTNotImplementedException
{
IASTAbstractDeclaration abstractDeclaration = varDeclaration.getAbstractDeclaration();
CElement abstractElement = createAbstractElement (parent, abstractDeclaration , isTemplate);
@@ -470,7 +463,7 @@
}
}
}
- element.setTypeName ( getType(varDeclaration.getAbstractDeclaration()) );
+ element.setTypeName ( ASTUtil.getType(varDeclaration.getAbstractDeclaration()) );
element.setConst(varDeclaration.getAbstractDeclaration().isConst());
element.setVolatile(varDeclaration.getAbstractDeclaration().isVolatile());
element.setStatic(varDeclaration.isStatic());
@@ -488,7 +481,7 @@
return element;
}
- protected FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate)
+ private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate)
{
String name = functionDeclaration.getName();
if (name == null) {
@@ -497,7 +490,7 @@
}
// get parameters types
- String[] parameterTypes = getFunctionParameterTypes(functionDeclaration);
+ String[] parameterTypes = ASTUtil.getFunctionParameterTypes(functionDeclaration);
FunctionDeclaration element = null;
@@ -566,7 +559,7 @@
}
}
element.setParameterTypes(parameterTypes);
- element.setReturnType( getType(functionDeclaration.getReturnType()) );
+ element.setReturnType( ASTUtil.getType(functionDeclaration.getReturnType()) );
element.setStatic(functionDeclaration.isStatic());
// add to parent
@@ -583,188 +576,4 @@
return element;
}
- private String[] getTemplateParameters(Iterator templateParams){
- List paramList = new ArrayList();
- while (templateParams.hasNext()){
- StringBuffer paramType = new StringBuffer();
- IASTTemplateParameter parameter = (IASTTemplateParameter)templateParams.next();
- if((parameter.getIdentifier() != null) && (parameter.getIdentifier().length() != 0))
- {
- paramList.add(parameter.getIdentifier().toString());
- }
- else
- {
- IASTTemplateParameter.ParamKind kind = parameter.getTemplateParameterKind();
- if(kind == IASTTemplateParameter.ParamKind.CLASS){
- paramType.append("class");
- }
- if(kind == IASTTemplateParameter.ParamKind.TYPENAME){
- paramType.append("typename");
- }
- if(kind == IASTTemplateParameter.ParamKind.TEMPLATE_LIST){
- paramType.append("template<");
- String[] subParams = getTemplateParameters(parameter.getTemplateParameters());
- int p = 0;
- if ( subParams.length > 0)
- paramType.append(subParams[p++]);
- while( p < subParams.length){
- paramType.append(", ");
- paramType.append(subParams[p++]);
- }
- paramType.append(">");
- }
- if(kind == IASTTemplateParameter.ParamKind.PARAMETER){
- paramType.append(getType(parameter.getParameterDeclaration()));
- }
- paramList.add(paramType.toString());
- } // end else
- }// end while
- String[] parameterTypes = new String[paramList.size()];
- for(int j=0; j<paramList.size(); ++j){
- parameterTypes[j] = (String) paramList.get(j);
- }
- return parameterTypes;
-
- }
- private String[] getTemplateParameters(IASTTemplateDeclaration templateDeclaration){
- // add the parameters
- Iterator i = templateDeclaration.getTemplateParameters();
- return getTemplateParameters(i);
- }
-
- private String getType(IASTAbstractDeclaration declaration)
- {
- StringBuffer type = new StringBuffer();
-
- // get type from declaration
- type.append(getDeclarationType(declaration));
- type.append(getPointerOperation(declaration));
- type.append(getArrayQualifiers(declaration));
-
- type.append(getPointerToFunctionType(declaration));
- return type.toString();
- }
-
- private String getPointerToFunctionType(IASTAbstractDeclaration declaration){
- StringBuffer type = new StringBuffer();
- ASTPointerOperator po = declaration.getPointerToFunctionOperator();
- if(po != null){
- type.append("(");
- type.append(getPointerOperator(po));
- type.append(")");
- String[] parameters =getParameterTypes(declaration.getParameters());
- type.append(getParametersString(parameters));
- }
- return type.toString();
- }
- private String getDeclarationType(IASTAbstractDeclaration declaration){
- StringBuffer type = new StringBuffer();
-
- if(declaration.isConst())
- type.append("const ");
- IASTTypeSpecifier typeSpecifier = declaration.getTypeSpecifier();
- if(typeSpecifier instanceof IASTElaboratedTypeSpecifier){
- IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) typeSpecifier;
- type.append(getElaboratedTypeSignature(elab));
- }else if(typeSpecifier instanceof IASTSimpleTypeSpecifier){
- IASTSimpleTypeSpecifier simpleSpecifier = (IASTSimpleTypeSpecifier) typeSpecifier;
- type.append(simpleSpecifier.getTypename());
- }
- return type.toString();
- }
-
- private String getElaboratedTypeSignature(IASTElaboratedTypeSpecifier elab){
- StringBuffer type = new StringBuffer();
- ASTClassKind t = elab.getClassKind();
- if( t == ASTClassKind.CLASS){
- type.append("class");
- }
- else if( t == ASTClassKind.STRUCT){
- type.append("struct");
- }
- else if( t == ASTClassKind.UNION){
- type.append("union");
- }
- else if( t == ASTClassKind.STRUCT){
- type.append("enum");
- }
- type.append(" ");
- type.append(elab.getName().toString());
- return type.toString();
- }
-
- private String getPointerOperation(IASTAbstractDeclaration declaration){
- StringBuffer pointerString = new StringBuffer();
- Iterator i = declaration.getPointerOperators();
- while(i.hasNext()){
- ASTPointerOperator po = (ASTPointerOperator) i.next();
- pointerString.append(getPointerOperator(po));
- }
- return pointerString.toString();
- }
-
- private String getPointerOperator(ASTPointerOperator po){
- String pointerString ="";
- if(po == ASTPointerOperator.POINTER)
- pointerString = ("*");
-
- if(po == ASTPointerOperator.REFERENCE)
- pointerString =("&");
-
- if(po == ASTPointerOperator.CONST_POINTER)
- pointerString =("* const");
-
- if(po == ASTPointerOperator.VOLATILE_POINTER)
- pointerString =("* volatile");
-
- return pointerString;
- }
-
- private String getArrayQualifiers(IASTAbstractDeclaration declaration){
- StringBuffer arrayString = new StringBuffer();
- Iterator i = declaration.getArrayModifiers();
- while (i.hasNext()){
- ASTArrayModifier q = (ASTArrayModifier) i.next();
- arrayString.append("[]");
- }
- return arrayString.toString();
- }
-
- private String[] getFunctionParameterTypes(IASTFunction functionDeclaration)
- {
- Iterator parameters = functionDeclaration.getParameters();
- return getParameterTypes(parameters);
- }
-
- private String[] getParameterTypes(Iterator parameters){
- List paramList = new ArrayList();
- while (parameters.hasNext()){
- IASTParameterDeclaration param = (IASTParameterDeclaration)parameters.next();
- paramList.add(getType(param));
- }
- String[] parameterTypes = new String[paramList.size()];
- for(int i=0; i<paramList.size(); ++i){
- parameterTypes[i] = (String)paramList.get(i);
- }
- return parameterTypes;
- }
- private String getParametersString(String[] parameterTypes)
- {
- StringBuffer parameters = new StringBuffer("");
-
- if ((parameterTypes != null) && (parameterTypes.length > 0)) {
- parameters.append("(");
- int i = 0;
- parameters.append(parameterTypes[i++]);
- while (i < parameterTypes.length) {
- parameters.append(", ");
- parameters.append(parameterTypes[i++]);
- }
- parameters.append(")");
- } else {
- if (parameterTypes != null) parameters.append("()");
- }
-
- return parameters.toString();
- }
}
Index: parser/org/eclipse/cdt/internal/core/parser/util/ASTUtil.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/util/ASTUtil.java
diff -N parser/org/eclipse/cdt/internal/core/parser/util/ASTUtil.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/util/ASTUtil.java 22 Sep 2003 21:39:29 -0000
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2001 Rational Software Corp. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - initial implementation
+ ******************************************************************************/
+package org.eclipse.cdt.internal.core.parser.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.ASTClassKind;
+import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
+import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
+import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
+import org.eclipse.cdt.internal.core.parser.ast.ASTArrayModifier;
+
+/**
+ * This is a utility class to help convert AST elements to Strings.
+ */
+
+public class ASTUtil {
+ public static String[] getTemplateParameters(IASTTemplateDeclaration templateDeclaration){
+ // add the parameters
+ Iterator i = templateDeclaration.getTemplateParameters();
+ return getTemplateParameters(i);
+ }
+ public static String[] getTemplateParameters(Iterator templateParams){
+ List paramList = new ArrayList();
+ while (templateParams.hasNext()){
+ StringBuffer paramType = new StringBuffer();
+ IASTTemplateParameter parameter = (IASTTemplateParameter)templateParams.next();
+ if((parameter.getIdentifier() != null) && (parameter.getIdentifier().length() != 0))
+ {
+ paramList.add(parameter.getIdentifier().toString());
+ }
+ else
+ {
+ IASTTemplateParameter.ParamKind kind = parameter.getTemplateParameterKind();
+ if(kind == IASTTemplateParameter.ParamKind.CLASS){
+ paramType.append("class");
+ }
+ if(kind == IASTTemplateParameter.ParamKind.TYPENAME){
+ paramType.append("typename");
+ }
+ if(kind == IASTTemplateParameter.ParamKind.TEMPLATE_LIST){
+ paramType.append("template<");
+ String[] subParams = getTemplateParameters(parameter.getTemplateParameters());
+ int p = 0;
+ if ( subParams.length > 0)
+ paramType.append(subParams[p++]);
+ while( p < subParams.length){
+ paramType.append(", ");
+ paramType.append(subParams[p++]);
+ }
+ paramType.append(">");
+ }
+ if(kind == IASTTemplateParameter.ParamKind.PARAMETER){
+ paramType.append(getType(parameter.getParameterDeclaration()));
+ }
+ paramList.add(paramType.toString());
+ } // end else
+ }// end while
+ String[] parameterTypes = new String[paramList.size()];
+ for(int j=0; j<paramList.size(); ++j){
+ parameterTypes[j] = (String) paramList.get(j);
+ }
+ return parameterTypes;
+
+ }
+
+ public static String getType(IASTAbstractDeclaration declaration)
+ {
+ StringBuffer type = new StringBuffer();
+
+ // get type from declaration
+ type.append(getDeclarationType(declaration));
+ type.append(getPointerOperation(declaration));
+ type.append(getArrayQualifiers(declaration));
+
+ type.append(getPointerToFunctionType(declaration));
+ return type.toString();
+ }
+
+ public static String getPointerToFunctionType(IASTAbstractDeclaration declaration){
+ StringBuffer type = new StringBuffer();
+ ASTPointerOperator po = declaration.getPointerToFunctionOperator();
+ if(po != null){
+ type.append("(");
+ type.append(getPointerOperator(po));
+ type.append(")");
+ String[] parameters =getParameterTypes(declaration.getParameters());
+ type.append(getParametersString(parameters));
+ }
+ return type.toString();
+ }
+ public static String getDeclarationType(IASTAbstractDeclaration declaration){
+ StringBuffer type = new StringBuffer();
+
+ if(declaration.isConst())
+ type.append("const ");
+ IASTTypeSpecifier typeSpecifier = declaration.getTypeSpecifier();
+ if(typeSpecifier instanceof IASTElaboratedTypeSpecifier){
+ IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) typeSpecifier;
+ type.append(getElaboratedTypeSignature(elab));
+ }else if(typeSpecifier instanceof IASTSimpleTypeSpecifier){
+ IASTSimpleTypeSpecifier simpleSpecifier = (IASTSimpleTypeSpecifier) typeSpecifier;
+ type.append(simpleSpecifier.getTypename());
+ }
+ return type.toString();
+ }
+
+ public static String getElaboratedTypeSignature(IASTElaboratedTypeSpecifier elab){
+ StringBuffer type = new StringBuffer();
+ ASTClassKind t = elab.getClassKind();
+ if( t == ASTClassKind.CLASS){
+ type.append("class");
+ }
+ else if( t == ASTClassKind.STRUCT){
+ type.append("struct");
+ }
+ else if( t == ASTClassKind.UNION){
+ type.append("union");
+ }
+ else if( t == ASTClassKind.STRUCT){
+ type.append("enum");
+ }
+ type.append(" ");
+ type.append(elab.getName().toString());
+ return type.toString();
+ }
+
+ public static String getPointerOperation(IASTAbstractDeclaration declaration){
+ StringBuffer pointerString = new StringBuffer();
+ Iterator i = declaration.getPointerOperators();
+ while(i.hasNext()){
+ ASTPointerOperator po = (ASTPointerOperator) i.next();
+ pointerString.append(getPointerOperator(po));
+ }
+ return pointerString.toString();
+ }
+
+ public static String getPointerOperator(ASTPointerOperator po){
+ String pointerString ="";
+ if(po == ASTPointerOperator.POINTER)
+ pointerString = ("*");
+
+ if(po == ASTPointerOperator.REFERENCE)
+ pointerString =("&");
+
+ if(po == ASTPointerOperator.CONST_POINTER)
+ pointerString =("* const");
+
+ if(po == ASTPointerOperator.VOLATILE_POINTER)
+ pointerString =("* volatile");
+
+ return pointerString;
+ }
+
+ public static String getArrayQualifiers(IASTAbstractDeclaration declaration){
+ StringBuffer arrayString = new StringBuffer();
+ Iterator i = declaration.getArrayModifiers();
+ while (i.hasNext()){
+ ASTArrayModifier q = (ASTArrayModifier) i.next();
+ arrayString.append("[]");
+ }
+ return arrayString.toString();
+ }
+
+ public static String[] getFunctionParameterTypes(IASTFunction functionDeclaration)
+ {
+ Iterator parameters = functionDeclaration.getParameters();
+ return getParameterTypes(parameters);
+ }
+
+ public static String[] getParameterTypes(Iterator parameters){
+ List paramList = new ArrayList();
+ while (parameters.hasNext()){
+ IASTParameterDeclaration param = (IASTParameterDeclaration)parameters.next();
+ paramList.add(getType(param));
+ }
+ String[] parameterTypes = new String[paramList.size()];
+ for(int i=0; i<paramList.size(); ++i){
+ parameterTypes[i] = (String)paramList.get(i);
+ }
+ return parameterTypes;
+ }
+ public static String getParametersString(String[] parameterTypes)
+ {
+ StringBuffer parameters = new StringBuffer("");
+
+ if ((parameterTypes != null) && (parameterTypes.length > 0)) {
+ parameters.append("(");
+ int i = 0;
+ parameters.append(parameterTypes[i++]);
+ while (i < parameterTypes.length) {
+ parameters.append(", ");
+ parameters.append(parameterTypes[i++]);
+ }
+ parameters.append(")");
+ } else {
+ if (parameterTypes != null) parameters.append("()");
+ }
+
+ return parameters.toString();
+ }
+
+}
Index: search/org/eclipse/cdt/core/search/BasicSearchMatch.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchMatch.java,v
retrieving revision 1.5
diff -u -r1.5 BasicSearchMatch.java
--- search/org/eclipse/cdt/core/search/BasicSearchMatch.java 15 Sep 2003 17:31:22 -0000 1.5
+++ search/org/eclipse/cdt/core/search/BasicSearchMatch.java 22 Sep 2003 21:39:29 -0000
@@ -30,6 +30,7 @@
public BasicSearchMatch(BasicSearchMatch basicMatch) {
name = basicMatch.name;
parentName = basicMatch.parentName;
+ returnType = basicMatch.returnType;
resource = basicMatch.resource;
path = basicMatch.path;
startOffset = basicMatch.startOffset;
@@ -41,6 +42,7 @@
hashString += name;
hashString += ":" + parentName;
+ hashString += ":" + returnType;
hashString += ":" + getLocation().toString();
hashString += ":" + startOffset + ":" + endOffset;
hashString += ":" + type + ":" + visibility;
@@ -62,7 +64,9 @@
if( type != match.getElementType() || visibility != match.getVisibility() )
return false;
- if( !name.equals( match.getName() ) || !parentName.equals( match.getParentName() ) )
+ if( !name.equals( match.getName() )
+ || !parentName.equals( match.getParentName() )
+ || !returnType.equals( match.getReturnType() ) )
return false;
IPath thisPath = getLocation();
@@ -90,14 +94,15 @@
str1 += " " + getStartOffset()+ " ";
str2 += " " + match.getStartOffset()+ " ";
- str1 += getName() + " " + getParentName();
- str2 += match.getName() + " " + match.getParentName();
+ str1 += getName() + " " + getParentName()+ " " + getReturnType();
+ str2 += match.getName() + " " + match.getParentName()+ " " + getReturnType();
return str1.compareTo( str2 );
}
public String name = null;
public String parentName = null;
+ public String returnType;
public IResource resource = null;
public IPath path = null;
@@ -128,6 +133,10 @@
return parentName;
}
+ public String getReturnType() {
+ return returnType;
+ }
+
public IResource getResource() {
return resource;
}
@@ -205,6 +214,13 @@
*/
public void setParentName(String string) {
parentName = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setReturnType(String string) {
+ returnType = string;
}
/**
Index: search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java,v
retrieving revision 1.7
diff -u -r1.7 BasicSearchResultCollector.java
--- search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java 15 Sep 2003 17:31:22 -0000 1.7
+++ search/org/eclipse/cdt/core/search/BasicSearchResultCollector.java 22 Sep 2003 21:39:29 -0000
@@ -40,6 +40,7 @@
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
+import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -110,6 +111,7 @@
if( offsetable instanceof IASTFunction ){
result.name += getParameterString( (IASTFunction) offsetable );
+ result.returnType = ASTUtil.getType(((IASTFunction)offsetable).getReturnType());
}
setElementInfo( result, offsetable );
Index: model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java,v
retrieving revision 1.6
diff -u -r1.6 CompletionProposalsTest.java
--- model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java 22 Sep 2003 18:38:20 -0000 1.6
+++ model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java 22 Sep 2003 21:39:51 -0000
@@ -108,7 +108,7 @@
TranslationUnit tu = new TranslationUnit(fCProject, bodyFile);
String buffer = tu.getBuffer().getContents();
Document document = new Document(buffer);
- int pos = buffer.indexOf(" a ") + 2; //255;
+ int pos = buffer.indexOf(" a ") + 2;
int length = 0;
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
@@ -126,7 +126,7 @@
assertEquals(displayString, "aVariable");
break;
case 1:
- assertEquals(displayString, "aFunction() void");
+ assertEquals(displayString, "aFunction() bool");
break;
case 2:
assertEquals(displayString, "aClass");
@@ -135,10 +135,10 @@
assertEquals(displayString, "anotherClass");
break;
case 4:
- assertEquals(displayString, "aStruct");
+ assertEquals(displayString, "AStruct");
break;
case 5:
- assertEquals(displayString, "aMacro");
+ assertEquals(displayString, "AMacro");
break;
case 6:
assertEquals(displayString, "anEnumeration");
Index: resources/cfiles/CompletionProposalsTestStart.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp,v
retrieving revision 1.2
diff -u -r1.2 CompletionProposalsTestStart.cpp
--- resources/cfiles/CompletionProposalsTestStart.cpp 22 Sep 2003 18:38:20 -0000 1.2
+++ resources/cfiles/CompletionProposalsTestStart.cpp 22 Sep 2003 21:39:51 -0000
@@ -1,9 +1,9 @@
#include "CompletionProposalsTestStart.h"
-#define aMacro(x) x+1
+#define AMacro(x) x+1
int aVariable = 0;
-void aFunction();
+bool aFunction();
enum anEnumeration {
first,
@@ -11,8 +11,8 @@
third
};
-struct aStruct{
- int aStructField = 0;
+struct AStruct{
+ int aStructField;
};
void foo(){
Index: resources/cfiles/CompletionProposalsTestStart.h
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.h,v
retrieving revision 1.2
diff -u -r1.2 CompletionProposalsTestStart.h
--- resources/cfiles/CompletionProposalsTestStart.h 2 Sep 2003 17:17:01 -0000 1.2
+++ resources/cfiles/CompletionProposalsTestStart.h 22 Sep 2003 21:39:51 -0000
@@ -6,6 +6,6 @@
class anotherClass {
public:
- int anotherField = 0;
+ int anotherField;
void anotherMethod();
};