Changeset 37
- Timestamp:
- 06/05/08 18:57:43 (7 months ago)
- Files:
-
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/contentProposer/AS3ContentProposer.java (modified) (4 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3KWLexer.gi (modified) (2 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g (modified) (11 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java (modified) (5 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3LabelProvider.java (modified) (4 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3TreeModelBuilder.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/contentProposer/AS3ContentProposer.java
r31 r37 32 32 if (decl instanceof VariableDeclarator) 33 33 return ((VariableDeclarator) decl).getName().toString(); 34 else if (decl instanceof Method Header)35 return ((Method Header) decl).getName().toString();34 else if (decl instanceof MethodDeclaration) 35 return ((MethodDeclaration) decl).getName().toString(); 36 36 return ""; 37 37 } … … 43 43 string = ((VariableDeclarator) decl).getName().toString() + " (" 44 44 + ((VariableDeclarator) decl).getType().toString() + ")"; 45 } else if (decl instanceof Method Header) {46 Method Header fdecl = (MethodHeader) decl;45 } else if (decl instanceof MethodDeclaration) { 46 MethodDeclaration fdecl = (MethodDeclaration) decl; 47 47 FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 48 48 string = fdecl.getReturnType().toString() + " " … … 64 64 } else if (decl instanceof MethodDeclaration) { 65 65 MethodDeclaration fdecl = (MethodDeclaration) decl; 66 FormalParameterList parameters = fdecl.get MethodHeader().getParameterBlock().getParameters();66 FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 67 67 String newText; 68 68 69 newText = fdecl.get MethodHeader().getName().toString()69 newText = fdecl.getName().toString() 70 70 + "("; 71 71 for (int i = 0; i < parameters.size(); i++) … … 73 73 + (i < parameters.size() - 1 ? ", " : ""); 74 74 newText += ")"; 75 String proposal = fdecl.get MethodHeader().getReturnType().toString()75 String proposal = fdecl.getReturnType().toString() 76 76 + " " + newText; 77 77 return new SourceProposal(proposal, newText, prefix, offset); axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3KWLexer.gi
r31 r37 23 23 package import class interface 24 24 public private protected internal static dynamic override 25 final enumerable explicit intrinsic 25 26 extends implements function var const 26 27 if else for each in while do … … 108 109 $EndAction 109 110 ./ 110 111 Keyword ::= f i n a l 112 /.$BeginAction 113 $setResult($_final); 114 $EndAction 115 ./ 116 Keyword ::= e n u m e r a b l e 117 /.$BeginAction 118 $setResult($_enumerable); 119 $EndAction 120 ./ 121 Keyword ::= e x p l i c i t 122 /.$BeginAction 123 $setResult($_explicit); 124 $EndAction 125 ./ 126 Keyword ::= i n t r i n s i c 127 /.$BeginAction 128 $setResult($_intrinsic); 129 $EndAction 130 ./ 111 131 Keyword ::= e x t e n d s 112 132 /.$BeginAction axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g
r36 r37 35 35 package import class interface 36 36 public private protected internal static dynamic override 37 final enumerable explicit intrinsic 37 38 extends implements function var const 38 39 if else for each in while do … … 134 135 ObjectLiteralField$ObjectLiteralField ::= %empty 135 136 136 ObjectLiteralFieldName ::= IDENTIFIER$Token | INTEGER_LITERAL$Token137 ObjectLiteralFieldName$ObjectLiteralFieldName ::= IDENTIFIER$Token | INTEGER_LITERAL$Token 137 138 138 139 -- types 139 140 Type ::= Name 140 141 TypeList$$Type ::= Type | TypeList COMMA Type 142 OptType ::= Type | STAR 141 143 142 144 -- names … … 149 151 public IAst getDeclaration() { return decl; } 150 152 ./ 153 QIdent$QIdent ::= NamespaceMod DBL_COLON$ Ident 151 154 152 155 -- cunit … … 161 164 TypeSpaceEntry ::= ClassDeclaration 162 165 TypeSpaceEntry ::= InterfaceDeclaration 166 TypeSpaceEntry ::= NamespaceDeclaration 163 167 TypeSpaceEntry ::= FieldDeclaration 164 168 TypeSpaceEntry ::= MethodDeclaration … … 182 186 183 187 SemiOpt ::= SEMI 188 189 184 190 -- mods 185 191 Modifiers$$Modifier ::= %empty | Modifiers Modifier 186 187 Modifier$Modifier ::= public | private | protected | static | internal | dynamic | override 192 Modifier ::= NamespaceMod | OtherMod 193 OtherMod$OtherMod ::= static$Token | final$Token | enumerable$Token | explicit$Token 194 | intrinsic$Token | dynamic$Token | override$Token 195 196 NamespaceMod ::= CustomNamespace | ReservedNamespace 197 ReservedNamespace$ReservedNamespace ::= public$Token | private$Token | protected$Token | internal$Token 198 CustomNamespace ::= IDENTIFIER$Name 199 188 200 -- anno 189 201 Annotations$$Annotations ::= %empty | Annotations Annotation … … 210 222 211 223 ClassMemberDeclaration ::= FieldDeclaration 212 ClassMemberDeclaration ::= ConstantDeclaration213 ClassMemberDeclaration ::= ConstructorDeclaration214 224 ClassMemberDeclaration ::= MethodDeclaration 225 ClassMemberDeclaration ::= NamespaceDeclaration 215 226 216 227 ClassMemberDeclaration$EmptyDeclaration ::= SEMI$ 217 228 218 -- class members 219 FieldDeclaration$FieldDeclaration ::= Annotations Modifiers var VariableDeclarators SEMI 220 ConstantDeclaration$ConstantDeclaration ::= Annotations Modifiers const VariableDeclarators SEMI 229 -- class members 230 NamespaceDeclaration$NamespaceDeclaration ::= Modifiers namespace IDENTIFIER$Name 231 NamespaceDeclaration$NamespaceDeclaration ::= Modifiers namespace IDENTIFIER$Name ASSIGN$ Expression$Initializer 232 233 FieldDeclaration$FieldDeclaration ::= Annotations Modifiers FieldType VariableDeclarators SemiOpt 234 235 FieldType$FieldType ::= var$Token | const$Token 221 236 222 237 VariableDeclarators$$VariableDeclarator ::= VariableDeclarator | VariableDeclarators COMMA VariableDeclarator 223 224 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ Type 225 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ STAR$Dyn 226 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ Type ASSIGN$ Expression$Initializer 227 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ STAR$Dyn ASSIGN$ Expression$Initializer 228 229 MethodDeclaration$MethodDeclaration ::= MethodHeader MethodBody 230 /. 238 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ OptType$Type 239 VariableDeclarator$VariableDeclarator ::= IDENTIFIER$Name COLON$ OptType$Type ASSIGN$ Expression$Initializer 240 241 MethodDeclaration$MethodDeclaration ::= Annotations Modifiers function$ AccessorRole IDENTIFIER$Name ParameterBlock ReturnType MethodBody 242 /. 243 public boolean isConstructor = false; 231 244 $action_type.SymbolTable symbolTable; 232 245 public void setSymbolTable($action_type.SymbolTable symbolTable) { this.symbolTable = symbolTable; } 233 246 public $action_type.SymbolTable getSymbolTable() { return symbolTable; } 234 247 ./ 235 236 ConstructorDeclaration$ConstructorDeclaration ::= ConstructorHeader MethodBody 237 /. 238 $action_type.SymbolTable symbolTable; 239 public void setSymbolTable($action_type.SymbolTable symbolTable) { this.symbolTable = symbolTable; } 240 public $action_type.SymbolTable getSymbolTable() { return symbolTable; } 241 ./ 242 243 MethodHeader ::= Annotations Modifiers function$ SetOrGet IDENTIFIER$Name ParameterBlock COLON ReturnType 244 245 SetOrGet ::= %empty | set$Token | get$Token 246 247 ReturnType$ReturnType ::= Type | void$ | STAR$Dyn 248 249 ConstructorHeader ::= Modifiers function$ IDENTIFIER$Name ParameterBlock 248 AccessorRole$AccessorRole ::= %empty | set$Token | get$Token 249 ReturnType$ReturnType ::= %empty | COLON$ OptType | COLON$ void$ 250 250 251 251 252 ParameterBlock$ParameterBlock ::= LPAREN$ RPAREN$ … … 276 277 277 278 InterfaceMemberDeclarations$$InterfaceMemberDeclaration ::= InterfaceMemberDeclaration | InterfaceMemberDeclarations InterfaceMemberDeclaration 278 279 InterfaceMemberDeclaration$MethodDeclaration ::= MethodHeader SEMI$ 280 279 InterfaceMemberDeclaration$MethodDeclaration ::= Annotations Modifiers function$ IDENTIFIER$Name ParameterBlock ReturnType SemiOpt$ 281 280 InterfaceMemberDeclaration$EmptyDeclaration ::= SEMI$ 281 InterfaceMemberDeclaration ::= NamespaceDeclaration 282 282 283 283 -- block … … 389 389 ThrowStatement$ThrowStatement ::= throw$ Expression SemiOpt$ 390 390 391 392 391 -- expressions 393 Primary ::= Literal392 Primary$Primary ::= Literal 394 393 | MethodInvocation 395 394 | ArrayAccess … … 402 401 | ObjectLiteral 403 402 | FunctionExpression 403 | QIdent 404 404 405 405 FunctionExpression$FunctionExpression ::= function$ ParameterBlock COLON$ ReturnType Block … … 419 419 ElementList$$Expression ::= Expression 420 420 | ElementList COMMA Expression 421 421 422 FieldAccess$FieldAccess ::= QIdent | Ident 422 423 FieldAccess$FieldAccess ::= Primary$Base DOT$ Ident 423 424 424 425 MethodInvocation ::= MethodReference Arguments 425 426 426 MethodReference$MethodReference ::= Ident 427 MethodReference$MethodReference ::= Name$Base DOT$ Ident 427 MethodReference$MethodReference ::= QIdent | Ident 428 428 MethodReference$MethodReference ::= Primary$Base DOT$ Ident 429 429 … … 539 539 if (n instanceof MethodDeclaration) 540 540 return ((MethodDeclaration) n).getSymbolTable(); 541 if (n instanceof ConstructorDeclaration)542 return ((ConstructorDeclaration) n).getSymbolTable();543 541 if (n instanceof ClassBody) 544 542 return ((ClassBody) n).getSymbolTable(); axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java
r31 r37 1 1 package org.axdt.as3.imp.parser; 2 2 3 import lpg.runtime.IAst; 3 4 import lpg.runtime.ILexStream; 4 5 import lpg.runtime.IPrsStream; … … 12 13 import org.axdt.as3.imp.parser.Ast.Block; 13 14 import org.axdt.as3.imp.parser.Ast.ClassBody; 14 import org.axdt.as3.imp.parser.Ast.ConstructorDeclaration; 15 import org.axdt.as3.imp.parser.Ast.ConstructorHeader; 15 import org.axdt.as3.imp.parser.Ast.CustomNamespace; 16 16 import org.axdt.as3.imp.parser.Ast.ExpressionStatement; 17 import org.axdt.as3.imp.parser.Ast.FieldDeclaration; 17 18 import org.axdt.as3.imp.parser.Ast.FormalParameter; 18 import org.axdt.as3.imp.parser.Ast.FormalParameterList;19 19 import org.axdt.as3.imp.parser.Ast.FunctionExpression; 20 20 import org.axdt.as3.imp.parser.Ast.InterfaceBody; 21 21 import org.axdt.as3.imp.parser.Ast.MethodDeclaration; 22 import org.axdt.as3.imp.parser.Ast.MethodHeader;23 22 import org.axdt.as3.imp.parser.Ast.PackageBody; 24 23 import org.axdt.as3.imp.parser.Ast.VariableDeclarator; … … 110 109 111 110 public boolean visit(MethodDeclaration n) { 112 MethodHeader hr = n.getMethodHeader(); 113 IToken id = hr.getName().getIToken(); 111 IToken id = n.getName().getIToken(); 114 112 SymbolTable symbol_table = peekTable(); 115 113 String name = id.toString(); 116 if ( hr.getSetOrGet()!= null) {117 name = hr.getSetOrGet().toString() +" "+ name;114 if (n.getAccessorRole()!= null) { 115 name = n.getAccessorRole().toString() +" "+ name; 118 116 } 119 if (!symbol_table.create(name, hr)) 117 for (Object o:n.getModifiers().getArrayList()) { 118 if (o instanceof CustomNamespace) { 119 name = o.toString() + "::" + name; 120 break; 121 } 122 } 123 if (!symbol_table.create(name, n)) 120 124 emitError(id, "Illegal redeclaration of " + name); 121 125 // Add a symbol table for the parameters … … 129 133 } 130 134 131 public boolean visit(ConstructorDeclaration n) {132 ConstructorHeader hr = n.getConstructorHeader();133 IToken id = hr.getName().getIToken();134 SymbolTable symbol_table = peekTable();135 String name = id.toString();136 137 if (!symbol_table.create(name, hr))138 emitError(id, "Illegal redeclaration of " + name);139 //140 // Add a symbol table for the parameters141 symbol_table = parser.new SymbolTable(symbol_table);142 symbol_table = pushNewTable();143 n.setSymbolTable(symbol_table);144 return true;145 }146 147 public void endVisit(ConstructorDeclaration n) {148 parser.symbolTableStack.pop();149 }150 151 135 public boolean visit(FunctionExpression n) { 152 136 n.setSymbolTable(pushNewTable()); … … 176 160 @Override 177 161 public boolean visit(VariableDeclarator n) { 162 IAst parent = n.getParent().getParent(); 178 163 String name = n.getName().toString(); 164 if (parent instanceof FieldDeclaration) { 165 FieldDeclaration f = (FieldDeclaration) parent; 166 for (Object o:f.getModifiers().getArrayList()) { 167 if (o instanceof CustomNamespace) { 168 name = o.toString() + "::" + name; 169 break; 170 } 171 } 172 } 179 173 if (!peekTable().create(name, n)) 180 174 emitError(n, "Illegal redeclaration of " + name); axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3LabelProvider.java
r31 r37 105 105 if (n instanceof InterfaceDeclaration) 106 106 return OUTLINE_INTERFACE_IMAGE; 107 if (n instanceof ConstructorDeclaration) {108 ModifierList modifiers = ((ConstructorDeclaration)n).getConstructorHeader().getModifiers();109 if (modifiers!=null) {110 for (Object m:modifiers.getArrayList()) {111 if (m instanceof Modifier) {112 Modifier mod = (Modifier) m;113 if ("private".equals(mod.toString()))114 return OUTLINE_PRIVATE_CONSTRUCTOR_IMAGE;115 }116 }117 }118 return OUTLINE_PUBLIC_CONSTRUCTOR_IMAGE;119 }120 107 if (n instanceof VariableDeclarator) { 121 108 IAst parent = ((VariableDeclarator)n).getParent().getParent(); … … 124 111 if (modifiers!=null) { 125 112 for (Object m:modifiers.getArrayList()) { 126 if (m instanceof Modifier) { 127 Modifier mod = (Modifier) m; 128 if ("private".equals(mod.toString())) 113 if (m instanceof IReservedNamespace) { 114 if ("private".equals(m.toString())) 129 115 return OUTLINE_PRIVATE_FIELD_IMAGE; 130 116 } … … 135 121 } 136 122 if (n instanceof MethodDeclaration) { 137 ModifierList modifiers = ((MethodDeclaration)n).getMethodHeader().getModifiers(); 123 MethodDeclaration method = (MethodDeclaration)n; 124 ModifierList modifiers = method.getModifiers(); 138 125 if (modifiers!=null) { 139 126 for (Object m:modifiers.getArrayList()) { 140 if (m instanceof Modifier) { 141 Modifier mod = (Modifier) m; 142 if ("private".equals(mod.toString())) 127 if (m instanceof IReservedNamespace) { 128 if ("private".equals(m.toString())) { 129 if (method.isConstructor) 130 return OUTLINE_PRIVATE_CONSTRUCTOR_IMAGE; 143 131 return OUTLINE_PRIVATE_METHOD_IMAGE; 132 } 144 133 } 145 134 } 146 135 } 136 if (method.isConstructor) 137 return OUTLINE_PUBLIC_CONSTRUCTOR_IMAGE; 147 138 return OUTLINE_PUBLIC_METHOD_IMAGE; 148 139 } … … 170 161 return ((VariableDeclarator)n).getName().toString(); 171 162 if (n instanceof MethodDeclaration){ 172 Method Header header = ((MethodDeclaration)n).getMethodHeader();173 if ( header.getSetOrGet()!=null)174 return header.getSetOrGet().toString() +" "+ header.getName().toString();175 return header.getName().toString();163 MethodDeclaration method = (MethodDeclaration)n; 164 if (method.getAccessorRole()!=null) 165 return method.getAccessorRole().toString() +" "+ method.getName().toString(); 166 return method.getName().toString(); 176 167 } 177 if (n instanceof ConstructorDeclaration)178 return ((ConstructorDeclaration)n).getConstructorHeader().getName().toString();179 168 if (n instanceof ClassDeclaration) 180 169 return ((ClassDeclaration)n).getName().toString(); axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/treeModelBuilder/AS3TreeModelBuilder.java
r31 r37 32 32 33 33 public boolean visit(MethodDeclaration n) { 34 createSubItem(n);35 return true;36 }37 38 public boolean visit(ConstructorDeclaration n) {39 34 createSubItem(n); 40 35 return true;
