Changeset 1192
- Timestamp:
- 06/20/08 23:19:43 (2 months ago)
- Files:
-
- trunk/descent.core/src/descent/core/CompletionProposal.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java (modified) (9 diffs)
- trunk/descent.core/src/descent/internal/codeassist/InternalCompletionProposal.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/codeassist/complete/CompletionOnImport.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java (modified) (3 diffs)
- trunk/descent.core/src/descent/internal/compiler/SourceElementParser.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Parser.java (modified) (10 diffs)
- trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalFunctionCallProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalMethodProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalTemplateProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalTemplatedFunctionProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/JavaMethodCompletionProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/JavaTemplateCompletionProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/JavaTemplatedFunctionCompletionProposal.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaMethodCompletionProposal.java (modified) (2 diffs)
- trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaTypeCompletionProposal.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/core/CompletionProposal.java
r1131 r1192 1992 1992 } 1993 1993 1994 /** 1995 * Returns whether the proposal is intended to be written with 1996 * arguments or just the name of the proposal. 1997 */ 1998 @Override 1999 public boolean wantArguments() { 2000 return super.wantArguments(); 2001 } 2002 1994 2003 @Override 1995 2004 public String toString() { trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java
r1189 r1192 269 269 boolean isCompletingSuperCall = false; 270 270 boolean isBetweenMethodName = false; 271 boolean wantArguments = true; 271 272 272 273 Scope rootScope; … … 444 445 !requestor.isIgnored(CompletionProposal.COMPILATION_UNIT_REF)) { 445 446 CompletionOnImport node = (CompletionOnImport) assistNode; 446 completeImport(node); 447 if (node.isSelective) { 448 completeSelectiveImport(node); 449 } else { 450 completeImport(node); 451 } 447 452 } else if (assistNode instanceof CompletionOnArgumentName) { 448 453 CompletionOnArgumentName node = (CompletionOnArgumentName) assistNode; … … 708 713 } 709 714 715 private void completeSelectiveImport(CompletionOnImport node) throws JavaModelException { 716 doSemantic(); 717 718 if (node.mod != null) { 719 if (node.selectiveName == null) { 720 this.startPosition = actualCompletionPosition; 721 this.endPosition = actualCompletionPosition; 722 this.currentName = CharOperation.NO_CHAR; 723 } else { 724 this.currentName = computePrefixAndSourceRange(node.selectiveName); 725 } 726 this.wantArguments = false; 727 suggestMembers(node.mod.members, false, new HashtableOfCharArrayAndObject(), INCLUDE_TYPES | INCLUDE_VARIABLES | INCLUDE_FUNCTIONS); 728 } 729 } 730 710 731 private void completeImport(CompletionOnImport node) { 711 732 char[] fqn = node.getFQN(); … … 2393 2414 CompletionProposal.METHOD_REF, 2394 2415 this.actualCompletionPosition, func); 2416 2417 if (parser.isInAddrExp) { 2418 proposal.wantArguments = false; 2419 } 2395 2420 2396 2421 if (constructor || opCall) { … … 3011 3036 proposal.nameLookup = this.nameEnvironment.nameLookup; 3012 3037 proposal.completionEngine = this; 3038 proposal.wantArguments = this.wantArguments; 3013 3039 return proposal; 3014 3040 } … … 3239 3265 3240 3266 CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition, null); 3267 3268 if (parser.isInAddrExp) { 3269 proposal.wantArguments = false; 3270 } 3241 3271 3242 3272 int relevance = computeBaseRelevance(); … … 3307 3337 return R_EXPECTED_TYPE; 3308 3338 } 3339 } else if (expectedType instanceof TypeDelegate) { 3340 if (type.covariant(expectedType.next, semanticContext) == 1) { 3341 return R_EXPECTED_TYPE; 3342 } 3309 3343 } 3310 3344 … … 3332 3366 } 3333 3367 3334 if (signature.length > 0 && 3335 (signature[0] == Signature.C_D_LINKAGE || signature[0] == Signature.C_C_LINKAGE || 3336 signature[0] == Signature.C_CPP_LINKAGE || signature[0] == Signature.C_PASCAL_LINKAGE || 3337 signature[0] == Signature.C_WINDOWS_LINKAGE)) { 3368 boolean isFunctionSignature = isFunctionSignature(signature); 3369 3370 if (CharOperation.equals(signature, expectedTypeSignature) || 3371 (expectedTypeSignature.length > 0 && expectedTypeSignature[0] == Signature.C_DELEGATE 3372 && isFunctionSignature 3373 && CharOperation.equals(signature, expectedTypeSignature, 1, expectedTypeSignature.length))) { 3374 return R_EXACT_EXPECTED_TYPE; 3375 } 3376 3377 if (isFunctionSignature) { 3338 3378 return computeRelevanceForExpectedType(Signature.getReturnType(signature)); 3339 }3340 3341 if (CharOperation.equals(expectedTypeSignature, signature)) {3342 return R_EXACT_EXPECTED_TYPE;3343 3379 } 3344 3380 … … 3372 3408 } 3373 3409 3410 private boolean isFunctionSignature(char[] signature) { 3411 return signature.length > 0 && signature[0] == Signature.C_D_LINKAGE || signature[0] == Signature.C_C_LINKAGE || 3412 signature[0] == Signature.C_CPP_LINKAGE || signature[0] == Signature.C_PASCAL_LINKAGE || 3413 signature[0] == Signature.C_WINDOWS_LINKAGE; 3414 } 3415 3374 3416 private boolean isImported(char[] fullyQualifiedName) { 3417 // This module is "imported" 3418 if (CharOperation.equals(fullyQualifiedName, this.sourceUnitFqn)) { 3419 return true; 3420 } 3421 3375 3422 if (module.aimports != null) { 3376 3423 for(Object sym : module.aimports) { trunk/descent.core/src/descent/internal/codeassist/InternalCompletionProposal.java
r1131 r1192 54 54 protected int declarationStart = -1; 55 55 protected boolean isAlias; // Whether the proposal is an alias for another symbol 56 protected boolean wantArguments; // Whether the proposal is intended to be completed with arguments or just the name 56 57 57 58 protected char[][] createDefaultParameterNames(int length) { … … 167 168 } 168 169 169 170 170 protected char[][] getParameterTypeNames() { 171 171 return this.parameterTypeNames; 172 172 } 173 173 174 protected boolean wantArguments() { 175 return this.wantArguments; 176 } 177 174 178 protected void setDeclarationPackageName(char[] declarationPackageName) { 175 179 this.declarationPackageName = declarationPackageName; trunk/descent.core/src/descent/internal/codeassist/complete/CompletionOnImport.java
r855 r1192 26 26 27 27 public int completePosition; 28 public boolean isSelective; 29 public IdentifierExp selectiveName; 28 30 29 31 public CompletionOnImport(Loc loc, Identifiers packages, IdentifierExp id, IdentifierExp aliasId, boolean isstatic, int completePosition) { trunk/descent.core/src/descent/internal/codeassist/complete/CompletionParser.java
r1173 r1192 86 86 public boolean inNewExp; 87 87 public boolean isInExp; 88 public boolean isInAddrExp; 88 89 89 90 public char[] completionToken; … … 202 203 return super.newImport(loc, packages, module, aliasid, isstatic); 203 204 } 205 } 206 207 @Override 208 protected Import addImportAlias(Import s, IdentifierExp name, IdentifierExp alias) { 209 super.addImportAlias(s, name, alias); 210 211 if (alias != null && alias.start <= cursorLocation && cursorLocation <= alias.start + alias.length) { 212 wantAssist = false; 213 wantKeywords = false; 214 return s; 215 } 216 217 if (prevToken.ptr <= cursorLocation && cursorLocation <= token.ptr) { 218 CompletionOnImport coi = new CompletionOnImport(s.loc, s.packages, s.id, s.aliasId, s.isstatic, cursorLocation); 219 if (name != null && name.start <= cursorLocation && cursorLocation <= name.start + name.length) { 220 coi.selectiveName = name; 221 } 222 coi.isSelective = true; 223 assistNode = coi; 224 wantKeywords = false; 225 return coi; 226 } 227 228 return s; 204 229 } 205 230 … … 691 716 } 692 717 return super.newCondExp(loc, e, e1, e2); 718 } 719 720 @Override 721 protected Expression newAddrExp(Loc loc, Expression e) { 722 if (e == assistNode) { 723 isInAddrExp = true; 724 } 725 return super.newAddrExp(loc, e); 693 726 } 694 727 trunk/descent.core/src/descent/internal/compiler/SourceElementParser.java
r1173 r1192 524 524 } 525 525 526 requestor.enterConstructor(info); 526 if (node.isCtorDeclaration() == null && 527 node.isDtorDeclaration() == null && 528 node.isNewDeclaration() == null && 529 node.isDeleteDeclaration() == null && 530 node.isPostBlitDeclaration() == null) { 531 requestor.enterMethod(info); 532 } else { 533 requestor.enterConstructor(info); 534 } 527 535 return true; 528 536 } trunk/descent.core/src/descent/internal/compiler/parser/Parser.java
r1173 r1192 2223 2223 2224 2224 // First, look ahead to see if it is a TypeParameter or a 2225 // ValueParameter ¿2225 // ValueParameterᅵ 2226 2226 2227 2227 t = peek(token); … … 2595 2595 s.preComments = lastComments; 2596 2596 s.first = prev == null; 2597 decldefs.add(s);2597 //decldefs.add(s); 2598 2598 if (prev == null) { 2599 2599 s.firstStart = start; … … 2613 2613 2614 2614 if (token.value != TOKidentifier) { 2615 parsingErrorInsertTokenAfter(prevToken, "Identifier"); 2615 // Signal an empty alias added 2616 s = addImportAlias(s, null, null); 2617 2618 parsingErrorInsertTokenAfter(prevToken, "Identifier"); 2619 2620 decldefs.add(s); 2616 2621 break; 2617 2622 } … … 2622 2627 nextToken(); 2623 2628 if (token.value != TOKidentifier) { 2629 // Signal an empty alias added 2630 s = addImportAlias(s, newIdentifierExp(), null); 2631 2624 2632 parsingErrorInsertTokenAfter(prevToken, "Identifier"); 2633 2634 decldefs.add(s); 2625 2635 break; 2626 2636 } … … 2631 2641 alias = null; 2632 2642 } 2633 s.addAlias(name, alias); 2643 s = addImportAlias(s, name, alias); 2644 decldefs.add(s); 2634 2645 s.setSourceRange(sStart, prevToken.ptr + prevToken.sourceLen - sStart); 2635 2646 } while (token.value == TOKcomma); 2636 2647 break; // no comma-separated imports of this form 2637 2648 } else { 2649 decldefs.add(s); 2638 2650 s.setSourceRange(sStart, prevToken.ptr + prevToken.sourceLen - sStart); 2639 2651 } … … 2652 2664 } 2653 2665 2666 2667 2654 2668 public Type parseType() { 2655 2669 return parseType(null, null); … … 6610 6624 nextToken(); 6611 6625 e = parseUnaryExp(); 6612 e = new AddrExp(loc(), e);6626 e = newAddrExp(loc(), e); 6613 6627 break; 6614 6628 … … 6832 6846 6833 6847 return e; 6834 } 6848 } 6835 6849 6836 6850 private void parsePrimaryExp_case_delegate(Expression[] e, TOK save, boolean isEmptySyntax) { … … 7895 7909 } 7896 7910 7911 protected Expression newAddrExp(Loc loc, Expression e) { 7912 return new AddrExp(loc, e); 7913 } 7914 7897 7915 protected VarDeclaration newVarDeclaration(Loc loc, Type type, IdentifierExp ident, Initializer init) { 7898 7916 return new VarDeclaration(loc, type, ident, init); … … 7933 7951 protected AggregateDeclaration endAggregateDeclaration(AggregateDeclaration a) { 7934 7952 return a; 7953 } 7954 7955 protected Import addImportAlias(Import s, IdentifierExp name, IdentifierExp alias) { 7956 if (name != null && alias != null) { 7957 s.addAlias(name, alias); 7958 } 7959 return s; 7935 7960 } 7936 7961 trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalFunctionCallProposal.java
r1132 r1192 87 87 */ 88 88 protected String computeReplacementString() { 89 if (!fProposal.wantArguments()) { 90 return new String(fProposal.getName()); 91 } 89 92 90 if (!hasParameters() || !hasArgumentList()) 93 if (!hasParameters() || !hasArgumentList()) { 91 94 return super.computeReplacementString(); 95 } 92 96 93 97 char[][] parameterTypes= Signature.getParameterTypes(fProposal.getTypeSignature()); trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalMethodProposal.java
r1132 r1192 86 86 */ 87 87 protected String computeReplacementString() { 88 if (!fProposal.wantArguments()) { 89 return new String(fProposal.getName()); 90 } 88 91 89 if (!hasParameters() || !hasArgumentList()) 92 if (!hasParameters() || !hasArgumentList()) { 90 93 return super.computeReplacementString(); 94 } 91 95 92 96 char[][] parameterNames= fProposal.findParameterNames(null); trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalTemplateProposal.java
r1132 r1192 86 86 */ 87 87 protected String computeReplacementString() { 88 89 if (!hasParameters() || !hasArgumentList()) 90 return super.computeReplacementString(); 91 92 char[][] parameterNames= fProposal.findTemplateParameterNames(null); 93 int count= parameterNames.length; 94 fArgumentOffsets= new int[count]; 95 fArgumentLengths= new int[count]; 96 StringBuffer buffer= new StringBuffer(String.valueOf(fProposal.getName())); 97 98 FormatterPrefs prefs= getFormatterPrefs(); 99 if (prefs.beforeOpeningParen) 100 buffer.append(SPACE); 101 buffer.append(EXCLAMATION); 102 buffer.append(LPAREN); 103 104 setCursorPosition(buffer.length()); 105 106 if (prefs.afterOpeningParen) 107 buffer.append(SPACE); 108 109 for (int i= 0; i != count; i++) { 110 if (i != 0) { 111 if (prefs.beforeFunctionComma) 112 buffer.append(SPACE); 113 buffer.append(COMMA); 114 if (prefs.afterFunctionComma) 115 buffer.append(SPACE); 88 try { 89 if (!hasParameters() || !hasArgumentList()) 90 return super.computeReplacementString(); 91 92 char[][] parameterNames= fProposal.findTemplateParameterNames(null); 93 int count= parameterNames.length; 94 fArgumentOffsets= new int[count]; 95 fArgumentLengths= new int[count]; 96 StringBuffer buffer= new StringBuffer(String.valueOf(fProposal.getName())); 97 98 FormatterPrefs prefs= getFormatterPrefs(); 99 if (prefs.beforeOpeningParen) 100 buffer.append(SPACE); 101 buffer.append(EXCLAMATION); 102 buffer.append(LPAREN); 103 104 setCursorPosition(buffer.length()); 105 106 if (prefs.afterOpeningParen) 107 buffer.append(SPACE); 108 109 for (int i= 0; i != count; i++) { 110 if (i != 0) { 111 if (prefs.beforeFunctionComma) 112 buffer.append(SPACE); 113 buffer.append(COMMA); 114 if (prefs.afterFunctionComma) 115 buffer.append(SPACE); 116 } 117 118 fArgumentOffsets[i]= buffer.length(); 119 buffer.append(parameterNames[i]); 120 fArgumentLengths[i]= parameterNames[i].length; 116 121 } 117 122 118 fArgumentOffsets[i]= buffer.length(); 119 buffer.append(parameterNames[i]); 120 fArgumentLengths[i]= parameterNames[i].length; 123 if (prefs.beforeFunctionClosingParen) 124 buffer.append(SPACE); 125 126 buffer.append(RPAREN); 127 128 return buffer.toString(); 129 } finally { 130 if (!fProposal.wantArguments()) { 131 setCursorPosition(fProposal.getName().length); 132 return new String(fProposal.getName()); 133 } 121 134 } 122 123 if (prefs.beforeFunctionClosingParen)124 buffer.append(SPACE);125 126 buffer.append(RPAREN);127 128 return buffer.toString();129 135 } 130 136 trunk/descent.ui/src/descent/internal/ui/text/java/ExperimentalTemplatedFunctionProposal.java
r1132 r1192 92 92 */ 93 93 protected String computeReplacementString() { 94 try{ 95 if (!hasParameters() || !hasArgumentList()) { 96 return super.computeReplacementString(); 97 } 94 98 95 if (!hasParameters() || !hasArgumentList()) 96 return super.computeReplacementString(); 97 98 char[][] tempParameterNames= fProposal.findTemplateParameterNames(null); 99 int tempCount= tempParameterNames.length; 100 fTempArgumentOffsets= new int[tempCount]; 101 fTempArgumentLengths= new int[tempCount]; 102 103 char[][] parameterNames= fProposal.findParameterNames(null); 104 int count= parameterNames.length; 105 fArgumentOffsets= new int[count]; 106 fArgumentLengths= new int[count]; 107 108 StringBuffer buffer= new StringBuffer(String.valueOf(fProposal.getName())); 109 110 FormatterPrefs prefs= getFormatterPrefs(); 111 if (prefs.beforeOpeningParen) 112 buffer.append(SPACE); 113 buffer.append(EXCLAMATION); 114 buffer.append(LPAREN); 115 116 if (tempCount > 0) { 117 setCursorPosition(buffer.length()); 99 char[][] tempParameterNames= fProposal.findTemplateParameterNames(null); 100 int tempCount= tempParameterNames.length; 101 fTempArgumentOffsets= new int[tempCount]; 102 fTempArgumentLengths= new int[tempCount]; 103 104 char[][] parameterNames= fProposal.findParameterNames(null); 105 int count= parameterNames.length; 106 fArgumentOffsets= new int[count]; 107 fArgumentLengths= new int[count]; 108 109 StringBuffer buffer= new StringBuffer(String.valueOf(fProposal.getName())); 110 111 FormatterPrefs prefs= getFormatterPrefs(); 112 if (prefs.beforeOpeningParen) 113 buffer.append(SPACE); 114 buffer.append(EXCLAMATION); 115 buffer.append(LPAREN); 116 117 if (tempCount > 0) { 118 setCursorPosition(buffer.length()); 119 } 120 121 if (prefs.afterOpeningParen) 122 buffer.append(SPACE); 123 124 for (int i= 0; i != tempCount; i++) { 125 if (i != 0) { 126 if (prefs.beforeFunctionComma) 127 buffer.append(SPACE); 128 buffer.append(COMMA); 129 if (prefs.afterFunctionComma) 130 buffer.append(SPACE); 131 } 132 133 fTempArgumentOffsets[i]= buffer.length(); 134 buffer.append(tempParameterNames[i]); 135 fTempArgumentLengths[i]= tempParameterNames[i].length; 136 } 137 138 if (prefs.beforeFunctionClosingParen) 139 buffer.append(SPACE); 140 141 buffer.append(RPAREN); 142 143 buffer.append(LPAREN); 144 145 if (tempCount == 0) { 146 setCursorPosition(buffer.length()); 147 } 148 149 if (prefs.afterOpeningParen) 150 buffer.append(SPACE); 151 152 for (int i= 0; i != count; i++) { 153 if (i != 0) { 154 if (prefs.beforeFunctionComma) 155 buffer.append(SPACE); 156 buffer.append(COMMA); 157 if (prefs.afterFunctionComma) 158 buffer.append(SPACE); 159 } 160 161 fArgumentOffsets[i]= buffer.length(); 162 buffer.append(parameterNames[i]); 163 fArgumentLengths[i]= parameterNames[i].length; 164 } 165 166 buffer.append(RPAREN); 167 168 return buffer.toString(); 169 } finally { 170 if (!fProposal.wantArguments()) { 171 setCursorPosition(fProposal.getName().length); 172 return new String(fProposal.getName()); 173 } 118 174 } 119 120 if (prefs.afterOpeningParen)121 buffer.append(SPACE);122 123 for (int i= 0; i != tempCount; i++) {124 if (i != 0) {125 if (prefs.beforeFunctionComma)126 buffer.append(SPACE);127 buffer.append(COMMA);128 if (prefs.afterFunctionComma)129 buffer.append(SPACE);130 }131 132 fTempArgumentOffsets[i]= buffer.length();133 buffer.append(tempParameterNames[i]);134 fTempArgumentLengths[i]= tempParameterNames[i].length;135 }136 137 if (prefs.beforeFunctionClosingParen)138 buffer.append(SPACE);139 140 buffer.append(RPAREN);141 142 buffer.append(LPAREN);143 144 if (tempCount == 0) {145 setCursorPosition(buffer.length());146 }147 148 if (prefs.afterOpeningParen)149 buffer.append(SPACE);150 151 for (int i= 0; i != count; i++) {152 if (i != 0) {153 if (prefs.beforeFunctionComma)154 buffer.append(SPACE);155 buffer.append(COMMA);156 if (prefs.afterFunctionComma)157 buffer.append(SPACE);158 }159 160 fArgumentOffsets[i]= buffer.length();161 buffer.append(parameterNames[i]);162 fArgumentLengths[i]= parameterNames[i].length;163 }164 165 buffer.append(RPAREN);166 167 return buffer.toString();168 175 } 169 176 trunk/descent.ui/src/descent/internal/ui/text/java/JavaMethodCompletionProposal.java
r1132 r1192 193 193 */ 194 194 protected String computeReplacementString() { 195 if (!hasArgumentList()) 195 if (!fProposal.wantArguments()) { 196 return new String(fProposal.getName()); 197 } 198 199 if (!hasArgumentList()) { 196 200 return super.computeReplacementString(); 201 } 197 202 198 203 // we're inserting a method plus the argument list - respect formatter preferences trunk/descent.ui/src/descent/internal/ui/text/java/JavaTemplateCompletionProposal.java
r1126 r1192 139 139 */ 140 140 protected String computeReplacementString() { 141 if (!hasArgumentList()) 142 return super.computeReplacementString(); 143 144 // we're inserting a method plus the argument list - respect formatter preferences 145 StringBuffer buffer= new StringBuffer(); 146 buffer.append(fProposal.getName()); 147 148 FormatterPrefs prefs= getFormatterPrefs(); 149 if (prefs.beforeOpeningParen) 150 buffer.append(SPACE); 151 buffer.append(EXCLAMATION); 152 buffer.append(LPAREN); 153 154 if (hasParameters()) { 155 setCursorPosition(buffer.length()); 141 try { 142 if (!hasArgumentList()) { 143 return super.computeReplacementString(); 144 } 156 145 157 if (prefs.afterOpeningParen) 146 // we're inserting a method plus the argument list - respect formatter preferences 147 StringBuffer buffer= new StringBuffer(); 148 buffer.append(fProposal.getName()); 149 150 FormatterPrefs prefs= getFormatterPrefs(); 151 if (prefs.beforeOpeningParen) 158 152 buffer.append(SPACE); 153 buffer.append(EXCLAMATION); 154 buffer.append(LPAREN); 159 155 160 161 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 162 // if (prefs.beforeClosingParen) 163 // buffer.append(SPACE); 164 } else { 165 if (prefs.inEmptyList) 166 buffer.append(SPACE); 167 } 168 169 buffer.append(RPAREN); 170 171 return buffer.toString(); 156 if (hasParameters()) { 157 setCursorPosition(buffer.length()); 158 159 if (prefs.afterOpeningParen) 160 buffer.append(SPACE); 161 162 163 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 164 // if (prefs.beforeClosingParen) 165 // buffer.append(SPACE); 166 } else { 167 if (prefs.inEmptyList) 168 buffer.append(SPACE); 169 } 170 171 buffer.append(RPAREN); 172 173 return buffer.toString(); 174 } finally { 175 if (!fProposal.wantArguments()) { 176 setCursorPosition(fProposal.getName().length); 177 return new String(fProposal.getName()); 178 } 179 } 172 180 } 173 181 trunk/descent.ui/src/descent/internal/ui/text/java/JavaTemplatedFunctionCompletionProposal.java
r1126 r1192 153 153 */ 154 154 protected String computeReplacementString() { 155 if (!hasArgumentList()) 156 return super.computeReplacementString(); 157 158 // we're inserting a method plus the argument list - respect formatter preferences 159 StringBuffer buffer= new StringBuffer(); 160 buffer.append(fProposal.getName()); 161 162 FormatterPrefs prefs= getFormatterPrefs(); 163 if (prefs.beforeOpeningParen) 164 buffer.append(SPACE); 165 buffer.append(EXCLAMATION); 166 buffer.append(LPAREN); 167 168 if (hasTemplateParameters()) { 169 setCursorPosition(buffer.length()); 155 try { 156 if (!hasArgumentList()) { 157 return super.computeReplacementString(); 158 } 170 159 171 if (prefs.afterOpeningParen) 160 // we're inserting a method plus the argument list - respect formatter preferences 161 StringBuffer buffer= new StringBuffer(); 162 buffer.append(fProposal.getName()); 163 164 FormatterPrefs prefs= getFormatterPrefs(); 165 if (prefs.beforeOpeningParen) 172 166 buffer.append(SPACE); 167 buffer.append(EXCLAMATION); 168 buffer.append(LPAREN); 173 169 174 175 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 176 // if (prefs.beforeClosingParen) 177 // buffer.append(SPACE); 178 } else { 179 if (prefs.inEmptyList) 180 buffer.append(SPACE); 181 } 182 buffer.append(RPAREN); 183 184 buffer.append(LPAREN); 185 if (hasParameters()) { 186 if (!hasTemplateParameters()) { 170 if (hasTemplateParameters()) { 187 171 setCursorPosition(buffer.length()); 188 } 172 173 if (prefs.afterOpeningParen) 174 buffer.append(SPACE); 175 176 177 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 178 // if (prefs.beforeClosingParen) 179 // buffer.append(SPACE); 180 } else { 181 if (prefs.inEmptyList) 182 buffer.append(SPACE); 183 } 184 buffer.append(RPAREN); 189 185 190 if (prefs.afterOpeningParen) 191 buffer.append(SPACE); 192 193 194 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 195 // if (prefs.beforeClosingParen) 196 // buffer.append(SPACE); 197 } else { 198 if (prefs.inEmptyList) 199 buffer.append(SPACE); 200 } 201 buffer.append(RPAREN); 202 203 return buffer.toString(); 186 buffer.append(LPAREN); 187 if (hasParameters()) { 188 if (!hasTemplateParameters()) { 189 setCursorPosition(buffer.length()); 190 } 191 192 if (prefs.afterOpeningParen) 193 buffer.append(SPACE); 194 195 196 // don't add the trailing space, but let the user type it in himself - typing the closing paren will exit 197 // if (prefs.beforeClosingParen) 198 // buffer.append(SPACE); 199 } else { 200 if (prefs.inEmptyList) 201 buffer.append(SPACE); 202 } 203 buffer.append(RPAREN); 204 205 return buffer.toString(); 206 } finally { 207 if (!fProposal.wantArguments()) { 208 setCursorPosition(fProposal.getName().length); 209 return new String(fProposal.getName()); 210 } 211 } 204 212 } 205 213
