[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] FIXED: 94135, 95119, 95202, 95219, 95224, 95225, 95229, 95372
|
FIXED 94135- All Declarations does not
include the namespace scope in the search pattern
FIXED 95119- AST parser fails to parse
character constant containing double quotes
FIXED 95202- [NPE] on Open Declarations
for C++ spec example
FIXED 95219- [Ctrl+Click] is enabled
on everything except for keywords
FIXED 95224- [Open Definition] of destructor
should have the same logic as constructors
FIXED 95225- [open definition] within
constructor in a throw statement fails
FIXED 95229- [open declaration] infinite
loop on keyword operator
FIXED 95372- DOMQuery#isLocal() should
not reference internal DOM packages
Devin Steffler
IBM's Eclipse CDT
Ottawa (Palladium), Ontario, Canada
Index: src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java,v
retrieving revision 1.2
diff -u -r1.2 CElementHyperlinkDetector.java
--- src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java 28 Apr 2005 02:25:50 -0000 1.2
+++ src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java 16 May 2005 20:13:20 -0000
@@ -66,14 +66,27 @@
private IRegion selectWord(IDocument document, int anchor) {
//TODO: Modify this to work with qualified name
+ // fix for 95219, return null if the mouse is pointing to a non-java identifier part
+ try {
+ if (!Character.isJavaIdentifierPart(document.getChar(anchor))) {
+ return null;
+ }
+ } catch (BadLocationException e) { return null; }
+
+ boolean isNumber=false;
try {
int offset= anchor;
char c;
+ char oldC='a'; // assume this is the first character
while (offset >= 0) {
c= document.getChar(offset);
- if (!Character.isJavaIdentifierPart(c))
- break;
+ if (!Character.isJavaIdentifierPart(c)) {
+ if (Character.isDigit(oldC)) // if the first character is a digit, then assume the word is a number, i.e. 1e13, 0xFF, 123
+ isNumber=true;
+ break;
+ }
+ oldC = c;
--offset;
}
@@ -94,13 +107,19 @@
if (start == end)
return new Region(start, 0);
- String selWord = null;
+ // don't select numbers only i.e. 0x1, 1e13, 1234
+ if (isNumber) return null;
+
+ String selWord = null;
String slas = document.get(start,1);
+
+ // TODO more need to be added to this list as they are discovered
if (slas.equals("\n") || //$NON-NLS-1$
slas.equals("\t") || //$NON-NLS-1$
slas.equals(" ") || //$NON-NLS-1$
slas.equals(">") || //$NON-NLS-1$
- slas.equals(".")) //$NON-NLS-1$
+ slas.equals(".") || //$NON-NLS-1$
+ slas.equals("(")) //$NON-NLS-1$
{
selWord =document.get(start+1, end - start - 1);
Index: src/org/eclipse/cdt/internal/ui/search/DOMQuery.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java,v
retrieving revision 1.3
diff -u -r1.3 DOMQuery.java
--- src/org/eclipse/cdt/internal/ui/search/DOMQuery.java 16 May 2005 18:24:29 -0000 1.3
+++ src/org/eclipse/cdt/internal/ui/search/DOMQuery.java 16 May 2005 20:13:20 -0000
@@ -148,9 +148,9 @@
private boolean isLocal() {
IBinding binding = searchName.resolveBinding();
- if (searchName instanceof CPPASTName) {
+ if (binding instanceof ICPPBinding) {
try {
- if (binding instanceof ICPPBinding && !((ICPPBinding)binding).isGloballyQualified())
+ if (!((ICPPBinding)binding).isGloballyQualified())
return true;
} catch (DOMException e) {}
} else {
Index: src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java,v
retrieving revision 1.17
diff -u -r1.17 FindAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java 3 May 2005 18:48:24 -0000 1.17
+++ src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java 16 May 2005 20:13:20 -0000
@@ -20,17 +20,10 @@
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IASTServiceProvider;
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IFunction;
-import org.eclipse.cdt.core.dom.ast.IFunctionType;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ParseError;
@@ -40,8 +33,6 @@
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
@@ -84,42 +75,7 @@
* @return
*/
public static CSearchQuery createDOMSearchQueryForName( IASTName name, LimitTo limitTo, ICSearchScope scope, ICSearchResultCollector collector ){
- StringBuffer buffer = new StringBuffer();
- buffer.append("::"); //$NON-NLS-1$
- if (name instanceof CPPASTName && name.getParent() instanceof CPPASTQualifiedName) {
- IASTName[] names = ((CPPASTQualifiedName)name.getParent()).getNames();
- for(int i=0; i<names.length; i++) {
- if (i != 0) buffer.append("::"); //$NON-NLS-1$
- buffer.append(names[i].toString());
- }
- } else {
- buffer.append(name.toString());
- }
-
- if( name.resolveBinding() instanceof IFunction ){
- try {
- IBinding binding = name.resolveBinding();
- IFunctionType type = ((IFunction)binding).getType();
-
- buffer.append("("); //$NON-NLS-1$
- if (binding instanceof ICExternalBinding) {
- buffer.append("..."); //$NON-NLS-1$
- } else {
- IType[] parms = type.getParameterTypes();
- for( int i = 0; i < parms.length; i++ ){
- if( i != 0 )
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(ASTTypeUtil.getType(parms[i]));
- }
- }
- buffer.append(")"); //$NON-NLS-1$
- } catch (DOMException e) {
- buffer = new StringBuffer();
- buffer.append(name.toString());
- }
- }
-
- return new DOMQuery(buffer.toString(), name, limitTo, scope, collector);
+ return new DOMQuery(DOMSearchUtil.getSearchPattern(name), name, limitTo, scope, collector);
}
/**
Index: src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java,v
retrieving revision 1.11
diff -u -r1.11 SelectionParseAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java 16 May 2005 18:24:29 -0000 1.11
+++ src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java 16 May 2005 20:13:20 -0000
@@ -429,6 +429,9 @@
case '(': {
if (possibleEnd > 0)
actualEnd = possibleEnd;
+
+ index++;
+
break;
}
case ']':
Index: parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java,v
retrieving revision 1.71
diff -u -r1.71 AST2Tests.java
--- parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java 13 May 2005 17:52:29 -0000 1.71
+++ parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java 16 May 2005 20:13:07 -0000
@@ -36,6 +36,7 @@
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
@@ -245,7 +246,7 @@
IASTName name_struct = type.getName();
assertTrue( name_struct.isDeclaration() );
assertFalse( name_struct.isReference() );
- assertNull("", name_struct.toString()); //$NON-NLS-1$
+ assertEquals("", name_struct.toString()); //$NON-NLS-1$
// member - x
IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type
.getMembers()[0];
@@ -1376,7 +1377,7 @@
assertEquals(d.getDeclarators().length, 1);
IASTStandardFunctionDeclarator f = (IASTStandardFunctionDeclarator) d
.getDeclarators()[0];
- assertNull(f.getName().toString());
+ assertEquals(f.getName().toString(), "");
assertNotNull(f.getNestedDeclarator());
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
assertTrue(f.getPointerOperators().length == 0);
@@ -1393,7 +1394,7 @@
d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(d.getDeclarators().length, 1);
f = (IASTStandardFunctionDeclarator) d.getDeclarators()[0];
- assertNull(f.getName().toString());
+ assertEquals(f.getName().toString(), "");
assertNotNull(f.getNestedDeclarator());
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
}
@@ -3126,4 +3127,36 @@
parse( buffer.toString(), ParserLanguage.C );
}
+
+
+ public void testBug95119() throws Exception {
+ StringBuffer buff = new StringBuffer();
+ buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
+ buff.append("void main() {\n"); //$NON-NLS-1$
+ buff.append("MACRO(\'\"\');\n"); //$NON-NLS-1$
+ buff.append("}\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
+ IASTDeclaration[] declarations = tu.getDeclarations();
+ assertEquals( declarations.length, 1 );
+ assertNotNull( declarations[0] );
+ assertTrue( declarations[0] instanceof IASTFunctionDefinition );
+ assertEquals( ((IASTFunctionDefinition)declarations[0]).getDeclarator().getName().toString(), "main");
+ assertTrue( ((IASTCompoundStatement)((IASTFunctionDefinition)declarations[0]).getBody()).getStatements()[0] instanceof IASTNullStatement );
+
+ buff = new StringBuffer();
+ buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
+ buff.append("void main() {\n"); //$NON-NLS-1$
+ buff.append("MACRO(\'X\');\n"); //$NON-NLS-1$
+ buff.append("}\n"); //$NON-NLS-1$
+
+ tu = parse(buff.toString(), ParserLanguage.C);
+ declarations = tu.getDeclarations();
+ assertEquals( declarations.length, 1 );
+ assertNotNull( declarations[0] );
+ assertTrue( declarations[0] instanceof IASTFunctionDefinition );
+ assertEquals( ((IASTFunctionDefinition)declarations[0]).getDeclarator().getName().toString(), "main");
+ assertTrue( ((IASTCompoundStatement)((IASTFunctionDefinition)declarations[0]).getBody()).getStatements()[0] instanceof IASTNullStatement );
+
+ }
}
\ No newline at end of file
Index: parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java,v
retrieving revision 1.3
diff -u -r1.3 DOMSelectionParseTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java 29 Apr 2005 00:56:08 -0000 1.3
+++ parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java 16 May 2005 20:13:08 -0000
@@ -24,7 +24,6 @@
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
Index: parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java,v
retrieving revision 1.5
diff -u -r1.5 ICPPMethod.java
--- parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java 15 Apr 2005 21:16:44 -0000 1.5
+++ parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java 16 May 2005 20:12:49 -0000
@@ -24,4 +24,11 @@
* @throws DOMException
*/
public boolean isVirtual() throws DOMException;
+
+ /**
+ * is this a destructor
+ *
+ * returns true if its name starts with '~'
+ */
+ public boolean isDestructor() throws DOMException;
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java,v
retrieving revision 1.43
diff -u -r1.43 AbstractGNUSourceCodeParser.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 6 May 2005 15:02:54 -0000 1.43
+++ parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 16 May 2005 20:12:50 -0000
@@ -1528,7 +1528,7 @@
final IASTDeclarator[] declarators = ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclarators();
if( declarators.length == 0 ||
( declarators.length == 1 &&
- ( declarators[0].getName().toString() == null && declarators[0].getNestedDeclarator() == null ) ) )
+ ( declarators[0].getName().toCharArray().length == 0 && declarators[0].getNestedDeclarator() == null ) ) )
{
backup(mark);
while (true) {
Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java,v
retrieving revision 1.8
diff -u -r1.8 CASTName.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java 2 May 2005 20:15:51 -0000 1.8
+++ parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java 16 May 2005 20:12:50 -0000
@@ -23,6 +23,7 @@
private final char[] name;
private static final char[] EMPTY_CHAR_ARRAY = {};
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding = null;
@@ -71,7 +72,7 @@
*/
public String toString() {
if (name == EMPTY_CHAR_ARRAY)
- return null;
+ return EMPTY_STRING;
return new String(name);
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java,v
retrieving revision 1.48
diff -u -r1.48 GNUCSourceParser.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 6 May 2005 15:02:54 -0000 1.48
+++ parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 16 May 2005 20:12:51 -0000
@@ -1209,7 +1209,7 @@
backup(mark);
throwBacktrack(bt);
}
- if (declarator == null || declarator.getName().toString() != null) //$NON-NLS-1$
+ if (declarator == null || declarator.getName().toCharArray().length > 0) //$NON-NLS-1$
{
backup(mark);
throwBacktrack(startingOffset, figureEndOffset(declSpecifier,
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java,v
retrieving revision 1.7
diff -u -r1.7 CPPASTName.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java 2 May 2005 20:15:51 -0000 1.7
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java 16 May 2005 20:12:51 -0000
@@ -24,6 +24,7 @@
private char[] name;
private static final char[] EMPTY_CHAR_ARRAY = {};
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding = null;
@@ -72,7 +73,7 @@
*/
public String toString() {
if (name == EMPTY_CHAR_ARRAY)
- return null;
+ return EMPTY_STRING;
return new String(name);
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java,v
retrieving revision 1.14
diff -u -r1.14 CPPMethod.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java 11 May 2005 21:29:58 -0000 1.14
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java 16 May 2005 20:12:51 -0000
@@ -47,6 +47,17 @@
public boolean isVirtual() throws DOMException {
return ((ICPPMethod)getBinding()).isVirtual();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
}
public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod {
@@ -67,6 +78,17 @@
public boolean isVirtual() throws DOMException {
throw new DOMException( this );
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
}
public CPPMethod( ICPPASTFunctionDeclarator declarator ){
@@ -224,4 +246,15 @@
public boolean isMutable() {
return hasStorageClass( this, ICPPASTDeclSpecifier.sc_mutable );
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java,v
retrieving revision 1.4
diff -u -r1.4 CPPMethodInstance.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java 2 May 2005 18:04:24 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java 16 May 2005 20:12:51 -0000
@@ -50,4 +50,15 @@
return ((ICPPMethod)getTemplateDefinition()).isVirtual();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
+
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java,v
retrieving revision 1.1
diff -u -r1.1 CPPMethodSpecialization.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java 2 May 2005 18:04:24 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java 16 May 2005 20:12:51 -0000
@@ -71,4 +71,15 @@
return 0;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
+
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java,v
retrieving revision 1.2
diff -u -r1.2 CPPMethodTemplate.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java 15 Apr 2005 21:16:44 -0000 1.2
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java 16 May 2005 20:12:51 -0000
@@ -133,4 +133,15 @@
return super.isInline();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
+
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java,v
retrieving revision 1.1
diff -u -r1.1 CPPMethodTemplateSpecialization.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java 2 May 2005 18:04:24 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java 16 May 2005 20:12:51 -0000
@@ -53,4 +53,15 @@
return 0;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
+ */
+ public boolean isDestructor() throws DOMException {
+ char[] name = getNameCharArray();
+ if (name.length > 1 && name[0] == '~')
+ return true;
+
+ return false;
+ }
+
}
Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java,v
retrieving revision 1.75
diff -u -r1.75 GNUCPPSourceParser.java
--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 6 May 2005 19:44:05 -0000 1.75
+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 16 May 2005 20:12:53 -0000
@@ -729,8 +729,7 @@
int o = throwExpression != null ? calculateEndOffset(throwExpression)
: throwToken.getEndOffset();
return buildUnaryExpression(ICPPASTUnaryExpression.op_throw,
- throwExpression, throwToken.getOffset(), o
- - throwToken.getOffset());
+ throwExpression, throwToken.getOffset(), o); // fix for 95225
}
/**
@@ -943,7 +942,7 @@
- startingOffset);
}
if (declarator != null) {
- if (declarator.getName().toString() != null) {
+ if (declarator.getName().toCharArray().length > 0) {
backup(mark);
throwBacktrack(startingOffset, figureEndOffset(declSpecifier,
declarator)
Index: parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java,v
retrieving revision 1.36
diff -u -r1.36 BaseScanner.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java 13 May 2005 19:39:24 -0000 1.36
+++ parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java 16 May 2005 20:12:55 -0000
@@ -3732,6 +3732,25 @@
return argEnd;
}
break;
+ // fix for 95119
+ case '\'':
+ boolean escapedChar = false;
+ loop: while (++bufferPos[bufferStackPos] < bufferLimit[bufferStackPos]) {
+ switch (buffer[bufferPos[bufferStackPos]]) {
+ case '\\':
+ escapedChar = !escapedChar;
+ continue;
+ case '\'':
+ if (escapedChar) {
+ escapedChar = false;
+ continue;
+ }
+ break loop;
+ default:
+ escapedChar = false;
+ }
+ }
+ break;
case '"':
boolean escaped = false;
loop: while (++bufferPos[bufferStackPos] < bufferLimit[bufferStackPos]) {
@@ -3991,7 +4010,7 @@
argend = skipOverMacroArg();
char[] arg = EMPTY_CHAR_ARRAY;
- int arglen = argend - argstart + 1;
+ int arglen = argend - argstart + 1; // TODO Devin argend shouldn't be 65 it should be 55 for 95119
if (arglen > 0) {
arg = new char[arglen];
System.arraycopy(buffer, argstart, arg, 0, arglen);
Index: search/org/eclipse/cdt/core/search/DOMSearchUtil.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java,v
retrieving revision 1.7
diff -u -r1.7 DOMSearchUtil.java
--- search/org/eclipse/cdt/core/search/DOMSearchUtil.java 13 May 2005 15:52:29 -0000 1.7
+++ search/org/eclipse/cdt/core/search/DOMSearchUtil.java 16 May 2005 20:12:55 -0000
@@ -19,6 +19,7 @@
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IASTServiceProvider;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -29,11 +30,15 @@
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@@ -48,6 +53,8 @@
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -77,7 +84,7 @@
SearchEngine engine = new SearchEngine();
BasicSearchResultCollector results = new BasicSearchResultCollector();
- ICSearchPattern pattern = createPattern(searchName.resolveBinding(), limitTo, true);
+ ICSearchPattern pattern = createPattern(searchName, limitTo, true);
try {
engine.search(CCorePlugin.getWorkspace(), pattern, scope, results, false);
@@ -88,7 +95,8 @@
return results.getSearchResults();
}
- private static CSearchPattern createPattern( IBinding binding, LimitTo limitTo, boolean caseSensitive) {
+ private static CSearchPattern createPattern( IASTName searchName, LimitTo limitTo, boolean caseSensitive) {
+ IBinding binding = searchName.resolveBinding();
if (binding == null)
return null;
@@ -131,7 +139,7 @@
searchFor = ICSearchConstants.UNKNOWN_SEARCH_FOR;
}
- return CSearchPattern.createPattern(binding.getName(), searchFor, limitTo, ICSearchConstants.EXACT_MATCH, caseSensitive);
+ return CSearchPattern.createPattern(DOMSearchUtil.getSearchPattern(searchName), searchFor, limitTo, ICSearchConstants.EXACT_MATCH, caseSensitive);
}
private static SearchFor createSearchFor( IBinding binding ) {
@@ -350,9 +358,10 @@
names = getNames(tu, binding, limitTo);
if (names == null || names.length == 0) { // try alternate strategies
- // fix for 86829
try {
- if (binding instanceof ICPPConstructor && binding.getScope() instanceof ICPPClassScope) {
+ // fix for 86829, 95224
+ if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor()))
+ && binding.getScope() instanceof ICPPClassScope) {
binding = ((ICPPClassScope)binding.getScope()).getClassType();
names = getNames(tu, binding, limitTo);
}
@@ -425,6 +434,13 @@
public int size() { return nameList.size(); }
}
+ /**
+ * Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
+ *
+ * @param path
+ * @param project
+ * @return
+ */
public static ParserLanguage getLanguage( IPath path, IProject project )
{
ICFileType type = CCorePlugin.getDefault().getFileType(project, path.lastSegment());
@@ -438,4 +454,72 @@
return ParserLanguage.C;
return ParserLanguage.CPP;
}
+
+ /**
+ * Generates a search pattern String based on the IASTName passed as a parameter.
+ *
+ * Used to generate a string to present to the user as well as a string used by
+ * the SearchEngine to parse for qualified names and parameters.
+ *
+ * @param name
+ * @return
+ */
+ public static String getSearchPattern(IASTName name) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("::"); //$NON-NLS-1$
+
+ String[] namespaces = null;
+
+ IASTNode parent = name.getParent();
+ while(!(parent instanceof IASTTranslationUnit) && parent != null) {
+ if (parent instanceof ICPPASTNamespaceDefinition) {
+ namespaces = (String[])ArrayUtil.append(String.class, namespaces, ((ICPPASTNamespaceDefinition)parent).getName().toString());
+ }
+ parent = parent.getParent();
+ }
+
+ if (namespaces != null && namespaces.length > 0) {
+ for( int i=namespaces.length-1; i>=0; i-- ) {
+ if (namespaces[i] != null) {
+ buffer.append(namespaces[i]);
+ buffer.append("::"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (name instanceof CPPASTName && name.getParent() instanceof CPPASTQualifiedName) {
+ IASTName[] names = ((CPPASTQualifiedName)name.getParent()).getNames();
+ for(int i=0; i<names.length; i++) {
+ if (i != 0) buffer.append("::"); //$NON-NLS-1$
+ buffer.append(names[i].toString());
+ }
+ } else {
+ buffer.append(name.toString());
+ }
+
+ if( name.resolveBinding() instanceof IFunction ){
+ try {
+ IBinding binding = name.resolveBinding();
+ IFunctionType type = ((IFunction)binding).getType();
+
+ buffer.append("("); //$NON-NLS-1$
+ if (binding instanceof ICExternalBinding) {
+ buffer.append("..."); //$NON-NLS-1$
+ } else {
+ IType[] parms = type.getParameterTypes();
+ for( int i = 0; i < parms.length; i++ ){
+ if( i != 0 )
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(ASTTypeUtil.getType(parms[i]));
+ }
+ }
+ buffer.append(")"); //$NON-NLS-1$
+ } catch (DOMException e) {
+ buffer = new StringBuffer();
+ buffer.append(name.toString());
+ }
+ }
+
+ return buffer.toString();
+ }
}
Index: ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java,v
retrieving revision 1.2
diff -u -r1.2 CPPSelectionTestsNoIndexer.java
--- ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java 13 May 2005 19:52:38 -0000 1.2
+++ ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java 16 May 2005 20:13:30 -0000
@@ -359,6 +359,30 @@
assertEquals(((ASTNode)def).getLength(), 7);
}
+ public void testBug95224() throws Exception{
+ Writer writer = new StringWriter();
+ writer.write( "class A{\n"); //$NON-NLS-1$
+ writer.write( "A();\n"); //$NON-NLS-1$
+ writer.write( "A(const A&); // open definition on A finds class A\n"); //$NON-NLS-1$
+ writer.write( "~A(); // open definition on A finds nothing\n"); //$NON-NLS-1$
+ writer.write( "};\n"); //$NON-NLS-1$
+
+ String code = writer.toString();
+ IFile file = importFile("testBug95224.cpp", code); //$NON-NLS-1$
+
+ int offset = code.indexOf("A(); // open definition "); //$NON-NLS-1$
+ IASTNode def = testF2(file, offset);
+ IASTNode decl = testF3(file, offset);
+ assertTrue(def instanceof IASTName);
+ assertTrue(decl instanceof IASTName);
+ assertEquals(((IASTName)decl).toString(), "~A"); //$NON-NLS-1$
+ assertEquals(((ASTNode)decl).getOffset(), 65);
+ assertEquals(((ASTNode)decl).getLength(), 2);
+ assertEquals(((IASTName)def).toString(), "A"); //$NON-NLS-1$
+ assertEquals(((ASTNode)def).getOffset(), 6);
+ assertEquals(((ASTNode)def).getLength(), 1);
+ }
+
public void testBasicTemplateInstance() throws Exception{
Writer writer = new StringWriter();
writer.write( "namespace N{ \n"); //$NON-NLS-1$
@@ -901,6 +925,53 @@
assertEquals(((ASTNode)def).getLength(), 1);
}
+ public void testBug95225() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("class Overflow {\n"); //$NON-NLS-1$
+ buffer.append("public:\n"); //$NON-NLS-1$
+ buffer.append("Overflow(char,double,double);\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("void f(double x)\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("throw Overflow('+',x,3.45e107);\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("int foo() {\n"); //$NON-NLS-1$
+ buffer.append("try {\n"); //$NON-NLS-1$
+ buffer.append("f(1.2);\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("catch(Overflow& oo) {\n"); //$NON-NLS-1$
+ buffer.append(" // handle exceptions of type Overflow here\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ String code = buffer.toString();
+ IFile file = importFile("testBug95225.cpp", code); //$NON-NLS-1$
+
+ int offset = code.indexOf("rflow('+',x,3.45e107);"); //$NON-NLS-1$
+ IASTNode def = testF2(file, offset);
+ IASTNode decl = testF3(file, offset);
+ assertTrue(def instanceof IASTName);
+ assertTrue(decl instanceof IASTName);
+ assertEquals(((IASTName)decl).toString(), "Overflow"); //$NON-NLS-1$
+ assertEquals(((ASTNode)decl).getOffset(), 25);
+ assertEquals(((ASTNode)decl).getLength(), 8);
+ assertEquals(((IASTName)def).toString(), "Overflow"); //$NON-NLS-1$
+ assertEquals(((ASTNode)def).getOffset(), 6);
+ assertEquals(((ASTNode)def).getLength(), 8);
+
+ offset = code.indexOf("x,3.45e107);"); //$NON-NLS-1$
+ def = testF2(file, offset);
+ decl = testF3(file, offset);
+ assertTrue(def instanceof IASTName);
+ assertTrue(decl instanceof IASTName);
+ assertEquals(((IASTName)decl).toString(), "x"); //$NON-NLS-1$
+ assertEquals(((ASTNode)decl).getOffset(), 72);
+ assertEquals(((ASTNode)decl).getLength(), 1);
+ assertEquals(((IASTName)def).toString(), "x"); //$NON-NLS-1$
+ assertEquals(((ASTNode)def).getOffset(), 72);
+ assertEquals(((ASTNode)def).getLength(), 1);
+ }
+
public void testNoDefinitions() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("extern int a1; // declares a\n"); //$NON-NLS-1$
@@ -985,4 +1056,26 @@
assertEquals(((ASTNode)def).getLength(), 1);
}
+
+ public void testBug95229() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("struct A {\n"); //$NON-NLS-1$
+ buffer.append("operator short(); // F3 on operator causes an infinite loop\n"); //$NON-NLS-1$
+ buffer.append("} a;\n"); //$NON-NLS-1$
+ buffer.append("int f(int);\n"); //$NON-NLS-1$
+ buffer.append("int f(float);\n"); //$NON-NLS-1$
+ buffer.append("int i = f(a); // Calls f(int), because short -> int is\n"); //$NON-NLS-1$
+
+ String code = buffer.toString();
+ IFile file = importFile("testBug95229.cpp", code); //$NON-NLS-1$
+
+ int offset = code.indexOf("rator short(); // F3"); //$NON-NLS-1$
+ IASTNode def = testF2(file, offset);
+ IASTNode decl = testF3(file, offset);
+ assertNull(def);
+ assertTrue(decl instanceof IASTName);
+ assertEquals(((IASTName)decl).toString(), "operator short"); //$NON-NLS-1$
+ assertEquals(((ASTNode)decl).getOffset(), 11);
+ assertEquals(((ASTNode)decl).getLength(), 14);
+ }
}