Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 140105 Details for
Bug 255142
[select] Codeselect should not omit cast
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug255142_001.txt (text/plain), 7.82 KB, created by
David Audel
on 2009-06-25 10:44:11 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2009-06-25 10:44:11 EDT
Size:
7.82 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java,v >retrieving revision 1.66 >diff -u -r1.66 ResolveTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 28 Apr 2009 17:46:10 -0000 1.66 >+++ src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 25 Jun 2009 14:45:08 -0000 >@@ -2909,4 +2909,31 @@ > true > ); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209639 >+public void test0123() throws Exception { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Resolve/src/test/Test.java", >+ "package test;\n" + >+ "public class Test {\n" + >+ " <T> T bar(T t) { return t; }\n" + >+ " void foo(boolean b, Runnable r) {\n" + >+ " Zork z = null;\n" + >+ " String s = (String) bar(z); // 5\n" + >+ " }\n" + >+ "}\n" + >+ "\n"); >+ >+ String str = this.workingCopies[0].getSource(); >+ int start = str.lastIndexOf("bar"); >+ int length = "bar".length(); >+ IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); >+ >+ assertElementsEqual( >+ "Unexpected elements", >+ "bar(T) {key=Ltest/Test;.bar<T:Ljava/lang/Object;>(TT;)TT;%<Ljava/lang/Object;>} [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", >+ elements, >+ true >+ ); >+} > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/parser/GenericsSelectionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsSelectionTest.java,v >retrieving revision 1.9 >diff -u -r1.9 GenericsSelectionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/GenericsSelectionTest.java 28 Apr 2009 17:17:31 -0000 1.9 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/GenericsSelectionTest.java 25 Jun 2009 14:45:09 -0000 >@@ -934,4 +934,51 @@ > expectedReplacedSource, > testName); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=255142 >+public void test0024() { >+ >+ String str = >+ "import java.util.List;\n" + >+ "public class X {\n" + >+ " <T> T bar(T t) { return t; }\n" + >+ " void foo(boolean b, Runnable r) {\n" + >+ " Zork z = null;\n" + >+ " String s = (String) bar(z); // 5\n" + >+ " }\n" + >+ "}\n" + >+ "\n"; >+ >+ String selection = "bar"; >+ >+ String expectedCompletionNodeToString = "<SelectOnMessageSend:bar(z)>"; >+ >+ String completionIdentifier = "bar"; >+ String expectedUnitDisplayString = >+ "import java.util.List;\n" + >+ "public class X {\n" + >+ " public X() {\n" + >+ " }\n" + >+ " <T>T bar(T t) {\n" + >+ " }\n" + >+ " void foo(boolean b, Runnable r) {\n" + >+ " Zork z;\n" + >+ " String s = (String) <SelectOnMessageSend:bar(z)>;\n" + >+ " }\n" + >+ "}\n"; >+ String expectedReplacedSource = "bar(z)"; >+ String testName = "<select method>"; >+ >+ int selectionStart = str.lastIndexOf(selection); >+ int selectionEnd = str.lastIndexOf(selection) + selection.length() - 1; >+ >+ this.checkMethodParse( >+ str.toCharArray(), >+ selectionStart, >+ selectionEnd, >+ expectedCompletionNodeToString, >+ expectedUnitDisplayString, >+ completionIdentifier, >+ expectedReplacedSource, >+ testName); >+} > } >Index: src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java,v >retrieving revision 1.23 >diff -u -r1.23 SelectionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java 28 Apr 2009 17:17:27 -0000 1.23 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java 25 Jun 2009 14:45:09 -0000 >@@ -794,7 +794,7 @@ > " public X() {\n" + > " }\n" + > " Object foo() {\n" + >- " return <SelectOnName:Object>;\n" + >+ " <SelectOnName:Object>;\n" + > " }\n" + > "}\n"; > >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java,v >retrieving revision 1.89 >diff -u -r1.89 SelectionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java 7 May 2009 08:49:43 -0000 1.89 >+++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java 25 Jun 2009 14:45:11 -0000 >@@ -41,6 +41,7 @@ > // KIND : all values known by SelectionParser are between 1025 and 1549 > protected static final int K_BETWEEN_CASE_AND_COLON = SELECTION_PARSER + 1; // whether we are inside a block > protected static final int K_INSIDE_RETURN_STATEMENT = SELECTION_PARSER + 2; // whether we are between the keyword 'return' and the end of a return statement >+ protected static final int K_CAST_STATEMENT = SELECTION_PARSER + 3; // whether we are between ')' and the end of a cast statement > > > public ASTNode assistNodeParent; // the parent node of assist node >@@ -129,6 +130,18 @@ > this.assistNodeParent = parentNode; > } > break nextElement; >+ case K_CAST_STATEMENT : >+ Expression castType; >+ if(this.expressionPtr > 0 >+ && ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference >+ || castType instanceof NameReference)) { >+ CastExpression cast = new CastExpression(expression, getTypeReference(castType)); >+ cast.sourceStart = castType.sourceStart; >+ cast.sourceEnd= expression.sourceEnd; >+ parentNode = cast; >+ this.assistNodeParent = parentNode; >+ } >+ break nextElement; > } > } > if(parentNode != null) { >@@ -249,6 +262,26 @@ > this.isOrphanCompletionNode = true; > } > } >+protected void consumeCastExpressionLL1() { >+ popElement(K_CAST_STATEMENT); >+ super.consumeCastExpressionLL1(); >+} >+protected void consumeCastExpressionWithGenericsArray() { >+ popElement(K_CAST_STATEMENT); >+ super.consumeCastExpressionWithGenericsArray(); >+} >+protected void consumeCastExpressionWithNameArray() { >+ popElement(K_CAST_STATEMENT); >+ super.consumeCastExpressionWithNameArray(); >+} >+protected void consumeCastExpressionWithPrimitiveType() { >+ popElement(K_CAST_STATEMENT); >+ super.consumeCastExpressionWithPrimitiveType(); >+} >+protected void consumeCastExpressionWithQualifiedGenericsArray() { >+ popElement(K_CAST_STATEMENT); >+ super.consumeCastExpressionWithQualifiedGenericsArray(); >+} > protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() { > // ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt > // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt >@@ -562,6 +595,18 @@ > this.listLength++; > } > } >+protected void consumeInsideCastExpression() { >+ super.consumeInsideCastExpression(); >+ pushOnElementStack(K_CAST_STATEMENT); >+} >+protected void consumeInsideCastExpressionLL1() { >+ super.consumeInsideCastExpressionLL1(); >+ pushOnElementStack(K_CAST_STATEMENT); >+} >+protected void consumeInsideCastExpressionWithQualifiedGenerics() { >+ super.consumeInsideCastExpressionWithQualifiedGenerics(); >+ pushOnElementStack(K_CAST_STATEMENT); >+} > protected void consumeInstanceOfExpression() { > if (indexOfAssistIdentifier() < 0) { > super.consumeInstanceOfExpression();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255142
: 140105