Changeset 1148
- Timestamp:
- 05/01/08 13:29:14 (8 months ago)
- Files:
-
- trunk/descent.core/src/descent/core/Signature.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java (modified) (12 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ASTNodeEncoder.java (modified) (6 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ISignatureConstants.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/core/search/matching/FieldPattern.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/core/search/matching/MethodPattern.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/core/search/matching/TypeDeclarationPattern.java (modified) (1 diff)
- trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaMethodCompletionProposal.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/core/Signature.java
r1146 r1148 130 130 * | "|" // interface 131 131 * | "E" // enum 132 * | " /" // variable132 * | "¡" // variable 133 133 * | "=" // alias 134 134 * | "T" // typedef … … 485 485 /** 486 486 * Character constant indicating a variable in a signature. 487 * Value is <code>' /'</code>.488 */ 489 public static final char C_VARIABLE = ' /';487 * Value is <code>'¡'</code>. 488 */ 489 public static final char C_VARIABLE = '¡'; 490 490 491 491 /** trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java
r1147 r1148 225 225 } 226 226 227 char[] parenthesis = { '(', ')' }; 228 227 229 IJavaProject javaProject; 228 230 CompletionParser parser; … … 720 722 } 721 723 722 nameEnvironment.findCompilationUnits(fqnBeforeCursor, this); 724 if (fqnBeforeCursor.length > 0) { 725 nameEnvironment.findCompilationUnits(fqnBeforeCursor, this); 726 } 723 727 } 724 728 … … 1036 1040 // Also suggest packages 1037 1041 isCompletingPackage = true; 1038 nameEnvironment.findCompilationUnits(currentName, this); 1042 if (currentName.length > 0) { 1043 nameEnvironment.findCompilationUnits(currentName, this); 1044 } 1039 1045 1040 1046 // And top level declarations 1041 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1047 if (currentName.length > 0) { 1048 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1049 } 1042 1050 1043 1051 // Show constructors and opCalls … … 1188 1196 // Also suggest packages 1189 1197 isCompletingPackage = true; 1190 nameEnvironment.findCompilationUnits(currentName, this); 1198 if (currentName.length > 0) { 1199 nameEnvironment.findCompilationUnits(currentName, this); 1200 } 1191 1201 1192 1202 // And top level declarations 1193 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1203 if (currentName.length > 0) { 1204 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1205 } 1194 1206 } 1195 1207 … … 1199 1211 if (node.dot == -1) { 1200 1212 currentName = computePrefixAndSourceRange(node); 1213 isBetweenMethodName = node.resolvedSymbol != null; 1201 1214 1202 1215 if (rootScope == null) { … … 1208 1221 // Also suggest packages 1209 1222 isCompletingPackage = true; 1210 nameEnvironment.findCompilationUnits(currentName, this); 1223 1224 if (currentName.length > 0) { 1225 nameEnvironment.findCompilationUnits(currentName, this); 1226 } 1211 1227 1212 1228 // And top level declarations 1213 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1229 if (currentName.length > 0) { 1230 nameEnvironment.findPrefixDeclarations(currentName, false, options.camelCaseMatch, this); 1231 } 1214 1232 1215 1233 // Show constructors and opCalls … … 1568 1586 1569 1587 isCompletingPackage = true; 1570 nameEnvironment.findCompilationUnits(fqn, this); 1588 if (fqn.length > 0) { 1589 nameEnvironment.findCompilationUnits(fqn, this); 1590 } 1571 1591 } 1572 1592 … … 1667 1687 proposal.setCompletion(CharOperation.NO_CHAR); 1668 1688 } else { 1669 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 1670 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 1671 } else { 1672 proposal.setCompletion(currentName); 1673 } 1689 handleMethodCompletion(proposal, currentName); 1674 1690 } 1675 1691 … … 2305 2321 handleContextInfo(func, funcNameIsOpCall, proposal); 2306 2322 } else { 2307 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 2308 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); 2309 } else { 2310 proposal.setCompletion(currentName); 2311 } 2323 handleMethodCompletion(proposal, currentName); 2312 2324 } 2313 2325 } else { … … 2316 2328 handleContextInfo(func, funcNameIsOpCall, proposal); 2317 2329 } else { 2318 if (!isBetweenMethodName && parser.completionTokenEnd == this.actualCompletionPosition) { 2319 proposal.setCompletion(CharOperation.concat(ident, "()".toCharArray())); 2320 } else { 2321 proposal.setCompletion(ident); 2322 } 2330 handleMethodCompletion(proposal, ident); 2323 2331 } 2324 2332 } … … 2351 2359 } 2352 2360 2361 private void handleMethodCompletion(CompletionProposal proposal, char[] ident) { 2362 if (isBetweenMethodName) { 2363 if (parser.completionToken != null && parser.completionTokenEnd == actualCompletionPosition) { 2364 proposal.setCompletion(CharOperation.concat(ident, parenthesis)); 2365 } else { 2366 proposal.setCompletion(ident); 2367 } 2368 } else { 2369 proposal.setCompletion(CharOperation.concat(ident, parenthesis)); 2370 } 2371 } 2372 2353 2373 private void handleContextInfo(FuncDeclaration func, boolean funcNameIsOpCall, CompletionProposal proposal) { 2354 2374 proposal.setCompletion(CharOperation.NO_CHAR); … … 3147 3167 relevance += R_METHOD; 3148 3168 3149 proposal.setCompletion(CharOperation.concat(fullName, "".toCharArray()));3169 handleMethodCompletion(proposal, fullName); 3150 3170 3151 3171 proposal.setName(name); trunk/descent.core/src/descent/internal/compiler/parser/ASTNodeEncoder.java
r1141 r1148 11 11 public class ASTNodeEncoder { 12 12 13 // private final static char INTEGER_EXP = '=';14 // private final static char IDENTIFIER_EXP = '?';13 private char[] nastyChar = { '/' }; 14 private char[] nastyCharSoltuion = { '*', '!', '_', '!', '*' }; 15 15 16 16 private Parser parser; … … 29 29 } 30 30 31 // TODO horrible hack: the indexer may get consufed if the expression has 32 // the '/' character in it, so replace it with some very improbable 33 // string, and then replace it back later 34 35 private char[] encoderForIndexer(char[] value) { 36 if (CharOperation.indexOf('/', value) != -1) { 37 return CharOperation.replace(value, nastyChar, nastyCharSoltuion); 38 } else { 39 return value; 40 } 41 } 42 43 private char[] decodeForIndexer(char[] value) { 44 if (CharOperation.indexOf(nastyCharSoltuion, value, false) != -1) { 45 return CharOperation.replace(value, nastyCharSoltuion, nastyChar); 46 } else { 47 return value; 48 } 49 } 50 31 51 public char[] encodeExpression(Expression value) { 32 52 if (value == null) { … … 34 54 } 35 55 36 // Optimize for IntegerExp and IdentifierExp, which are the most common cases 37 // if (value instanceof IntegerExp) { 38 // StringBuilder sb = new StringBuilder(); 39 // sb.append(INTEGER_EXP); 40 // sb.append(((IntegerExp) value).value.toString()); 41 // return sb.toString().toCharArray(); 42 // } else if (value instanceof IdentifierExp) { 43 // StringBuilder sb = new StringBuilder(); 44 // sb.append(IDENTIFIER_EXP); 45 // sb.append(((IdentifierExp) value).ident); 46 // return sb.toString().toCharArray(); 47 // } else { 48 return value.toString().toCharArray(); 49 // } 56 char[] result = value.toString().toCharArray(); 57 return encoderForIndexer(result); 50 58 } 51 59 … … 55 63 } 56 64 57 // Optimize for IntegerExp and IdentifierExp, which are the most common cases 58 // if (value[0] == INTEGER_EXP) { 59 // return new IntegerExp(Loc.ZERO, new integer_t(new BigInteger(new String(value, 1, value.length - 1)))); 60 // } else if (value[0] == IDENTIFIER_EXP) { 61 // return new IdentifierExp(CharOperation.subarray(value, 1, value.length)); 62 // } 65 value = decodeForIndexer(value); 63 66 64 67 return initParser(value).parseExpression(); … … 74 77 } 75 78 76 return init.toString().toCharArray(); 79 char[] result = init.toString().toCharArray(); 80 return encoderForIndexer(result); 77 81 } 78 82 … … 88 92 } 89 93 90 // Optimize for IntegerExp and IdentifierExp, which are the most common cases 91 // if (value[0] == INTEGER_EXP || value[0] == IDENTIFIER_EXP) { 92 // return new ExpInitializer(Loc.ZERO, decodeExpression(value)); 93 // } 94 value = decodeForIndexer(value); 94 95 95 96 return initParser(value).parseInitializer(); trunk/descent.core/src/descent/internal/compiler/parser/ISignatureConstants.java
r1092 r1148 13 13 char ENUM = 'E'; 14 14 char ENUM_MEMBER = '~'; 15 char VARIABLE = ' /';15 char VARIABLE = '¡'; 16 16 char ALIAS = '='; 17 17 char TYPEDEF = 'T'; trunk/descent.core/src/descent/internal/core/search/matching/FieldPattern.java
r1145 r1148 167 167 this.declarationStart = -1; 168 168 } else { 169 slash = CharOperation.indexOf(SEPARATOR, key, start); 170 // TODO optimize this 171 this.declarationStart = Integer.parseInt(new String(CharOperation.subarray(key, start, slash))); 169 this.declarationStart = 0; 170 for (; key[start] != SEPARATOR; start++) { 171 declarationStart = 10 * declarationStart + (key[start] - '0'); 172 } 173 slash = start; 172 174 } 173 175 trunk/descent.core/src/descent/internal/core/search/matching/MethodPattern.java
r1132 r1148 166 166 this.declarationStart = -1; 167 167 } else { 168 slash = CharOperation.indexOf(SEPARATOR, key, start); 169 // TODO optimize this 170 this.declarationStart = Integer.parseInt(new String(CharOperation.subarray(key, start, slash))); 168 this.declarationStart = 0; 169 for (; key[start] != SEPARATOR; start++) { 170 declarationStart = 10 * declarationStart + (key[start] - '0'); 171 } 172 slash = start; 171 173 } 172 174 trunk/descent.core/src/descent/internal/core/search/matching/TypeDeclarationPattern.java
r1132 r1148 198 198 this.declarationStart = -1; 199 199 } else { 200 slash = CharOperation.indexOf(SEPARATOR, key, start); 201 // TODO optimize this 202 this.declarationStart = Integer.parseInt(new String(CharOperation.subarray(key, start, slash))); 200 this.declarationStart = 0; 201 for (; key[start] != SEPARATOR; start++) { 202 declarationStart = 10 * declarationStart + (key[start] - '0'); 203 } 204 slash = start; 203 205 } 204 206 trunk/descent.ui/src/descent/internal/ui/text/java/LazyJavaMethodCompletionProposal.java
r1147 r1148 116 116 117 117 if (!hasParameters() || !hasArgumentList()) { 118 setCursorPosition(replacement.length() + (getVariadic() != IMethod.VARARGS_NO ? 1 : 2)); 119 // if (replacement.length() > 0) { 120 // return replacement + "()"; //$NON-NLS-1$ 121 // } else { 118 if (fProposal.getCompletion().length > 0 && fProposal.getCompletion()[fProposal.getCompletion().length - 1] == ')') { 119 return replacement + "()"; //$NON-NLS-1$ 120 } else { 121 boolean variadic = getVariadic() != IMethod.VARARGS_NO; 122 setCursorPosition(replacement.length() + (variadic ? 1 : 2)); 122 123 return replacement; 123 //}124 } 124 125 } 125 126 … … 377 378 } else { 378 379 // Before the last ) 379 fSelectedRegion= new Region(baseOffset + replacement.length() + offsetAdded - ( getVariadic() != IMethod.VARARGS_NO ? 1 : 0), 0);380 fSelectedRegion= new Region(baseOffset + replacement.length() + offsetAdded - (replacement.endsWith(")") && getVariadic() != IMethod.VARARGS_NO ? 1 : 0), 0); //$NON-NLS-1$ 380 381 } 381 382
