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 50801 Details for
Bug 141518
IEvaluationContext.newVariable is not considered when doing codecomplete.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug141518__002.txt (text/plain), 5.50 KB, created by
David Audel
on 2006-09-25 05:40:05 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2006-09-25 05:40:05 EDT
Size:
5.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.128 >diff -u -r1.128 CompletionTests.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 25 Sep 2006 08:22:38 -0000 1.128 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 25 Sep 2006 09:43:15 -0000 >@@ -923,6 +923,41 @@ > requestor.getResults()); > } > >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=141518 >+public void testEvaluationContextCompletion5() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/TestEvaluationContextCompletion5.java", >+ "package test;"+ >+ "public class TestEvaluationContextCompletion5 {\n"+ >+ "}"); >+ >+ String start = "someVariable.to"; >+ IJavaProject javaProject = getJavaProject("Completion"); >+ IEvaluationContext context = javaProject.newEvaluationContext(); >+ >+ context.newVariable( "Object", "someVariable", null ); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false); >+ context.codeComplete(start, start.length(), requestor, this.wcOwner); >+ >+ int startOffset = start.length() - 2; >+ int endOffset = startOffset + 2 ; >+ >+ assertResults( >+ "completion offset="+endOffset+"\n"+ >+ "completion range=["+startOffset+", "+(endOffset-1)+"]\n"+ >+ "completion token=\"to\"\n"+ >+ "completion token kind=TOKEN_KIND_NAME\n"+ >+ "expectedTypesSignatures=null\n"+ >+ "expectedTypesKeys=null", >+ requestor.getContext()); >+ >+ assertResults( >+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"}", >+ requestor.getResults()); >+} >+ > /** > * Ensures that completion is not case sensitive > */ >#P org.eclipse.jdt.core >Index: eval/org/eclipse/jdt/internal/eval/EvaluationContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java,v >retrieving revision 1.54 >diff -u -r1.54 EvaluationContext.java >--- eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 4 Sep 2006 08:58:33 -0000 1.54 >+++ eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 25 Sep 2006 09:43:17 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.eval; > >+import java.util.Locale; > import java.util.Map; > > import org.eclipse.jdt.core.CompletionRequestor; >@@ -20,9 +21,12 @@ > import org.eclipse.jdt.internal.codeassist.SelectionEngine; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.IProblemFactory; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; > import org.eclipse.jdt.internal.compiler.env.IBinaryType; > import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; > import org.eclipse.jdt.internal.compiler.env.INameEnvironment; >+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.core.SearchableEnvironment; >@@ -98,6 +102,20 @@ > * set of options used to configure the code assist engine. > */ > public void complete(char[] codeSnippet, int completionPosition, SearchableEnvironment environment, CompletionRequestor requestor, Map options, IJavaProject project) { >+ try { >+ IRequestor variableRequestor = new IRequestor() { >+ public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { >+ // Do nothing >+ return true; >+ } >+ public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int fragmentKind) { >+ // Do nothing >+ } >+ }; >+ this.evaluateVariables(environment, options, variableRequestor, new DefaultProblemFactory(Locale.getDefault())); >+ } catch (InstallException e) { >+ // Do nothing >+ } > final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$ > final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper( > codeSnippet, >@@ -125,7 +143,28 @@ > return null; > } > }; >+ > CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options, project); >+ >+ if (this.installedVars != null) { >+ IBinaryType binaryType = this.getRootCodeSnippetBinary(); >+ if (binaryType != null) { >+ engine.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/); >+ } >+ >+ ClassFile[] classFiles = installedVars.classFiles; >+ for (int i = 0; i < classFiles.length; i++) { >+ ClassFile classFile = classFiles[i]; >+ IBinaryType binary = null; >+ try { >+ binary = new ClassFileReader(classFile.getBytes(), null); >+ } catch (ClassFormatException e) { >+ e.printStackTrace(); // Should never happen since we compiled this type >+ } >+ engine.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/); >+ } >+ } >+ > engine.complete(sourceUnit, mapper.startPosOffset + completionPosition, mapper.startPosOffset); > } > /**
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 141518
:
41327
| 50801