Changeset 1147
- Timestamp:
- 05/01/08 12:11:31 (4 months ago)
- Files:
-
- trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java (modified) (8 diffs)
- trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java (modified) (4 diffs)
- trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaMethodCompletionProposal.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java
r1145 r1147 264 264 boolean isCompletingThisCall = false; 265 265 boolean isCompletingSuperCall = false; 266 boolean isBetweenMethodName = false; 266 267 267 268 Scope rootScope; … … 660 661 CompletionContext context = new CompletionContext(); 661 662 context.setOffset(this.offset); 663 if (parser.completionToken != null) { 664 context.setTokenKind(CompletionContext.TOKEN_KIND_NAME); 665 context.setToken(parser.completionToken); 666 context.setTokenRange(parser.completionTokenStart, parser.completionTokenEnd); 667 } 662 668 return context; 663 669 } … … 1456 1462 } 1457 1463 private void completeExpression(Expression e1, IdentifierExp ident) throws JavaModelException { 1464 isBetweenMethodName = ident != null && ident.resolvedSymbol != null; 1465 1458 1466 if (e1 instanceof VarExp) { 1459 1467 VarExp var = (VarExp) e1; … … 1659 1667 proposal.setCompletion(CharOperation.NO_CHAR); 1660 1668 } else { 1661 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 1669 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 1670 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 1671 } else { 1672 proposal.setCompletion(currentName); 1673 } 1662 1674 } 1663 1675 … … 2293 2305 handleContextInfo(func, funcNameIsOpCall, proposal); 2294 2306 } else { 2295 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 2307 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 2308 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 2309 } else { 2310 proposal.setCompletion(currentName); 2311 } 2296 2312 } 2297 2313 } else { … … 2300 2316 handleContextInfo(func, funcNameIsOpCall, proposal); 2301 2317 } else { 2302 proposal.setCompletion(CharOperation.concat(ident, "()".toCharArray())); 2318 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 2319 proposal.setCompletion(CharOperation.concat(ident, "()".toCharArray())); 2320 } else { 2321 proposal.setCompletion(ident); 2322 } 2303 2323 } 2304 2324 } … … 2707 2727 private char[] computePrefixAndSourceRange(IdentifierExp ident) { 2708 2728 char[] prefix; 2709 if (ident == null || ident.ident == null || CharOperation.equals(ident.ident, CharOperation.NO_CHAR)) { 2729 2730 if (parser.completionToken != null) { 2731 this.startPosition = parser.completionTokenStart; 2732 this.endPosition = parser.completionTokenEnd; 2733 prefix = parser.completionToken; 2734 } else if (ident == null || ident.ident == null || CharOperation.equals(ident.ident, CharOperation.NO_CHAR)) { 2710 2735 this.startPosition = this.actualCompletionPosition; 2711 2736 this.endPosition = this.actualCompletionPosition; … … 2716 2741 prefix = ident.ident; 2717 2742 } 2743 2718 2744 return prefix; 2719 2745 } trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java
r1141 r1147 85 85 public boolean inNewExp; 86 86 public boolean isInExp; 87 88 public char[] completionToken; 89 public int completionTokenStart; 90 public int completionTokenEnd; 87 91 88 92 public CompletionParser(int apiLevel, char[] source, char[] filename) { … … 242 246 @Override 243 247 protected IdentifierExp newIdentifierExp() { 244 if (token.ptr + token.sourceLen == cursorLocation && !wantNames) { 248 if (token.ptr <= cursorLocation && cursorLocation <= token.ptr + token.sourceLen && !wantNames) { 249 completionTokenStart = token.ptr; 250 completionTokenEnd = token.ptr + token.sourceLen; 251 completionToken = CharOperation.subarray(input, completionTokenStart, cursorLocation); 252 245 253 assistNode = new CompletionOnIdentifierExp(loc, token); 246 254 return (IdentifierExp) assistNode; … … 261 269 @Override 262 270 protected TypeQualified newTypeIdentifier(Loc loc, IdentifierExp id) { 263 if (id.start + id.length == cursorLocation) {271 if (id.start <= cursorLocation && cursorLocation <= id.start + id.length) { 264 272 assistNode = new CompletionOnTypeIdentifier(loc, id); 265 273 return (TypeQualified) assistNode; … … 435 443 @Override 436 444 protected DotIdExp newDotIdExp(Loc loc, Expression e, IdentifierExp id) { 437 if (prevToken.ptr + prevToken.sourceLen == cursorLocation || token.ptr + token.sourceLen == cursorLocation) {445 if (prevToken.ptr <= cursorLocation && cursorLocation <= prevToken.ptr + prevToken.sourceLen) { 438 446 if (cursorLocation <= id.start) { 439 447 assistNode = new CompletionOnDotIdExp(loc, e, new IdentifierExp(CharOperation.NO_CHAR)); 440 448 return (DotIdExp) assistNode; 441 449 } else { 450 completionTokenStart = prevToken.ptr; 451 completionTokenEnd = prevToken.ptr + prevToken.sourceLen; 452 completionToken = CharOperation.subarray(input, completionTokenStart, cursorLocation); 453 442 454 assistNode = new CompletionOnDotIdExp(loc, e, id); 443 455 return (DotIdExp) assistNode; trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaMethodCompletionProposal.java
r1136 r1147 117 117 if (!hasParameters() || !hasArgumentList()) { 118 118 setCursorPosition(replacement.length() + (getVariadic() != IMethod.VARARGS_NO ? 1 : 2)); 119 if (replacement.length() > 0) {120 return replacement + "()"; //$NON-NLS-1$121 } else {119 // if (replacement.length() > 0) { 120 // return replacement + "()"; //$NON-NLS-1$ 121 // } else { 122 122 return replacement; 123 }123 // } 124 124 } 125 125
