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 27813 Details for
Bug 110188
[plan][assist] Provide hook for completing inside string literal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
incomplete patch to allow string completion
patchjdtcore001.txt (text/plain), 9.72 KB, created by
David Audel
on 2005-10-04 11:50:49 EDT
(
hide
)
Description:
incomplete patch to allow string completion
Filename:
MIME Type:
Creator:
David Audel
Created:
2005-10-04 11:50:49 EDT
Size:
9.72 KB
patch
obsolete
>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.144 >diff -u -r1.144 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 29 Sep 2005 16:30:31 -0000 1.144 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 4 Oct 2005 15:37:26 -0000 >@@ -3133,7 +3133,51 @@ > public TypeReference createParameterizedSingleAssistTypeReference(TypeReference[] typeArguments, char[] assistName, long position) { > return this.createSingleAssistTypeReference(assistName, position); > } >- >+protected StringLiteral createStringLiteral(char[] token, int start, int end) { >+ if (start <= this.cursorLocation && this.cursorLocation <= end){ >+ char[] source = this.scanner.source; >+ >+ int stringStart = start; >+ int stringEnd = end; >+ >+ // " could be as unicode \u0022 >+ int pos = stringStart; >+ if(source[pos] == '\"') { >+ stringStart = pos + 1; >+ } else if(source[pos] == '\\' && source[pos+1] == 'u') { >+ pos += 2; >+ while (source[pos] == 'u') { >+ pos++; >+ } >+ stringStart = pos + 4; >+ } >+ pos = stringEnd; >+ if(source[pos] == '\"') { >+ stringEnd = pos - 1; >+ } else if(source.length > 5 && source[pos-4] == 'u') { >+ pos -= 5; >+ while (pos > -1 && source[pos] == 'u') { >+ pos--; >+ } >+ if(pos > -1 && source[pos] == '\\') { >+ stringEnd = pos - 1; >+ } >+ >+ } >+ >+ CompletionOnStringLiteral stringLiteral = new CompletionOnStringLiteral( >+ token, >+ stringStart, >+ stringEnd); >+ >+ this.assistNode = stringLiteral; >+ this.restartRecovery = true; >+ this.lastCheckPoint = end; >+ >+ return stringLiteral; >+ } >+ return super.createStringLiteral(token, start, end); >+} > public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int cursorLoc) { > > this.cursorLocation = cursorLoc; >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java,v >retrieving revision 1.49 >diff -u -r1.49 CompletionScanner.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java 28 Sep 2005 13:45:33 -0000 1.49 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java 4 Oct 2005 15:37:27 -0000 >@@ -21,7 +21,6 @@ > * n means completion behind the n-th character > */ > import org.eclipse.jdt.core.compiler.*; >-import org.eclipse.jdt.core.compiler.InvalidInputException; > import org.eclipse.jdt.internal.compiler.parser.Scanner; > > public class CompletionScanner extends Scanner { >@@ -82,6 +81,25 @@ > return super.getCurrentIdentifierSource(); > } > >+public char[] getCurrentTokenSourceString() { >+ if (this.completionIdentifier == null){ >+ if (this.cursorLocation+1 >= this.startPosition && this.cursorLocation < this.currentPosition){ >+ // remember actual identifier positions >+ this.completedIdentifierStart = this.startPosition; >+ this.completedIdentifierEnd = this.currentPosition - 1; >+ if (this.withoutUnicodePtr != 0){ // check unicode scenario >+ int length = this.cursorLocation - this.startPosition - this.unicodeCharSize; >+ System.arraycopy(this.withoutUnicodeBuffer, 2, this.completionIdentifier = new char[length], 0, length); >+ } else { >+ // no char[] sharing around completionIdentifier, we want it to be unique so as to use identity checks >+ int length = this.cursorLocation - this.startPosition; >+ System.arraycopy(this.source, this.startPosition + 1, (this.completionIdentifier = new char[length]), 0, length); >+ } >+ return this.completionIdentifier; >+ } >+ } >+ return super.getCurrentTokenSourceString(); >+} > public int getNextToken() throws InvalidInputException { > > this.wasAcr = false; >@@ -490,9 +508,6 @@ > } > throw e; // rethrow > } >- if (this.startPosition <= this.cursorLocation && this.cursorLocation <= this.currentPosition-1){ >- throw new InvalidCursorLocation(InvalidCursorLocation.NO_COMPLETION_INSIDE_STRING); >- } > return TokenNameStringLiteral; > case '/' : > { >@@ -760,7 +775,9 @@ > public final void getNextUnicodeChar() throws InvalidInputException { > int temp = this.currentPosition; // the \ is already read > super.getNextUnicodeChar(); >- this.unicodeCharSize += (this.currentPosition - temp); >+ if(this.cursorLocation > temp) { >+ this.unicodeCharSize += (this.currentPosition - temp); >+ } > if (temp < this.cursorLocation && this.cursorLocation < this.currentPosition-1){ > throw new InvalidCursorLocation(InvalidCursorLocation.NO_COMPLETION_INSIDE_UNICODE); > } >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java,v >retrieving revision 1.10 >diff -u -r1.10 CompletionNodeDetector.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java 13 Apr 2005 14:37:33 -0000 1.10 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java 4 Oct 2005 15:37:23 -0000 >@@ -263,6 +263,9 @@ > public boolean visit(SingleTypeReference singleTypeReference, ClassScope scope) { > return this.visit(singleTypeReference); > } >+ public boolean visit(StringLiteral stringLiteral, BlockScope scope) { >+ return this.visit(stringLiteral); >+ } > public boolean visit(SuperReference superReference, BlockScope scope) { > return this.visit(superReference); > } >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.319 >diff -u -r1.319 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 29 Sep 2005 18:17:12 -0000 1.319 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 4 Oct 2005 15:37:33 -0000 >@@ -6847,11 +6847,11 @@ > this.scanner.currentPosition - 1)); > break; > case TokenNameStringLiteral : >- StringLiteral stringLiteral = new StringLiteral( >+ pushOnExpressionStack( >+ this.createStringLiteral( > this.scanner.getCurrentTokenSourceString(), > this.scanner.startPosition, >- this.scanner.currentPosition - 1); >- pushOnExpressionStack(stringLiteral); >+ this.scanner.currentPosition - 1)); > break; > case TokenNamefalse : > pushOnExpressionStack( >@@ -7383,6 +7383,9 @@ > protected LocalDeclaration createLocalDeclaration(char[] localDeclarationName, int sourceStart, int sourceEnd) { > return new LocalDeclaration(localDeclarationName, sourceStart, sourceEnd); > } >+protected StringLiteral createStringLiteral(char[] token, int start, int end) { >+ return new StringLiteral(token, start, end); >+} > protected RecoveredType currentRecoveryType() { > if(this.currentElement != null) { > if(this.currentElement instanceof RecoveredType) { >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java,v >retrieving revision 1.157 >diff -u -r1.157 Scanner.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java 28 Sep 2005 13:45:33 -0000 1.157 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java 4 Oct 2005 15:37:36 -0000 >@@ -488,7 +488,7 @@ > this.startPosition, > this.currentPosition - this.startPosition); > } >-public final char[] getCurrentTokenSourceString() { >+public char[] getCurrentTokenSourceString() { > //return the token REAL source (aka unicodes are precomputed). > //REMOVE the two " that are at the beginning and the end. > >Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnStringLiteral.java >=================================================================== >RCS file: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnStringLiteral.java >diff -N codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnStringLiteral.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnStringLiteral.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+package org.eclipse.jdt.internal.codeassist.complete; >+ >+import org.eclipse.jdt.internal.compiler.ast.StringLiteral; >+import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >+import org.eclipse.jdt.internal.compiler.lookup.ClassScope; >+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >+ >+public class CompletionOnStringLiteral extends StringLiteral { >+ >+ public CompletionOnStringLiteral(char[] token, int s, int e) { >+ super(token, s, e); >+ } >+ >+ public CompletionOnStringLiteral(int s, int e) { >+ super(s,e); >+ } >+ public TypeBinding resolveType(ClassScope scope) { >+ throw new CompletionNodeFound(this, null, scope); >+ } >+ public TypeBinding resolveType(BlockScope scope) { >+ throw new CompletionNodeFound(this, null, scope); >+ } >+ >+ public StringBuffer printExpression(int indent, StringBuffer output) { >+ output.append("<CompletionOnString:"); //$NON-NLS-1$ >+ output = super.printExpression(indent, output); >+ return output.append('>'); >+ } >+}
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 110188
: 27813