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 158833 Details for
Bug 287939
[code assist] The instanceof and the auto cast feature should also work for an assignment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix + Tests v0.1
patch.txt (text/plain), 6.39 KB, created by
Srikanth Sankaran
on 2010-02-11 06:07:45 EST
(
hide
)
Description:
Fix + Tests v0.1
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-02-11 06:07:45 EST
Size:
6.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java,v >retrieving revision 1.209 >diff -u -r1.209 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 16 Oct 2009 11:29:40 -0000 1.209 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 11 Feb 2010 11:06:05 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -561,7 +561,8 @@ > return; > } > } >- if(expression == this.assistNode >+ if(expression == this.assistNode >+ || (expression instanceof Assignment && ((Assignment) expression).expression == this.assistNode) > || (expression instanceof AllocationExpression > && ((AllocationExpression)expression).type == this.assistNode)){ > buildMoreCompletionContext(expression); >@@ -575,6 +576,21 @@ > } > } > } >+ >+ if (this.astPtr > -1 && this.astStack[this.astPtr] instanceof LocalDeclaration) { >+ LocalDeclaration local = (LocalDeclaration) this.astStack[this.astPtr]; >+ if (local.initialization == this.assistNode) { >+ Statement enclosing = buildMoreCompletionEnclosingContext(local); >+ if (enclosing != local && enclosing instanceof IfStatement) { >+ if (this.currentElement instanceof RecoveredBlock) { >+ // RecoveredLocalVariable must be removed from its parent because the IfStatement will be added instead >+ RecoveredBlock recoveredBlock = (RecoveredBlock) this.currentElement; >+ recoveredBlock.statements[--recoveredBlock.statementCount] = null; >+ this.currentElement = this.currentElement.add(enclosing, 0); >+ } >+ } >+ } >+ } > } > public Object becomeSimpleParser() { > CompletionScanner completionScanner = (CompletionScanner)this.scanner; >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v >retrieving revision 1.210 >diff -u -r1.210 CompletionTests.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 7 Oct 2009 10:42:00 -0000 1.210 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 11 Feb 2010 11:06:21 -0000 >@@ -20600,4 +20600,76 @@ > requestor.getResults()); > } > >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 >+public void testCompletionAfterInstanceof25_01() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/CompletionAfterInstanceOf.java", >+ "package test;\n" + >+ "public class CompletionAfterInstanceOf {\n" + >+ " public int returnZero(){ return 0;}\n" + >+ " public Object a;\n" + >+ " void bar(){\n" + >+ " if (this.a instanceof CompletionAfterInstanceOf) {\n" + >+ " int j = 0;\n" + >+ " int k = 2;\n" + >+ " int i = this.a.r\n" + >+ " int p = 12;\n" + >+ " }\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); >+ requestor.allowAllRequiredProposals(); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "this.a.r"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED; >+ int start1 = str.lastIndexOf("r") + "r".length(); >+ int end1 = start1 + "r".length(); >+ int start2 = str.lastIndexOf("this.a.r"); >+ int end2 = start2 + "this.a.r".length(); >+ int start3 = str.lastIndexOf("this.a."); >+ int end3 = start3 + "this.a".length(); >+ assertResults( >+ "returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)this.a).returnZero(), Ltest.CompletionAfterInstanceOf;, I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}", >+ requestor.getResults()); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=287939 >+public void testCompletionAfterInstanceof25_02() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/CompletionAfterInstanceOf.java", >+ "package test;\n" + >+ "public class CompletionAfterInstanceOf {\n" + >+ " public int returnZero(){ return 0;}\n" + >+ " public Object a;\n" + >+ " void bar(){\n" + >+ " int i;\n" + >+ " if (this.a instanceof CompletionAfterInstanceOf) {\n" + >+ " i = this.a.r\n" + >+ " }\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true); >+ requestor.allowAllRequiredProposals(); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "this.a.r"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED; >+ int start1 = str.lastIndexOf("r") + "r".length(); >+ int end1 = start1 + "r".length(); >+ int start2 = str.lastIndexOf("this.a.r"); >+ int end2 = start2 + "this.a.r".length(); >+ int start3 = str.lastIndexOf("this.a."); >+ int end3 = start3 + "this.a".length(); >+ assertResults( >+ "returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)this.a).returnZero(), Ltest.CompletionAfterInstanceOf;, I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}", >+ requestor.getResults()); >+} >+ > }
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 287939
:
158833
|
159290
|
159397