Changeset 1137
- Timestamp:
- 04/29/08 19:29:49 (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) (9 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/AliasDeclaration.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/Dsymbol.java (modified) (1 diff)
- trunk/descent.core/src/descent/internal/compiler/parser/FuncDeclaration.java (modified) (4 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/SemanticMixin.java (modified) (2 diffs)
- trunk/descent.core/src/descent/internal/compiler/parser/TemplateDeclaration.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.core/src/descent/core/Signature.java
r1132 r1137 13 13 14 14 import java.util.ArrayList; 15 import java.util.EmptyStackException; 15 16 import java.util.List; 16 17 import java.util.Stack; … … 1827 1828 private char nextTemplateParameterName() { 1828 1829 // We don't care about crazy templates with more than 8 parameters 1829 return (char) ('T' + templateParameters.peek().size()); 1830 try { 1831 return (char) ('T' + templateParameters.peek().size()); 1832 } catch (EmptyStackException e) { 1833 System.out.println(1); 1834 return 'T'; 1835 } 1830 1836 } 1831 1837 @Override trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java
r1136 r1137 101 101 import descent.internal.compiler.parser.StringExp; 102 102 import descent.internal.compiler.parser.StructDeclaration; 103 import descent.internal.compiler.parser.SuperExp; 103 104 import descent.internal.compiler.parser.SwitchStatement; 104 105 import descent.internal.compiler.parser.SymOffExp; … … 259 260 boolean wantProperties = true; 260 261 boolean wantMethodContextInfo = false; 262 boolean isCompletingThisCall = false; 263 boolean isCompletingSuperCall = false; 261 264 262 265 Scope rootScope; … … 1216 1219 doSemantic(); 1217 1220 1221 if (node.sourceE1 instanceof SuperExp) { 1222 isCompletingSuperCall = true; 1223 } else if (node.sourceE1 instanceof ThisExp) { 1224 isCompletingThisCall = true; 1225 } 1226 1218 1227 if (node.e1 != null && node.e1.type != null) { 1219 1228 currentName = CharOperation.NO_CHAR; … … 1224 1233 VarExp var = (VarExp) node.e1; 1225 1234 if (var.var instanceof FuncDeclaration) { 1226 wantMethodContextInfo = true; 1227 suggestMember(var.var, false, 0, null, INCLUDE_FUNCTIONS); 1235 suggestContextInfo((FuncDeclaration) var.var); 1228 1236 } 1229 1237 } else if (node.e1 instanceof DotVarExp && node.e1.type instanceof TypeFunction) { 1230 1238 DotVarExp var = (DotVarExp) node.e1; 1231 1239 if (var.var instanceof FuncDeclaration) { 1232 wantMethodContextInfo = true; 1233 suggestMember(var.var, false, 0, null, INCLUDE_FUNCTIONS); 1240 suggestContextInfo((FuncDeclaration) var.var); 1234 1241 } 1235 1242 } else if (node.e1.type instanceof TypeFunction && node.e1.type.next != null) { 1236 1243 trySuggestCall(node.e1.type.next, currentName, CharOperation.NO_CHAR, false /* dosen't matter here */); 1237 1244 } else { 1238 // TODO check this1245 wantMethodContextInfo = true; 1239 1246 trySuggestCall(node.e1.type, currentName, CharOperation.NO_CHAR, false /* dosen't matter here */); 1240 1247 } 1241 1248 } else if (node.e1 instanceof CallExp && node.e1 != node) { 1242 1249 completeCallExp((CallExp) node.e1); 1250 } else if (node.e1 instanceof SuperExp) { 1251 1252 } 1253 } 1254 1255 private void suggestContextInfo(FuncDeclaration func) { 1256 int includes = func instanceof CtorDeclaration ? INCLUDE_CONSTRUCTORS : INCLUDE_FUNCTIONS; 1257 1258 wantMethodContextInfo = true; 1259 suggestMember(func, false, 0, null, includes); 1260 1261 Dsymbol prev = func.overprevious; 1262 while(prev != null) { 1263 suggestMember(prev, false, 0, null, includes); 1264 prev = prev.overprevious; 1265 } 1266 1267 Dsymbol next = func.overnext; 1268 while(next != null) { 1269 suggestMember(next, false, 0, null, includes); 1270 if (next instanceof FuncDeclaration) { 1271 next = ((FuncDeclaration) next).overnext; 1272 } else if (next instanceof AliasDeclaration) { 1273 next = ((AliasDeclaration) next).overnext; 1274 } else { 1275 break; 1276 } 1243 1277 } 1244 1278 } … … 1252 1286 endPosition = actualCompletionPosition; 1253 1287 1254 wantMethodContextInfo = true; 1255 suggestMember(node.member, false, 0, null, INCLUDE_CONSTRUCTORS); 1288 suggestContextInfo((FuncDeclaration) node.member); 1256 1289 } 1257 1290 } … … 1943 1976 1944 1977 semanticContext.allowOvernextBySignature = true; 1945 Declaration funcDecl = func.overnext ();1978 Declaration funcDecl = func.overnext; 1946 1979 if (funcDecl != null && funcDecl != sym) { 1947 1980 suggestMember(funcDecl, ident, onlyStatics, flags, funcSignatures, includes); … … 2257 2290 proposal.setName(currentName); 2258 2291 if (wantMethodContextInfo) { 2259 proposal.setCompletion(CharOperation.NO_CHAR);2292 handleContextInfo(func, funcNameIsOpCall, proposal); 2260 2293 } else { 2261 2294 proposal.setCompletion(CharOperation.concat(currentName, "()".toCharArray())); … … 2264 2297 proposal.setName(funcName); 2265 2298 if (wantMethodContextInfo) { 2266 proposal.setCompletion(CharOperation.NO_CHAR);2299 handleContextInfo(func, funcNameIsOpCall, proposal); 2267 2300 } else { 2268 2301 proposal.setCompletion(CharOperation.concat(ident, "()".toCharArray())); … … 2293 2326 } 2294 2327 return; 2328 } 2329 } 2330 } 2331 2332 private void handleContextInfo(FuncDeclaration func, boolean funcNameIsOpCall, CompletionProposal proposal) { 2333 proposal.setCompletion(CharOperation.NO_CHAR); 2334 if (funcNameIsOpCall || func instanceof CtorDeclaration) { 2335 if (isCompletingThisCall) { 2336 proposal.setName(TOK.TOKthis.charArrayValue); 2337 } else if (isCompletingSuperCall) { 2338 proposal.setName(TOK.TOKsuper.charArrayValue); 2339 } else { 2340 proposal.setName(func.parent.ident.ident); 2295 2341 } 2296 2342 } trunk/descent.core/src/descent/internal/compiler/parser/ASTDmdNode.java
r1118 r1137 463 463 next = fa.overnext; 464 464 } else if ((f = d.isFuncDeclaration()) != null) { 465 next = f.overnext ();465 next = f.overnext; 466 466 467 467 TypeFunction tf = (TypeFunction) f.type; … … 1400 1400 } 1401 1401 1402 next = f.overnext ();1402 next = f.overnext; 1403 1403 } 1404 1404 } trunk/descent.core/src/descent/internal/compiler/parser/AliasDeclaration.java
r1124 r1137 105 105 if (overnext == null) { 106 106 overnext = s; 107 s.overprevious = this; 107 108 return true; 108 109 } else { trunk/descent.core/src/descent/internal/compiler/parser/Dsymbol.java
r1136 r1137 64 64 public Dsymbol parent; 65 65 public Loc loc; 66 public Dsymbol overprevious; // previous in overload list 66 67 67 68 public Dsymbol() { trunk/descent.core/src/descent/internal/compiler/parser/FuncDeclaration.java
r1128 r1137 625 625 return f; 626 626 } 627 next = f.overnext ();627 next = f.overnext; 628 628 } 629 629 } … … 647 647 } 648 648 overnext = a; 649 a.overprevious = this; 649 650 return true; 650 651 } … … 665 666 } 666 667 overnext = f; 668 f.overprevious = this; 667 669 return true; 668 670 } … … 1864 1866 } 1865 1867 1866 public Declaration overnext() {1867 return overnext;1868 }1869 1870 1868 public VarDeclaration vthis() { 1871 1869 return vthis; trunk/descent.core/src/descent/internal/compiler/parser/SemanticMixin.java
r1128 r1137 154 154 } 155 155 156 if (aThis instanceof FuncDeclaration ) {156 if (aThis instanceof FuncDeclaration && !(aThis.parent instanceof TemplateInstance)) { 157 157 aThis.type().appendSignature(sb); 158 158 } … … 175 175 sb.append(tempinst.name.ident); 176 176 177 if (aThis instanceof FuncDeclaration) { 178 aThis.type().appendSignature(sb); 179 } 180 177 181 appendTemplateParameters(tempdecl, sb); 178 182 trunk/descent.core/src/descent/internal/compiler/parser/TemplateDeclaration.java
r1128 r1137 687 687 688 688 beforePf.overnext = f; 689 f.overprevious = beforePf; 689 690 return true; 690 691 }
