Changeset 5c182b6e475d5851c54cdb2117f25af21723b62a
- Timestamp:
- 06/29/09 07:06:59 (14 months ago)
- Children:
- 8a0050b3611b877b0c6c480dc26f48d9afa9c369
- Parents:
- 2aa064d78a2c1162da70e2413b7c386278a1473d
- git-committer:
- mb0 <mb0@…> (06/29/09 07:06:59)
- Files:
-
- 5 added
- 2 removed
- 33 modified
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java (modified) (6 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java (modified) (1 diff)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/IndexingVisitorTest.java (added)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java (modified) (2 diffs)
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/AS3Plugin.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/analysis/AS3Analysis.java (added)
-
org.axdt.as3/src/org/axdt/as3/analysis/AS3TokenHelper.java (added)
-
org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java (modified) (9 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3LexHelper.java (modified) (6 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi (modified) (1 diff)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java (modified) (10 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g (modified) (11 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/DiagnoseVisitor.java (modified) (4 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/IndexingVisitor.java (deleted)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/ResolvingVisitor.java (modified) (12 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTable.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTableVisitor.java (deleted)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java (modified) (11 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3EditorService.java (modified) (3 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3SourceHelper.java (added)
-
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java (modified) (2 diffs)
-
org.axdt.as3/src/org/axdt/as3/util/AS3ASTUtil.java (modified) (4 diffs)
-
org.axdt.as3/src/org/axdt/as3/util/DocTrimmerUtil.java (added)
-
org.axdt.axdoc.model/model/AXDoc.ecore (modified) (3 diffs)
-
org.axdt.axdoc.model/model/AXDocXML.xsd (modified) (1 diff)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXDocPackage.java (modified) (14 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndex.java (modified) (2 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndexNode.java (modified) (2 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXLevel.java (modified) (8 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXDocPackageImpl.java (modified) (7 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXEntryImpl.java (modified) (6 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexImpl.java (modified) (8 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexNodeImpl.java (modified) (9 diffs)
-
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXRootImpl.java (modified) (4 diffs)
-
org.axdt.axdoc.test/src/org/axdt/axdoc/util/Index0rTest.java (modified) (1 diff)
-
org.axdt.axdoc/src/org/axdt/axdoc/util/AXDocParser.java (modified) (12 diffs)
-
org.axdt.axdoc/src/org/axdt/axdoc/util/Index0r.java (modified) (10 diffs)
-
org.axdt.common/src/org/axdt/util/IFlexErrorCodes.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java
rb32f7a4 r5c182b6 19 19 import org.axdt.as3.imp.parser.Ast.StringLiteral; 20 20 import org.axdt.as3.imp.parser.Ast.VariableDefinition; 21 import org.axdt.as3.imp.parser.ParseUtil.ParserContext; 21 22 22 23 public class BasicParserTest extends TestCase { 23 private AS3Parser parser;24 private ParserContext context; 24 25 private Program parse(String content) { 25 parser= ParseUtil.parser(content);26 return ParseUtil.parse(parser,0);26 context = ParseUtil.parser(content); 27 return context.parse(0); 27 28 } 28 29 private <T extends IDirective> T assertFirstDirective(String string, Class<T> clazz) { 29 parser= ParseUtil.parser(string);30 Program result = ParseUtil.parse(parser,0);30 context = ParseUtil.parser(string); 31 Program result = context.parse(0); 31 32 return assertFirstDirective(result, clazz); 32 33 } … … 38 39 } else { 39 40 // TODO gather some info 40 ArrayList tokens = parser.getIPrsStream().getTokens();41 ArrayList tokens = context.parser.getIPrsStream().getTokens(); 41 42 assertNotNull("parser error "+ tokens.toString(),prog); 42 43 } … … 79 80 80 81 // bom works just as expected 81 assertNotNull(parse("\u00ef\u00bb\u00bf package {}")); 82 prog = parse("\u00ef\u00bb\u00bf package {}"); 83 assertNotNull(prog); 82 84 System.out.print("expected"); 83 assertNull(parse("package \u00ef\u00bb\u00bf {}")); 85 prog = parse("package \u00ef\u00bb\u00bf {}"); 86 // when using parseActions used as unicode package name ?! 87 assertNull(prog); 84 88 85 89 prog = parse("package P{} package Q{}"); … … 93 97 System.out.print("expected"); 94 98 prog = parse("package P{} function f(){} package Q{}"); 99 // when using parseActions finds the first package but fails to parse the following directives 95 100 assertNull(prog); 96 101 } … … 157 162 def = assertFirstDirective("function f():void{}",FunctionDefinition.class); 158 163 159 def = assertFirstDirective("function f( b:B){a = b;a.c();}",FunctionDefinition.class);164 def = assertFirstDirective("function f(a:A,b:B){a = b;a.c();}",FunctionDefinition.class); 160 165 assertEquals("f", def.getName().toString()); 161 166 assertEquals(2, def.getBlock().getDirectives().size()); 162 167 FunctionCommon common = def.getCommon(); 163 168 assertEquals(null, common.getResultType()); 169 assertEquals(2, common.getParameters().size()); 164 170 165 171 def = assertFirstDirective("function f(){}",FunctionDefinition.class); … … 171 177 def = assertFirstDirective("function get f(i){}",FunctionDefinition.class); 172 178 def = assertFirstDirective("function get f(a:A,b:B){}",FunctionDefinition.class); 173 // TODO fix parameter declaration174 179 def = assertFirstDirective("function set(){}",FunctionDefinition.class); 175 180 def = assertFirstDirective("function get(a,b){}",FunctionDefinition.class); -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java
rb32f7a4 r5c182b6 122 122 assertExpression(parse("i..x"), Query.class); 123 123 assertExpression(parse("i..x::y"), Query.class); 124 assertExpression(parse("i.(@a::y.c)"), Query.class); 124 assertExpression(parse("i.(y,x)"), Query.class); 125 assertExpression(parse("i.(y)"), Query.class); 125 126 assertExpression(parse("i++"), PostIncrementExpression.class); 126 127 assertExpression(parse("i--"), PostDecrementExpression.class); 128 assertExpression(parse("i..(y)::id"), Query.class); 129 assertExpression(parse("i..@(y)::id"), Query.class); 130 assertExpression(parse("i..@[0]"), Query.class); 127 131 } 128 132 public void testNew() throws Exception { -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java
rb32f7a4 r5c182b6 20 20 } 21 21 public static Program parse(String content, int repair) { 22 AS3Parser parser= parser(content);23 return parse(parser,repair);22 ParserContext context = parser(content); 23 return context.parse(repair); 24 24 } 25 25 public static Program parse(AS3Parser parser, int repair) { … … 29 29 return null; 30 30 } 31 public static AS3Parserparser(String content) {31 public static ParserContext parser(String content) { 32 32 char[] charArray = content.toCharArray(); 33 AS3Lexer lexer = new AS3Lexer(); 34 lexer.reset(charArray, "name"); 35 AS3Parser parser = new AS3Parser(); 36 parser.reset(lexer.getILexStream()); 37 lexer.lexer(null, parser); 38 return parser; 33 ParserContext context = new ParserContext(charArray); 34 context.lex(); 35 return context; 36 } 37 public static class ParserContext { 38 public AS3Lexer lexer = new AS3Lexer(); 39 public AS3Parser parser = new AS3Parser(); 40 public boolean lexSuccess; 41 42 public ParserContext(char[] charArray) { 43 lexer.reset(charArray, "name"); 44 parser.reset(lexer.getILexStream()); 45 } 46 public Program parse(int repair) { 47 Object result = null; 48 if (lexSuccess) { 49 result = parser.parserActions(null, repair); 50 } else { 51 result = parser.parser(null, repair); 52 } 53 return result instanceof Program ? (Program) result : null; 54 } 55 public boolean lex() { 56 lexSuccess = lexer.lexer(null, parser); 57 return lexSuccess; 58 } 39 59 } 40 60 } -
org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java
rb32f7a4 r5c182b6 1 1 package org.axdt.as3.imp.parser; 2 2 3 import java.util.ArrayList; 4 3 5 import org.axdt.as3.imp.parser.Ast.Program; 6 import org.axdt.as3.imp.parser.ParseUtil.ParserContext; 4 7 5 8 import junit.framework.TestCase; 9 import lpg.runtime.IToken; 6 10 7 11 public class VirtualSemiTest extends TestCase { 8 12 9 public static Program parse(String content) { 10 return ParseUtil.parse(content, 0); 13 @SuppressWarnings("unchecked") 14 public void assertVSemiInsertion(String content, int expected) { 15 ParserContext context = ParseUtil.parser(content); 16 Program parse = context.parse(-1); 17 assertNotNull(parse); 18 ArrayList<IToken> tokens = context.parser.getIPrsStream().getTokens(); 19 int result = 0; 20 for (IToken t:tokens) { 21 if (t.getKind() == AS3Parsersym.TK_VirtualSemicolon) 22 result++; 23 } 24 assertEquals(expected, result); 11 25 } 12 26 public void testLineBreakVirtualSemi() throws Exception { 13 // TODOcheck that the parser should not insert v semi14 assert NotNull(parse("{var i = 0;\nvar j = 1;}"));15 // TODOdont insert if there is a semi16 assert NotNull(parse("{var i = 0\n;var j = 1;}"));17 assert NotNull(parse("{var i = 0\nvar j = 1;}"));27 // check that the parser should not insert v semi 28 assertVSemiInsertion("{var i = 0;\nvar j = 1;}",0); 29 // dont insert if there is a semi 30 assertVSemiInsertion("{var i = 0\n;var j = 1;}",0); 31 assertVSemiInsertion("{var i = 0\nvar j = 1;}",1); 18 32 } 19 33 public void testGrammarVirtualSemi() throws Exception { 20 34 // abbrev semi is inserted before RCURLY or EOF 21 assert NotNull(parse("var j = 1"));22 assert NotNull(parse("var j = 1;"));23 assert NotNull(parse("{var i = 0;var j = 1}"));35 assertVSemiInsertion("var j = 1",1); 36 assertVSemiInsertion("var j = 1;",0); 37 assertVSemiInsertion("{var i = 0;var j = 1}",1); 24 38 } 25 39 } -
org.axdt.as3/src/org/axdt/as3/AS3Plugin.java
r364575f r5c182b6 4 4 import java.net.URL; 5 5 6 import org.axdt.as3.imp.builders.AS3Builder; 6 7 import org.axdt.as3.imp.builders.AS3Nature; 7 8 import org.axdt.as3.preferences.AS3Preferences; 8 9 import org.axdt.as3.templates.AS3ContextType; 9 import org.axdt.axdoc.model.AXRoot Type;10 import org.axdt.axdoc.model.AXRoot; 10 11 import org.axdt.axdoc.util.Index0r; 11 12 import org.axdt.common.preferences.AxdtPreferences; 12 13 import org.eclipse.core.resources.IContainer; 13 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.core.resources.IncrementalProjectBuilder; 14 16 import org.eclipse.core.resources.ResourcesPlugin; 15 17 import org.eclipse.core.runtime.CoreException; 16 18 import org.eclipse.core.runtime.FileLocator; 17 19 import org.eclipse.core.runtime.IPath; 20 import org.eclipse.core.runtime.IProgressMonitor; 18 21 import org.eclipse.core.runtime.Path; 19 22 import org.eclipse.core.runtime.Status; 20 23 import org.eclipse.core.runtime.preferences.ConfigurationScope; 21 24 import org.eclipse.core.runtime.preferences.IScopeContext; 22 import org.eclipse.emf.common.util.URI;23 25 import org.eclipse.imp.runtime.PluginBase; 24 26 import org.eclipse.jface.preference.IPreferenceStore; … … 161 163 162 164 private void initializeIndex() { 165 IProgressMonitor monitor = null; 163 166 Index0r index0r = Index0r.getInstance(); 164 167 // asdoc locations are added on axdoc plugin start … … 172 175 } 173 176 IContainer[] paths = AS3Preferences.getSourcePaths(project); 177 boolean needsBuild = false; 174 178 for (IContainer srcPath:paths) { 175 179 if (!srcPath.exists()) continue; 176 String name = "source "+srcPath.getFullPath(); 177 URI uri = URI.createPlatformResourceURI(srcPath.getFullPath().toString(), true); 178 index0r.addRoot(name, uri.toString(), AXRootType.SOURCE); 180 AXRoot root = index0r.addSourceRoot(srcPath); 181 try { 182 needsBuild = needsBuild || root.eContents().isEmpty() && srcPath.members().length > 0; 183 } catch (CoreException e) {/* ignore */ } 184 index0r.saveRoot(root); 185 index0r.cachePackages(root); 186 } 187 if (needsBuild) { 188 try { 189 project.build(IncrementalProjectBuilder.FULL_BUILD, AS3Builder.BUILDER_ID, null, monitor); 190 } catch (CoreException e) { 191 log("error invoking initial build", e); 192 } 179 193 } 180 194 } -
org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java
r2aa064d r5c182b6 1 1 package org.axdt.as3.imp.builders; 2 2 3 import java.util.ArrayList;4 3 import java.util.Arrays; 4 import java.util.Collection; 5 import java.util.HashSet; 5 6 import java.util.List; 6 7 import java.util.Map; … … 8 9 import org.axdt.as3.AS3Plugin; 9 10 import org.axdt.as3.imp.parser.AS3ParseController; 11 import org.axdt.as3.imp.parser.ResolvingVisitor; 12 import org.axdt.as3.imp.parser.Ast.ASTNode; 10 13 import org.axdt.as3.preferences.AS3Preferences; 11 import org.axdt.as3.util.AS3Util;12 14 import org.axdt.axdoc.model.AXRoot; 13 15 import org.axdt.axdoc.util.Index0r; … … 16 18 import org.eclipse.core.resources.IProject; 17 19 import org.eclipse.core.resources.IResource; 20 import org.eclipse.core.resources.IResourceDelta; 21 import org.eclipse.core.resources.IResourceDeltaVisitor; 22 import org.eclipse.core.resources.IResourceVisitor; 23 import org.eclipse.core.resources.IncrementalProjectBuilder; 18 24 import org.eclipse.core.runtime.CoreException; 19 25 import org.eclipse.core.runtime.IPath; 20 26 import org.eclipse.core.runtime.IProgressMonitor; 27 import org.eclipse.core.runtime.SubProgressMonitor; 21 28 import org.eclipse.core.runtime.content.IContentDescription; 22 import org.eclipse.imp.builder.BuilderBase;23 29 import org.eclipse.imp.builder.BuilderUtils; 24 30 import org.eclipse.imp.builder.MarkerCreator; … … 28 34 import org.eclipse.imp.model.ModelFactory; 29 35 import org.eclipse.imp.model.ModelFactory.ModelException; 36 import org.eclipse.imp.parser.IMessageHandler; 30 37 import org.eclipse.imp.runtime.PluginBase; 31 38 import org.eclipse.imp.services.IAnnotationTypeInfo; … … 36 43 * "Build" a project. 37 44 */ 38 public class AS3Builder extends BuilderBase { 39 45 public class AS3Builder extends IncrementalProjectBuilder { 40 46 public static final String BUILDER_ID = AS3Plugin.PLUGIN_ID + ".imp.builder"; 41 47 public static final String PROBLEM_MARKER_ID = AS3Plugin.PLUGIN_ID + ".imp.builder.problem"; 42 48 public static final Language LANGUAGE = LanguageRegistry.findLanguage(AS3Plugin.LANGUAGE); 43 private boolean isFullBuild = false; 44 private List<AS3ParseController> astnodes; 45 46 public AS3Builder() { 47 super(); 48 } 49 50 protected Index0r fIndex0r; 51 protected Collection<IFile> fSourcesToCompile; 52 protected IContainer fDeployContainer; 53 protected IContainer[] fSourceContainer; 49 54 50 55 protected PluginBase getPlugin() { … … 56 61 } 57 62 58 protected String getWarningMarkerID() { 59 return PROBLEM_MARKER_ID; 60 } 61 62 protected String getInfoMarkerID() { 63 return PROBLEM_MARKER_ID; 64 } 65 66 /** 67 * Decide whether a file needs to be build using this builder. Note that 68 * <code>isNonRootSourceFile()</code> and <code>isSourceFile()</code> 69 * should never return true for the same file. 70 * 71 * @return true if an arbitrary file is a AS3 source file. 72 */ 73 protected boolean isSourceFile(IFile file) { 74 IPath path = file.getRawLocation(); 75 if (path == null || !LANGUAGE.hasExtension(path.getFileExtension())) 76 return false; 77 IContainer sourceFolder = AS3Util.getSourceFolder(file); 78 return sourceFolder != null; 79 } 80 81 /** 82 * Decide whether or not to scan a file for dependencies. Note: 83 * <code>isNonRootSourceFile()</code> and <code>isSourceFile()</code> 84 * should never return true for the same file. 85 * 86 * @return true if the given file is a source file that this builder should 87 * scan for dependencies, but not compile as a top-level compilation 88 * unit. 89 */ 90 protected boolean isNonRootSourceFile(IFile resource) { 91 return false; 92 } 93 94 /** 95 * Collects compilation-unit dependencies for the given file, and records 96 * them via calls to <code>fDependency.addDependency()</code>. 97 */ 98 protected void collectDependencies(IFile file) { 99 // TODO: implement dependency collector 100 // fDependencyInfo.addDependency(fromPath, uponPath); 101 } 102 103 /** 104 * @return true if this resource identifies the output folder 105 */ 106 protected boolean isOutputFolder(IResource resource) { 107 if (resource == null || !(resource instanceof IContainer)) return false; 108 return resource.equals(AS3Preferences.getDeployPath(resource)); 109 } 63 protected void initBuilder(int kind, Map args) { 64 fIndex0r = Index0r.getInstance(); 65 fSourcesToCompile = new HashSet<IFile>(); 66 fDeployContainer = AS3Preferences.getDeployPath(getProject()); 67 fSourceContainer = AS3Preferences.getSourcePaths(getProject()); 68 } 69 70 protected void clearBuilder() { 71 fIndex0r = null; 72 fSourcesToCompile = null; 73 fDeployContainer = null; 74 fSourceContainer = null; 75 } 76 110 77 @Override 111 78 @SuppressWarnings("unchecked") 112 79 protected IProject[] build(int kind, Map args, IProgressMonitor monitor) { 113 isFullBuild = kind == FULL_BUILD || kind == CLEAN_BUILD; 114 if (isFullBuild) { 115 Index0r index0r = Index0r.getInstance(); 116 IContainer[] srcFolders = AS3Preferences.getSourcePaths(getProject()); 117 for (IContainer srcFolder:srcFolders) { 118 AXRoot root = index0r.getSourceRoot(srcFolder); 119 index0r.clearRoot(root); 80 monitor.beginTask("Building",51); 81 try { 82 initBuilder(kind, args); 83 monitor.worked(1); 84 boolean isFullBuild = kind == FULL_BUILD || kind == CLEAN_BUILD; 85 SubProgressMonitor subMonitor = new SubProgressMonitor(monitor,50,SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); 86 if (isFullBuild) { 87 buildFull(args, subMonitor); 88 } else { 89 buildChanged(args, subMonitor); 120 90 } 121 astnodes = new ArrayList<AS3ParseController>(); 91 } finally { 92 clearBuilder(); 93 monitor.done(); 94 } 95 return new IProject[0]; 96 } 97 private void buildChanged(Map args, IProgressMonitor monitor) { 98 monitor.beginTask(" changed Resources", 11); 99 try { 100 IResourceDelta delta = getDelta(getProject()); 101 if (delta != null) { 102 delta.accept(new SourceDeltaVisitor()); 103 } else { 104 getProject().accept(new SourceCollectVisitor()); 105 } 106 monitor.worked(1); 107 SubProgressMonitor subMonitor = new SubProgressMonitor(monitor,10,SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); 108 compileNecessarySources(subMonitor); 109 } catch (CoreException e) { 110 AS3Plugin.getDefault().debug("Error collecting sources", e); 111 } finally { 112 monitor.done(); 113 } 114 } 115 116 private void buildFull(Map args, IProgressMonitor monitor) { 117 monitor.beginTask(" all Resources", 13); 118 try { 119 getProject().accept(new SourceCollectVisitor()); 120 monitor.worked(1); 121 clearIndex(); 122 monitor.worked(1); 122 123 // do the build. it should index the whole project 123 super.build(kind, args, monitor); 124 for (AS3ParseController control:astnodes) { 125 control.resolveDeclarations(control.getCurrentAst()); 126 } 127 astnodes = null; 124 SubProgressMonitor subMonitor = new SubProgressMonitor(monitor,10,SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); 125 compileNecessarySources(subMonitor); 128 126 // build done save and cache the index 129 for (IContainer srcFolder:srcFolders) { 130 AXRoot root = index0r.getSourceRoot(srcFolder); 131 index0r.saveRoot(root); 132 index0r.cachePackages(root); 133 } 134 return new IProject[0]; 135 } else { 136 // proceed with normal build 137 return super.build(kind, args, monitor); 138 } 139 } 127 cacheIndex(); 128 monitor.worked(1); 129 } catch (Exception e) { 130 AS3Plugin.getDefault().debug("Error collecting sources", e); 131 } finally { 132 monitor.done(); 133 } 134 } 135 protected void compileNecessarySources(IProgressMonitor monitor) { 136 monitor.beginTask("", fSourcesToCompile.size()*2); 137 try { 138 // first we lex and parse once without resolving or error reporting 139 for(IFile file : fSourcesToCompile) { 140 clearMarkersOn(file); 141 compile(file, new SubProgressMonitor(monitor,1), false); 142 } 143 // the second time the index is build and we can resolve after parsing 144 for(IFile file : fSourcesToCompile) { 145 clearMarkersOn(file); 146 compile(file, new SubProgressMonitor(monitor,1), true); 147 } 148 // the reason to parse the files twice is that caching is to expensive (mem peak) 149 // and cpu cycles cheap enough. the ideal solution would be a cheap and clean 150 // dependency analysis. 151 } finally { 152 monitor.done(); 153 } 154 } 155 156 protected void cacheIndex() { 157 for (IContainer srcFolder:fSourceContainer) { 158 AXRoot root = fIndex0r.getSourceRoot(srcFolder); 159 fIndex0r.saveRoot(root); 160 fIndex0r.cachePackages(root); 161 } 162 } 163 164 protected void clearIndex() { 165 for (IContainer folder:fSourceContainer) { 166 AXRoot root = fIndex0r.getSourceRoot(folder); 167 fIndex0r.clearRoot(root); 168 } 169 } 170 171 protected void clearMarkersOn(IFile file) { 172 try { 173 file.deleteMarkers(getErrorMarkerID(), true, IResource.DEPTH_INFINITE); 174 } catch (CoreException e) { 175 } 176 } 177 140 178 /** 141 179 * Compile one AS3 file. 142 180 * It will not actually compile, but analyze and index the model. 143 181 */ 144 protected void compile( final IFile file, IProgressMonitor monitor) {145 AS3ParseController parse = getParseController(file );182 protected void compile(IFile file, IProgressMonitor monitor, boolean resolve) { 183 AS3ParseController parse = getParseController(file, resolve); 146 184 // if controller could not be created or initialized 147 185 if (parse == null || parse.getProject() == null) 148 186 return; 187 monitor.beginTask("", 10); 188 try { 189 parse.parse(getContents(file), resolve, new SubProgressMonitor(monitor,10)); 190 } finally { 191 parse.dispose(); 192 monitor.done(); 193 } 194 } 195 196 protected String getContents(IFile file) { 149 197 String contents = BuilderUtils.getFileContents(file); 150 if (hasBom(file)) contents = removeBom(contents); 151 Object ast = parse.parse(contents, false, monitor); 152 if (ast != null && astnodes != null) { 153 astnodes.add(parse); 154 } 155 } 156 157 private String removeBom(String contents) { 198 return hasBom(file) ? removeBom(contents) : contents; 199 } 200 201 protected String removeBom(String contents) { 158 202 // first char might be misread utf8 char 159 203 return contents.charAt(0) == 0xfeff ? … … 161 205 } 162 206 163 pr ivateboolean hasBom(IFile file) {207 protected boolean hasBom(IFile file) { 164 208 try { 165 209 IContentDescription info = file.getContentDescription(); … … 170 214 171 215 @SuppressWarnings("unchecked") 172 pr ivate AS3ParseController getParseController(IFile file) {216 protected AS3ParseController getParseController(IFile file, boolean reportErrors) { 173 217 AS3ParseController controller = new AS3ParseController(); 174 IAnnotationTypeInfo typeInfo = controller.getAnnotationTypeInfo(); 218 addMarkerTypeOnce(controller.getAnnotationTypeInfo()); 219 IMessageHandler marker = reportErrors ? new MarkerCreator(file, controller, PROBLEM_MARKER_ID) 220 : null; 221 IPath relativePath = file.getProjectRelativePath(); 222 try { 223 ISourceProject sourceProject = ModelFactory.open(file.getProject()); 224 controller.initialize(relativePath, sourceProject, marker); 225 } catch (ModelException e) { 226 getPlugin().logException("Cannot create parse controller", e); 227 } 228 return controller; 229 } 230 private void addMarkerTypeOnce(IAnnotationTypeInfo typeInfo) { 175 231 List<List<String>> lists = Arrays.asList(typeInfo.getProblemMarkerTypes()); 176 232 boolean found = false; … … 182 238 } 183 239 if (!found) typeInfo.addProblemMarkerType(getErrorMarkerID()); 184 MarkerCreator marker = new MarkerCreator(file, controller, PROBLEM_MARKER_ID); 185 IPath relativePath = file.getProjectRelativePath(); 186 try { 187 ISourceProject sourceProject = ModelFactory.open(file.getProject()); 188 controller.initialize(relativePath, sourceProject, marker); 189 } catch (ModelException e) { 190 getPlugin().logException("Cannot create parse controller", e); 191 } 192 return controller; 193 } 194 @Override 195 protected void clearMarkersOn(IFile file) { 196 try { 197 file.deleteMarkers(getErrorMarkerID(), true, IResource.DEPTH_INFINITE); 198 } catch (CoreException e) { 199 } 200 //super.clearMarkersOn(file); 240 } 241 242 protected class SourceCollectVisitor implements IResourceVisitor { 243 public boolean visit(IResource resource) throws CoreException { 244 return processResource(resource, fSourcesToCompile); 245 } 246 } 247 protected class SourceDeltaVisitor implements IResourceDeltaVisitor { 248 public boolean visit(IResourceDelta delta) throws CoreException { 249 return processResource(delta.getResource(), fSourcesToCompile); 250 } 251 } 252 protected boolean processResource(IResource resource, Collection<IFile> result) { 253 if (resource instanceof IFile) { 254 IFile file = (IFile) resource; 255 if (isSourceFile(file)) result.add(file); 256 } else if (resource.equals(fDeployContainer)) { 257 return false; 258 } 259 return true; 260 } 261 public boolean isSourceFile(IFile file) { 262 if (file != null && file.exists() && LANGUAGE.hasExtension(file.getFileExtension())) 263 for (IContainer folder:fSourceContainer) 264 if (folder.getFullPath().isPrefixOf(file.getFullPath())) 265 return true; 266 return false; 201 267 } 202 268 } 269 class CustomResolvingVisitor extends ResolvingVisitor { 270 private ASTNode node; 271 public CustomResolvingVisitor(IFile myfile, ASTNode node) { 272 super(myfile, node.getLeftIToken().getILexStream()); 273 this.node = node; 274 } 275 public void run() { 276 node.accept(this); 277 } 278 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3LexHelper.java
rb32f7a4 r5c182b6 63 63 HelperAst ast = parseXml(offset); 64 64 return tryAst(ast, AS3Parsersym.TK_Xml); 65 } else 66 errorDetected(); 65 } 67 66 return false; 68 67 } … … 74 73 HelperAst ast = parseRegex(offset); 75 74 return tryAst(ast, AS3Parsersym.TK_RegularExpression); 76 } else 77 errorDetected(); 75 } 78 76 return false; 79 77 } … … 84 82 prs.makeToken(ast.start, ast.end, kind); 85 83 lexer.getParser().resetTokenStream(ast.end + 1); 84 prs.reset(ast.end + 1); 86 85 return true; 87 86 } … … 146 145 boolean isNewLine = detectedLineBreak; 147 146 detectedLineBreak = false; 148 if (hasError(kind)) { 149 int lastKind = getKind(getLast()); 150 switch (kind) { 151 case AS3Parsersym.TK_LPAREN: 152 if (lastKind == AS3Parsersym.TK_get 153 || lastKind == AS3Parsersym.TK_set) { 154 parser.errorReset(); 155 getLast().setKind(AS3Parsersym.TK_IDENTIFIER); 156 } 147 boolean checkAgain = true; 148 int lastKind = getKind(getLast()); 149 boolean found = false; 150 switch (kind) { 151 case AS3Parsersym.TK_get: 152 case AS3Parsersym.TK_set: 153 if (lastKind == AS3Parsersym.TK_function) { 154 int c = lex.getIntValue(e+1); 155 for (int i=e+2;Character.isWhitespace(c);i++) { 156 // TODO: also skip comments 157 c = lex.getCharValue(i); 158 } 159 if (Character.isJavaIdentifierStart(c)) { 160 break; 161 } 162 } 163 found = true; 164 case AS3Parsersym.TK_namespace: 165 case AS3Parsersym.TK_each: 166 case AS3Parsersym.TK_include: 167 case AS3Parsersym.TK_xml: 168 if (!found && !hasError(kind)) { 169 checkAgain = false; 157 170 break; 158 case AS3Parsersym.TK_get: 159 case AS3Parsersym.TK_set: 160 if (getKind(getLast()) == AS3Parsersym.TK_function) { 161 break; 162 } 163 case AS3Parsersym.TK_each: 164 case AS3Parsersym.TK_namespace: 165 case AS3Parsersym.TK_include: 166 case AS3Parsersym.TK_xml: 167 if (!hasError(AS3Parsersym.TK_IDENTIFIER)) { 168 kind = AS3Parsersym.TK_IDENTIFIER; 169 } 170 break; 171 } 171 } 172 if (!hasError(AS3Parsersym.TK_IDENTIFIER)) { 173 checkAgain = false; 174 kind = AS3Parsersym.TK_IDENTIFIER; 175 } 176 } 177 if (checkAgain && hasError(kind)) { 172 178 if (isNewLine) { 173 179 // line-break semicolon insertion … … 183 189 int end = getLast().getEndOffset(); 184 190 prs.makeToken(end + 1, end, AS3Parsersym.TK_NO_LINE_BREAK); 185 } else186 errorDetected();187 }191 } 192 } 193 if (tryXmlOrRegex(kind,s)) return; 188 194 if (hasError(kind)) 189 195 errorDetected(); 190 } 196 } else if (tryXmlOrRegex(kind, s)) { 197 return; 198 } 199 prs.makeToken(s, e, kind); 200 } 201 private boolean tryXmlOrRegex(int kind, int s) { 191 202 switch (kind) { 192 203 // check for xml 193 204 case AS3Parsersym.TK_LT: 194 if (tryXml(s)) 195 return; 196 else 197 break; 205 return tryXml(s); 198 206 // check for regex 199 207 case AS3Parsersym.TK_DIV: 200 208 case AS3Parsersym.TK_DIV_ASSIGN: 201 if (tryRegex(s)) 202 return; 203 else 204 break; 205 } 206 prs.makeToken(s, e, kind); 207 } 208 209 return tryRegex(s); 210 } 211 return false; 212 } 209 213 private void tryToInsertSemicolon() { 210 214 if (!hasError(AS3Parsersym.TK_VirtualSemicolon)) { … … 212 216 prs.makeToken(end + 1, end, AS3Parsersym.TK_VirtualSemicolon); 213 217 insertedVirtualSemicolons++; 214 } else 215 errorDetected(); 218 } 216 219 } 217 220 -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi
rb32f7a4 r5c182b6 632 632 lexParser.parseCharacters(monitor); 633 633 make.eof(); 634 return !make.detectedError; 634 boolean hadErrors = make.detectedError; 635 make = null; 636 return !hadErrors; 635 637 } 636 638 public int [] getKeywordKinds() { -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java
rb32f7a4 r5c182b6 4 4 import java.util.Iterator; 5 5 6 import lpg.runtime.IAst;7 8 6 import org.axdt.as3.AS3Plugin; 7 import org.axdt.as3.analysis.AS3Analysis; 9 8 import org.axdt.as3.imp.parser.Ast.ASTNode; 10 9 import org.axdt.as3.imp.services.AS3SyntaxProperties; 11 10 import org.eclipse.core.runtime.IPath; 12 11 import org.eclipse.core.runtime.IProgressMonitor; 13 import org.eclipse.core.runtime.NullProgressMonitor;14 12 import org.eclipse.imp.model.ISourceProject; 15 13 import org.eclipse.imp.parser.ILexer; … … 33 31 private IPath location; 34 32 35 private SymbolTable topLevelSymbolTable = null;33 private AS3Analysis analysis; 36 34 37 35 public AS3ParseController() { … … 77 75 */ 78 76 public Object parse(String contents, boolean resolve, IProgressMonitor monitor) { 79 if (monitor == null) monitor = new NullProgressMonitor();77 //if (monitor == null) monitor = new NullProgressMonitor(); 80 78 int newHash = contents.hashCode(); 81 79 if (lastHash == newHash) { … … 85 83 AS3Plugin.getDefault().debug("parsing "+ getPath().toString()); 86 84 lastHash = newHash; 87 topLevelSymbolTable = null;88 85 PMMonitor my_monitor = new PMMonitor(monitor); 89 86 char[] contentsArray = contents.toCharArray(); … … 96 93 97 94 if (parser == null) { 98 parser = new AS3Parser( lexer.getILexStream());95 parser = new AS3Parser(); 99 96 } 100 97 parser.reset(lexer.getILexStream()); … … 102 99 103 100 // Lex the stream to produce the token stream 104 lexer.lexer(my_monitor, parser);101 boolean success = lexer.lexer(my_monitor, parser); 105 102 // fCurrentAst might (probably will) be 106 103 // inconsistent wrt the lex stream now … … 109 106 if (fCurrentAst != null) 110 107 backupAst = fCurrentAst; 108 if (success) { 109 // the lexer called the deterministic parser incrementally and we can just assemble the ast 110 fCurrentAst = parser.parserActions(my_monitor, 0); 111 } else { 112 // do parseActions anyway we have no other way to clear the deterministicparser.action field 113 // and we have a memory leak otherwise 114 parser.parserActions(my_monitor, 0); 115 fCurrentAst = parser.parser(my_monitor, -1); 116 } 117 if (fCurrentAst != null) 118 backupAst = null; 119 120 if (analysis == null) 121 analysis = new AS3Analysis(this); 122 analysis.analyse(fCurrentAst); 111 123 112 fCurrentAst = parser.parser(my_monitor, -1); 113 114 if (fCurrentAst instanceof ASTNode) { 124 if (resolve && fCurrentAst instanceof ASTNode) { 115 125 ASTNode node = (ASTNode) fCurrentAst; 116 topLevelSymbolTable = resolveSymbolTable(node); 117 buildIndex(node); 118 if (resolve) { 119 resolveDeclarations(node); 120 } 126 resolveDeclarations(node); 121 127 } 122 128 … … 124 130 125 131 return fCurrentAst; 126 }127 128 public void buildIndex(Object object) {129 if (object instanceof ASTNode) {130 ((ASTNode)object).accept(new IndexingVisitor(this));131 }132 132 } 133 133 … … 138 138 } 139 139 140 protected SymbolTable resolveSymbolTable(ASTNode root) {141 SymbolTableVisitor symbolTableVisitor = new SymbolTableVisitor(this);142 root.accept(symbolTableVisitor);143 return symbolTableVisitor.getTopLevelSymbolTable();144 }145 146 140 public Object getBackupAst() { 147 141 return backupAst; 148 }149 150 public SymbolTable getEnclosingSymbolTable(IAst node) {151 if (topLevelSymbolTable != null) {152 return topLevelSymbolTable.getEnclosingSymbolTable(node);153 }154 return null;155 142 } 156 143 … … 161 148 return super.getTokenIterator(region); 162 149 } 150 151 public void dispose() { 152 parser = null; 153 lexer = null; 154 backupAst = null; 155 fCurrentAst = null; 156 handler = null; 157 analysis = null; 158 } 163 159 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g
rb32f7a4 r5c182b6 487 487 | Statement_sif 488 488 | VariableDefinition_allowin 489 | Attributes --NO_LINE_BREAK$490 LCURLY$ Substatements RCURLY$489 -- | Attributes --NO_LINE_BREAK$ 490 -- LCURLY$ Substatements RCURLY$ 491 491 492 492 Substatement_nosif$Substatement … … 494 494 | Statement_nosif 495 495 | VariableDefinition_allowin 496 | Attributes --NO_LINE_BREAK$497 LCURLY$ Substatements RCURLY$498 499 Substatements$Substatements$Substatement ::= %empty500 Substatements$Substatements$Substatement ::= Substatements Substatement_sif496 -- | Attributes --NO_LINE_BREAK$ 497 -- LCURLY$ Substatements RCURLY$ 498 499 --Substatements$Substatements$Substatement ::= %empty 500 --Substatements$Substatements$Substatement ::= Substatements Substatement_sif 501 501 502 502 -- no empty semicolon ! use virtual semi instead ! … … 521 521 Block$Block ::= LCURLY$ RCURLY$ 522 522 /. 523 public static final int OTHER = 0;524 public static final int METHOD = 4;525 public static final int FUNCTION = 5;526 public static final int PACKAGE = 1;527 public static final int CLASS = 2;528 public static final int INTERFACE = 3;529 public int type;530 523 SymbolTable symbolTable; 531 524 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } … … 626 619 AnnotatedDirective 627 620 ::= Attributes --NO_LINE_BREAK$ 628 AnnotatableDirective 629 | AnnotatableDirective 621 AnnotatableDirective$Directive 622 | AnnotatableDirective$Directive 630 623 Directive ::= AnnotatedDirective 631 624 | EmptyStatment … … 710 703 VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBindingList_noin COMMA$ VariableBinding_noin 711 704 712 VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 705 713 706 --B 714 707 VariableBinding_allowin$VariableBinding … … 766 759 -- 17.2.1 Function body 767 760 FunctionCommon$FunctionCommon ::= LPAREN$ Parameters RPAREN$ ResultType 761 FunctionCommon$FunctionCommon ::= LPAREN$ RPAREN$ ResultType 768 762 769 763 -- 17.2.2 Function signature 770 764 771 765 -- 17.2.3 Parameter list 772 Parameters$Parameters$Parameter ::= %empty 773 Parameters$Parameters$Parameter ::= NonemptyParameters 774 NonemptyParameters$Parameters$Parameter ::= Parameter 775 NonemptyParameters$Parameters$Parameter ::= PlainParameter COMMA$ NonemptyParameters 766 Parameters$Parameters$Parameter ::= Parameter 767 -- rest is only allowed as last parameter but check that later 768 Parameters$Parameters$Parameter ::= Parameter COMMA$ Parameters 776 769 Parameter ::= PlainParameter | RestParameter 777 770 PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident 778 771 PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident ASSIGN$ AssignmentExpression_allowin$Initializer 779 772 RestParameter$RestParameter ::= REST$ 780 RestParameter$RestParameter ::= REST$ Identifier$Untyped781 773 RestParameter$RestParameter ::= REST$ TypedIdentifier_allowin$Ident 782 774 … … 826 818 InterfaceDefinition ::= interface$ Name ExtendsList InterfaceBlock$Body 827 819 /. 820 SymbolTable symbolTable; 821 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 822 public SymbolTable getSymbolTable() { return symbolTable; } 828 823 public Attributes getAttributes() { 829 824 if (!(getParent() instanceof AnnotatedDirective)) return null; … … 842 837 InterfaceBlock$InterfaceBlock ::= LCURLY$ RCURLY$ 843 838 InterfaceBlock$InterfaceBlock ::= LCURLY$ InterfaceDirectives$Directives RCURLY$ 844 /. 845 SymbolTable symbolTable; 846 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 847 public SymbolTable getSymbolTable() { return symbolTable; } 848 ./ 839 849 840 InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= FunctionSignature 850 841 InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= InterfaceDirectives FunctionSignature … … 874 865 return _Packages.getPackageDefinitionAt(0); 875 866 } 867 SymbolTable symbolTable; 868 public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 869 public SymbolTable getSymbolTable() { return symbolTable; } 876 870 ./ 877 871 … … 883 877 VariableDefinition ::= VariableDefinition_allowin | VariableDefinition_noin 884 878 VariableBinding ::= VariableBinding_allowin | VariableBinding_noin 879 VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 885 880 Statement ::= Statement_sif | Statement_nosif 886 881 Substatement ::= Substatement_sif | Substatement_nosif … … 890 885 %Headers 891 886 /. 887 public Object parserActions(Monitor monitor, int error_repair_count) 888 { 889 dtParser.setMonitor(monitor); 890 891 try 892 { 893 return (Object) dtParser.parseActions(); 894 } 895 catch (BadParseException e) 896 { 897 prsStream.reset(e.error_token); // point to error token 898 899 DiagnoseParser diagnoseParser = new DiagnoseParser(prsStream, prsTable); 900 diagnoseParser.diagnose(e.error_token); 901 } 902 903 return null; 904 } 892 905 ./ 893 906 %End -
org.axdt.as3/src/org/axdt/as3/imp/parser/DiagnoseVisitor.java
r25b5d22 r5c182b6 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.IMessageHandler; 5 import lpg.runtime.IPrsStream;6 6 import lpg.runtime.IToken; 7 7 import lpg.runtime.ParseErrorCodes; 8 8 9 import org.axdt.as3.imp.parser.Ast.ASTNode;10 9 import org.axdt.as3.imp.parser.Ast.AbstractVisitor; 11 10 import org.eclipse.core.resources.IFile; … … 13 12 14 13 public class DiagnoseVisitor extends AbstractVisitor { 15 protected static int[] NULL_LOCATION = n ew int[] {0,0};14 protected static int[] NULL_LOCATION = null; 16 15 17 protected final IPrsStream prsStream;18 16 protected final ILexStream lexStream; 19 protected AS3ParseController parseController; 20 protected int errorCount = 0; 17 protected final IFile file; 18 19 public int errorCount = 0; 21 20 protected boolean severeError = false; 22 21 23 public DiagnoseVisitor(AS3ParseController parseController) { 24 this.parseController = parseController; 25 this.prsStream = parseController.getParser().getIPrsStream(); 26 this.lexStream = prsStream.getILexStream(); 22 public DiagnoseVisitor(IFile file, ILexStream stream) { 23 this.file = file; 24 this.lexStream = stream; 27 25 } 28 26 29 27 protected IProject getProject() { 30 return parseController.getProject().getRawProject();28 return file.getProject(); 31 29 } 32 30 33 31 protected IFile getFile() { 34 return getProject().getFile(parseController.getPath()); 32 return file; 33 } 34 35 public void emitError(Object node, String message) { 36 emitError((IAst) node, message); 35 37 } 36 38 … … 39 41 } 40 42 41 public void emitError( ASTNodenode, String message) {43 public void emitError(IAst node, String message) { 42 44 emitError(node.getLeftIToken().getStartOffset(), node.getRightIToken().getEndOffset(), message); 43 45 } … … 46 48 emitError(ParseErrorCodes.NO_MESSAGE_CODE, startOffset, endOffset, message); 47 49 } 50 51 public void emitError(int code, IToken id, String message) { 52 emitError(code, id.getStartOffset(), id.getEndOffset(), message); 53 } 54 55 public void emitError(int code, IAst node, String message) { 56 emitError(code, node.getLeftIToken().getStartOffset(), node.getRightIToken().getEndOffset(), message); 57 } 48 58 public void emitError(int code, int startOffset, int endOffset, String message) { 49 int[] loc = lexStream.getLocation(startOffset, endOffset); 59 int[] loc = lexStream.getLocation(Math.min(startOffset,lexStream.getStreamLength()), Math.min(endOffset, lexStream.getStreamLength())); 60 if (NULL_LOCATION == null) 61 NULL_LOCATION = lexStream.getLocation(0, 0); 50 62 String[] msgs = new String[] {message}; 51 63 IMessageHandler handler = lexStream.getMessageHandler(); 52 handler.handleMessage(code, loc, NULL_LOCATION, prsStream.getFileName(), msgs);64 handler.handleMessage(code, loc, NULL_LOCATION, file.getName(), msgs); 53 65 errorCount++; 54 66 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/ResolvingVisitor.java
r2aa064d r5c182b6 5 5 6 6 import lpg.runtime.IAst; 7 import lpg.runtime.ILexStream; 7 8 8 9 import org.axdt.as3.AS3Plugin; … … 14 15 import org.axdt.as3.imp.parser.Ast.ExtendsList; 15 16 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 16 import org.axdt.as3.imp.parser.Ast.FunctionExpression;17 17 import org.axdt.as3.imp.parser.Ast.IName; 18 import org.axdt.as3.imp.parser.Ast.IPostfixExpression;19 18 import org.axdt.as3.imp.parser.Ast.ITypeExpression_allowin; 20 import org.axdt.as3.imp.parser.Ast.ITypeExpression_noin;21 19 import org.axdt.as3.imp.parser.Ast.Ident; 22 20 import org.axdt.as3.imp.parser.Ast.ImportDirective; … … 24 22 import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 25 23 import org.axdt.as3.imp.parser.Ast.Name; 24 import org.axdt.as3.imp.parser.Ast.NewExpression; 26 25 import org.axdt.as3.imp.parser.Ast.PackageDefinition; 26 import org.axdt.as3.imp.parser.Ast.Parameters; 27 import org.axdt.as3.imp.parser.Ast.RestParameter; 27 28 import org.axdt.as3.imp.parser.Ast.ResultType; 28 29 import org.axdt.as3.imp.parser.Ast.TypeExpressionList; 29 30 import org.axdt.as3.imp.parser.Ast.TypedIdentifier; 30 import org.axdt.as3. imp.parser.Ast.VariableBinding;31 import org.axdt.as3.util.AS3ASTUtil; 31 32 import org.axdt.as3.util.AS3Util; 32 33 import org.axdt.axdoc.model.AXEntry; … … 35 36 import org.axdt.axdoc.util.Index0r; 36 37 import org.axdt.common.preferences.AxdtPreferences; 38 import org.eclipse.core.resources.IFile; 37 39 38 40 public class ResolvingVisitor extends DiagnoseVisitor { … … 42 44 private ArrayList<AXEntry> importedTypes; 43 45 private String expectedPackageName; 44 45 public ResolvingVisitor(AS3ParseController parseController) { 46 super(parseController); 46 public ResolvingVisitor(AS3ParseController pc) { 47 this(pc.getProject().getRawProject().getFile(pc.getPath()), pc.getLexer().getILexStream()); 48 } 49 public ResolvingVisitor(IFile file, ILexStream stream) { 50 super(file, stream); 47 51 addDebugErrors = AS3Plugin.getDefault() != null && AxdtPreferences.doDebug(); 48 52 index0r = Index0r.getInstance(); … … 60 64 } 61 65 } 66 // add same package 62 67 AXIndex[] sameIndexes = index0r.findPackage(expectedPackageName); 63 68 for (AXIndex index:sameIndexes) { 64 69 importedPackages.add(index); 65 70 } 71 // file private names are resolved with the local symbol table 66 72 } 67 73 protected AXEntry resolveType(String name) { 68 74 for (AXEntry entry:importedTypes) { 69 if (entry.getName().equals(name)) 75 if (entry.getName().equals(name)) { 76 index0r.requestFull(entry); 70 77 return entry; 78 } 71 79 } 72 80 for (AXIndex index:importedPackages) { 73 81 for (AXEntry entry:index.getTypes()) { 74 82 if (entry.getName().equals(name)) { 83 index0r.requestFull(entry); 75 84 return entry; 76 85 } … … 79 88 return null; 80 89 } 81 protected String resolveType(ITypeExpression_nointype) {90 protected Object resolveType(Object type) { 82 91 return type instanceof ASTNode ? resolveNode((ASTNode) type) : null; 83 92 } 84 protected String resolveType(ITypeExpression_allowin type) { 85 return type instanceof ASTNode ? resolveNode((ASTNode) type) : null; 86 } 87 protected String resolveType(IPostfixExpression type) { 88 return type instanceof ASTNode ? resolveNode((ASTNode) type) : null; 89 } 90 protected String resolveNode(ASTNode type) { 91 if (type == null) 92 return null; 93 protected Object resolveConstructor(Object type) { 94 if (type == null) return null; 93 95 String typeName = type.toString(); 94 96 AXEntry entry = resolveType(typeName); 95 if (entry == null) { 96 if (!typeName.equals("*")) 97 emitError((ASTNode)type, "could not resolve type"); 98 return null; 99 } 100 String id = entry.getId(); 101 if (type instanceof Ident) { 102 ((Ident)type).setDeclaration(id); 103 } else if (addDebugErrors) { 104 emitError((ASTNode)type, "todo: not expected other than ident"); 105 } 106 return id; 97 Object declaration = null; 98 if (entry != null) { 99 AXEntry member = entry.localMember(typeName); 100 if (member != null){ 101 declaration = member.getId(); 102 } else { 103 declaration = entry.getId(); 104 } 105 } else { 106 // might be file private member 107 SymbolTable table = AS3ASTUtil.getEnclosingSymbolTable((IAst)type).getRoot(); 108 declaration = table.findDeclaration(typeName); 109 } 110 setDeclaration(type, declaration); 111 return declaration; 112 } 113 protected Object resolveNode(ASTNode type) { 114 if (type == null) return null; 115 Object declaration = null; 116 String typeName = type.toString(); 117 if (typeName.equals("*")) { 118 declaration = "*"; 119 } else { 120 AXEntry entry = resolveType(typeName); 121 if (entry != null) { 122 declaration = entry.getId(); 123 } else { 124 // might be file private member 125 SymbolTable table = AS3ASTUtil.getEnclosingSymbolTable(type).getRoot(); 126 declaration = table.findDeclaration(typeName); 127 } 128 } 129 setDeclaration(type, declaration); 130 return declaration; 131 } 132 protected void setDeclaration(Object type, Object declaration) { 133 if (declaration != null) { 134 if (type instanceof Ident) { 135 ((Ident)type).setDeclaration(declaration); 136 } else if (addDebugErrors) { 137 emitError((ASTNode)type, "todo: not expected other than ident"); 138 } 139 } else { 140 emitError((ASTNode)type, "could not resolve type"); 141 } 107 142 } 108 143 protected void resolveTypes(TypeExpressionList list) { … … 121 156 @Override 122 157 public boolean visit(PackageDefinition n) { 123 String packageName = AS3Util.getExpectedPackageName(getFile());124 // is not inside a valid source path125 if (packageName == null) {126 emitError(n, "file should be inside a configured source path");127 return false;128 }129 // check if name corresponds with folder names130 if (n.getName() != null) {131 Name nameNode = (Name) n.getName();132 String name = nameNode.toString();133 if (!name.equals(packageName))134 emitError(nameNode, "package name sould be: "+ packageName);135 // fill declaration with false136 Name current = nameNode;137 while (current!=null) {138 current.getIdent().setDeclaration(Boolean.FALSE);139 current = current.getQualifier() instanceof Name ?140 (Name)current.getQualifier() : null;141 }142 } else if (packageName != null && packageName.length() > 0) {143 emitError(n.getLeftIToken(), "package name sould be: "+ packageName);144 }145 158 return true; 146 159 } … … 187 200 } 188 201 @Override 189 public boolean visit(ClassDefinition n) {190 Name name = (Name) n.getName();191 checkTypeName(name);192 checkPackageDirectiveName(name);193 return true;194 }195 @Override196 202 public boolean visit(Inheritance n) { 197 203 ClassDefinition parent = (ClassDefinition) n.getParent(); … … 202 208 } 203 209 @Override 204 public boolean visit(InterfaceDefinition n) {205 Name name = (Name) n.getName();206 checkTypeName(name);207 checkPackageDirectiveName(name);208 return true;209 }210 @Override211 210 public boolean visit(ExtendsList n) { 212 211 InterfaceDefinition parent = (InterfaceDefinition) n.getParent(); … … 214 213 return false; 215 214 } 216 private void checkTypeName(Name name) {217 if (name.getQualifier()!=null)218 emitError(name, "type names are not qualified. the package name belongs in the package declaration");219 name.getIdent().setDeclaration(Boolean.FALSE);220 }221 private void checkPackageDirectiveName(Name name) {222 IAst grandp = name;223 while (grandp != null) {224 grandp = grandp.getParent();225 if (grandp instanceof PackageDefinition)226 break;227 }228 if (grandp != null) {229 String nameString = name.getIdent().toString();230 String expectedName = AS3Util.getExpectedMemberName(getFile());231 if (!nameString.equals(expectedName))232 emitError(name, "public package member name should match the file name");233 }234 }235 215 216 @Override 217 public boolean visit(FunctionDefinition n) { 218 Ident name = n.getName(); 219 if (name == null) { 220 emitError(n, "must have a name"); 221 // TODO check for overrides ? 222 // 223 } 224 return true; 225 } 226 @Override 227 public boolean visit(RestParameter n) { 228 // TODO: move to more basic checking phase 229 IAst parent = n.getParent(); 230 if (parent instanceof Parameters) { 231 Parameters params = (Parameters) parent; 232 if (n != params.getParameterAt(params.size()-1)) { 233 emitError(n, "rest parameter can only occur as last parameter"); 234 } 235 } else { 236 emitError(parent, "todo: rest parameters parent should be parameters ?!"); 237 } 238 return true; 239 } 240 @Override 236 241 public boolean visit(TypedIdentifier n) { 237 if (n != null) 242 if (n != null) { 238 243 resolveNode(n.getType()); 239 return false; 240 } 244 n.getName().setDeclaration(Boolean.FALSE); 245 } 246 return false; 247 } 248 @Override 241 249 public boolean visit(ResultType n) { 242 250 if (n != null) … … 244 252 return false; 245 253 } 246 254 @Override 255 public void endVisit(NewExpression n) { 256 // TODO check expression for type 257 if (n != null) { 258 resolveConstructor(n.getExpression()); 259 } 260 } 261 @Override 262 public void endVisit(AssignmentExpression n) { 263 // TODO check if left type is assignable from right type 264 n.toString(); 265 } 266 @Override 267 public boolean visit(ExpressionStatement n) { 268 return true; 269 } 247 270 } -
org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTable.java
re9006de r5c182b6 2 2 3 3 import java.util.ArrayList; 4 import java.util.Hash table;4 import java.util.HashMap; 5 5 import java.util.List; 6 import java.util.Map; 6 7 7 8 import lpg.runtime.IAst; 8 9 9 import org.axdt.as3.imp.parser.Ast.Block; 10 import org.axdt.as3.imp.parser.Ast.ClassDefinition; 11 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 12 import org.axdt.as3.imp.parser.Ast.FunctionExpression; 13 import org.axdt.as3.imp.parser.Ast.InterfaceBlock; 10 import org.axdt.as3.util.AS3ASTUtil; 14 11 15 public class SymbolTable extends Hashtable<String, IAst> { 12 public class SymbolTable { 13 public class SymbolEntry { 14 15 private IAst node; 16 17 public SymbolEntry(IAst node) { 18 this.node = node; 19 } 20 21 public IAst getAst() { 22 return node; 23 } 24 25 } 16 26 private static final long serialVersionUID = 1L; 17 SymbolTable parent; 18 Class<?> nodeClass; 27 private Map<String,SymbolEntry> store; 28 private SymbolTable parent; 29 private Class<?> nodeClass; 19 30 20 SymbolTable(SymbolTable parent, Class<?> clazz) {31 public SymbolTable(SymbolTable parent, Class<?> clazz) { 21 32 this.parent = parent; 22 33 this.nodeClass = clazz; 34 store = new HashMap<String, SymbolEntry>(); 23 35 } 24 36 25 37 public IAst findDeclaration(String name) { 26 IAst decl = (IAst)get(name);27 if ( decl != null) return decl;38 SymbolEntry entry = store.get(name); 39 if (entry != null) return entry.getAst(); 28 40 if (parent != null) return parent.findDeclaration(name); 29 41 return null; … … 33 45 return parent; 34 46 } 47 public SymbolTable getRoot() { 48 return parent == null ? this : parent.getRoot(); 49 } 35 50 36 51 public boolean create(String name, IAst node) { 37 if ( get(name) == null) {38 put(name, node);52 if (store.get(name) == null) { 53 store.put(name, new SymbolEntry(node)); 39 54 return true; 40 55 } … … 45 60 if (list == null) 46 61 list = new ArrayList<String>(); 47 list.addAll( keySet());62 list.addAll(store.keySet()); 48 63 if (parent != null) parent.getAllKeys(list); 49 64 return list; 50 65 } 51 66 public SymbolTable getEnclosingSymbolTable(IAst n) { 52 SymbolTable enclosing = getEnclosing(n);67 SymbolTable enclosing = AS3ASTUtil.getEnclosingSymbolTable(n); 53 68 if (enclosing != null) return enclosing; 54 69 return this; 55 }56 public static SymbolTable getEnclosing(IAst n) {57 for (; n != null; n = n.getParent()) {58 if (n instanceof Block) return ((Block) n).getSymbolTable();59 if (n instanceof InterfaceBlock) return ((InterfaceBlock) n).getSymbolTable();60 if (n instanceof FunctionDefinition) return ((FunctionDefinition) n).getSymbolTable();61 if (n instanceof FunctionExpression) return ((FunctionExpression) n).getSymbolTable();62 if (n instanceof ClassDefinition) return ((ClassDefinition) n).getSymbolTable();63 }64 return null;65 70 } 66 71 public String cleanName(String key) { -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java
rb32f7a4 r5c182b6 7 7 8 8 import lpg.runtime.IAst; 9 import lpg.runtime.IPrsStream;10 import lpg.runtime.IToken;11 9 12 import org.axdt.as3.AS3Plugin; 13 import org.axdt.as3.imp.parser.AS3ASTNodeLocator; 10 import org.axdt.as3.analysis.AS3TokenHelper; 14 11 import org.axdt.as3.imp.parser.AS3ParseController; 15 import org.axdt.as3.imp.parser.AS3Parsersym;16 12 import org.axdt.as3.imp.parser.SymbolTable; 17 13 import org.axdt.as3.imp.parser.Ast.ASTNode; 18 import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective;19 14 import org.axdt.as3.imp.parser.Ast.IName; 20 15 import org.axdt.as3.imp.parser.Ast.ImportDirective; 21 16 import org.axdt.as3.imp.parser.Ast.PackageDefinition; 22 17 import org.axdt.as3.templates.AS3TemplateCompletionProcessor; 18 import org.axdt.as3.util.AS3ASTUtil; 23 19 import org.axdt.as3.util.AS3Util; 24 20 import org.axdt.axdoc.model.AXEntry; … … 28 24 import org.eclipse.imp.editor.SourceProposal; 29 25 import org.eclipse.imp.parser.IParseController; 30 import org.eclipse.imp.parser.IParser;31 26 import org.eclipse.imp.services.IContentProposer; 32 27 import org.eclipse.jface.text.ITextViewer; … … 35 30 public class AS3ContentProposer implements IContentProposer { 36 31 37 private static AS3ASTNodeLocator locator = new AS3ASTNodeLocator();32 private AS3SourceHelper helper; 38 33 39 private boolean offsetWithinToken;40 private int offset;41 private AS3ParseController control;42 private IToken token;43 private String prefix;44 private ASTNode ast;45 private ASTNode node;46 47 private ArrayList<IAst> ancestors;48 49 private IToken previous;50 51 private IToken next;52 53 private boolean offsetAfterToken;54 55 private ITextViewer viewer;56 57 private boolean usingBackup;58 59 private int originalOffset;60 61 62 private int offsetDiff;63 64 private boolean nextIsSemi;65 66 private void clear() {67 offsetWithinToken = offsetAfterToken = nextIsSemi = false;68 prefix = null;69 ancestors = null;70 token = previous = next = null;71 node = null;72 }73 74 34 public AS3ContentProposer() { 75 }76 protected boolean collectInfo(IParseController controller, int offset, ITextViewer viewer) {77 this.viewer = viewer;78 this.control = (AS3ParseController) controller;79 this.offset = offset;80 offsetDiff = offset - originalOffset;81 usingBackup = false;82 ast = null;83 ASTNode newast = getAst();84 if (newast != null && newast == ast) {85 AS3Plugin.getDefault().debug("using old ast nothing changed");86 return true;87 }88 IParser parser = control.getParser();89 IPrsStream stream = parser.getIPrsStream();90 if (stream == null) {91 AS3Plugin.getDefault().debug("no error lexing.");92 return false;93 }94 if (newast == null) {95 AS3Plugin.getDefault().debug("no ast available try to recover");96 Object backupAst = control.getBackupAst();97 if (! (backupAst instanceof ASTNode)) {98 AS3Plugin.getDefault().debug("no backup ast. recover failed.");99 return false;100 }101 newast = (ASTNode) backupAst;102 usingBackup = true;103 } else {104 originalOffset = offset;105 }106 clear();107 try {108 ast = newast;109 int myOffset = offset;110 int index = stream.getTokenIndexAtCharacter(myOffset);111 token = getToken(stream, index < 0 ? -index + 1: index);112 previous = getToken(stream, token.getTokenIndex()-1);113 offsetAfterToken = previous.getEndOffset() == myOffset - 1;114 if (offsetAfterToken || token.getKind() == Sym.TK_SEMI115 || (myOffset < token.getStartOffset()&& stream.getILexStream().getLineNumberOfCharAt(myOffset) < token.getLine())) {116 next = token;117 token = previous;118 previous = stream.getIToken(token.getTokenIndex()-1);119 }120 if (next == null){121 next = stream.getIToken(stream.getNext(token.getTokenIndex()));122 }123 nextIsSemi = next.getKind() == Sym.TK_SEMI;124 offsetWithinToken = Sym.isWithinToken(myOffset, token);125 if ((offsetAfterToken||offsetWithinToken) && Sym.isKeyword(token))126 return false;127 this.prefix = offsetWithinToken ? Sym.getPrefix(myOffset, token)128 : ( offsetAfterToken ? token.toString() : "");129 node = getNode(token);130 collectAncestorInfo(node);131 } catch (Exception e) {132 AS3Plugin.getDefault().debug("error collecting context info for completion proposals", e);133 }134 return true;135 }136 private IToken getToken(IPrsStream s, int index) {137 IToken result = s.getIToken(index);138 if (result.getKind() == Sym.TK_VirtualSemicolon)139 result = s.getIToken(index-1);140 return result;141 }142 private void collectAncestorInfo(ASTNode node) {143 ancestors = new ArrayList<IAst>();144 for (IAst n = node; n != null; n = n.getParent()) {145 if (n instanceof IAnnotatableDirective146 || n instanceof ImportDirective147 || n instanceof PackageDefinition148 ) {149 ancestors.add(n);150 }151 }152 }153 private ASTNode getNode(IToken t) {154 Object object = locator.findNode(ast, t.getStartOffset(), t.getEndOffset());155 return (object instanceof ASTNode) ? (ASTNode) object : null;156 }157 private ASTNode getAst() {158 Object object = control.parse(viewer.getDocument().get(), null);159 return (object instanceof ASTNode) ? (ASTNode) object : null;160 35 } 161 36 /** … … 180 55 public ICompletionProposal[] getContentProposals(IParseController controller, int offset, 181 56 ITextViewer viewer) { 182 boolean precede = collectInfo(controller, offset, viewer); 57 helper = new AS3SourceHelper((AS3ParseController)controller, viewer); 58 boolean precede = helper.init(offset); 183 59 if (!precede) { 184 60 return new ICompletionProposal[0]; 185 61 } 186 62 ProposalHelper proposals = new ProposalHelper(); 187 if ( ast != null) {188 if ( ancestors != null && ancestors.size() > 0) {189 IAst ancestor = ancestors.get(0);63 if (helper.hasAst()) { 64 if (helper.hasAncestors()) { 65 IAst ancestor = helper.ancestors.get(0); 190 66 if (ancestor instanceof PackageDefinition) { 191 67 PackageDefinition packdef = (PackageDefinition)ancestor; 192 if (packdef.getBody() == null || offset < packdef.getBody().getLeftIToken().getStartOffset()+offsetDiff) {68 if (packdef.getBody() == null || offset <= packdef.getBody().getLeftIToken().getStartOffset()) { 193 69 // in package header 194 70 IName nameNode = packdef.getName(); 195 if (!usingBackup) 196 prefix = fetchName((IAst) nameNode); 197 IResource project = control.getProject().getResource(); 198 String expectedName = AS3Util.getExpectedPackageName(project,project.getFullPath().append(control.getPath())); 199 if (!prefix.equals(expectedName)) 200 proposals.addSourceProposal(expectedName, prefix,PackageDefinition.class); 71 helper.updatePrefix(helper.fetchName((IAst) nameNode)); 72 IResource project = helper.control.getProject().getResource(); 73 String expectedName = AS3Util.getExpectedPackageName(project,project.getFullPath().append(helper.control.getPath())); 74 if (!helper.prefix.equals(expectedName)) 75 proposals.addSourceProposal(expectedName, helper.prefix,PackageDefinition.class); 201 76 } else { 202 proposals.addUnitScopeProposals( node);203 boolean isImport = token.getKind() == Sym.TK_import;204 if (isImport || prefix.startsWith("import")) {77 proposals.addUnitScopeProposals(helper.node); 78 boolean isImport = helper.token.getKind() == AS3TokenHelper.TK_import; 79 if (isImport || helper.prefix.startsWith("import")) { 205 80 for (String packname:Index0r.getInstance().getPackageNames()) { 206 81 String proposed = (isImport ? "":"import ")+packname+".*"; 207 proposals.addSourceProposal(proposed, prefix, ImportDirective.class, !nextIsSemi);82 proposals.addSourceProposal(proposed, helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 208 83 } 209 84 } … … 211 86 } else if (ancestor instanceof ImportDirective) { 212 87 IName nameNode = ((ImportDirective)ancestor).getName(); 213 if (!usingBackup) 214 prefix = fetchName((IAst) nameNode); 215 int dotIndex = prefix.lastIndexOf('.'); 88 helper.updatePrefix(helper.fetchName((IAst) nameNode)); 89 int dotIndex = helper.prefix.lastIndexOf('.'); 216 90 Collection<String> packageNames = Index0r.getInstance().getPackageNames(); 217 91 if (dotIndex > 0) { 218 String packname = prefix.substring(0,dotIndex);219 String rest = prefix.substring(dotIndex+1);92 String packname = helper.prefix.substring(0,dotIndex); 93 String rest = helper.prefix.substring(dotIndex+1); 220 94 if (packageNames.contains(packname)) { 221 95 if ("*".equals(rest)) { … … 226 100 String entryname = entry.getName(); 227 101 if (entryname != null && (rest.length() == 0 || entryname.startsWith(rest))) { 228 proposals.addSourceProposal(packname+"."+entryname, prefix, ImportDirective.class, !nextIsSemi);102 proposals.addSourceProposal(packname+"."+entryname, helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 229 103 } 230 104 } 231 105 if (rest.length() == 0) { 232 proposals.addSourceProposal(packname+".*", prefix, ImportDirective.class, !nextIsSemi);106 proposals.addSourceProposal(packname+".*", helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 233 107 } 234 108 } … … 236 110 } 237 111 for (String packname:packageNames) { 238 if (packname.startsWith( prefix)) {239 proposals.addSourceProposal(packname+".*", prefix, ImportDirective.class, !nextIsSemi);112 if (packname.startsWith(helper.prefix)) { 113 proposals.addSourceProposal(packname+".*", helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 240 114 } 241 115 } 242 116 } else { 243 proposals.addUnitScopeProposals( node);117 proposals.addUnitScopeProposals(helper.node); 244 118 } 245 119 } else { … … 247 121 } 248 122 } 249 if ( prefix != null && prefix.length() > 0) {123 if (helper.hasPrefix()) { 250 124 proposals.addKeywordProposals(); 251 125 proposals.addTemplateProposals(viewer); 252 126 } 253 127 return proposals.getResult(); 254 }255 protected String fetchName(IAst nameNode) {256 String name = nameNode == null ? "" : nameNode.toString();257 int startOffset = nameNode == null ? offset : nameNode.getLeftIToken().getStartOffset();258 if (offset > startOffset + name.length()) {259 try {260 name = viewer.getDocument().get(startOffset, offset - startOffset);261 } catch (Exception e) {262 AS3Plugin.getDefault().debug("error fetching real name",e);263 }264 }265 return name;266 128 } 267 129 public static final Comparator<ICompletionProposal> ProposalComparator = new Comparator<ICompletionProposal>() { … … 270 132 } 271 133 }; 272 private class ProposalHelper implements AS3Parsersym{134 private class ProposalHelper { 273 135 ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal>(); 274 136 275 137 void addUnitScopeProposals(ASTNode node) { 276 SymbolTable table = SymbolTable.getEnclosing(node);138 SymbolTable table = AS3ASTUtil.getEnclosingSymbolTable(node); 277 139 if (table == null) return; 278 140 for (String key:table.getAllKeys(null)) { 279 141 String name = table.cleanName(key); 280 if (name.startsWith( prefix)) {142 if (name.startsWith(helper.prefix)) { 281 143 IAst ast = table.findDeclaration(key); 282 result.add(new AS3SourceProposal(name, prefix,offset, ast.getClass()));144 result.add(new AS3SourceProposal(name, helper.prefix, helper.offset, ast.getClass())); 283 145 } 284 146 } 285 147 } 286 148 void addSourceProposal(String packageName, String usePrefix, ASTNode node) { 287 result.add(new AS3SourceProposal(packageName, usePrefix, offset, node.getClass()));149 result.add(new AS3SourceProposal(packageName, usePrefix, helper.offset, node.getClass())); 288 150 } 289 151 void addSourceProposal(String packageName, String usePrefix, Class<?> nodeClass) { 290 result.add(new AS3SourceProposal(packageName, usePrefix, offset, nodeClass));152 result.add(new AS3SourceProposal(packageName, usePrefix, helper.offset, nodeClass)); 291 153 } 292 154 void addSourceProposal(String packageName, String usePrefix, Class<?> nodeClass, boolean addSemi) { 293 155 if (addSemi) packageName += ";"; 294 result.add(new AS3SourceProposal(packageName, usePrefix, offset, nodeClass));156 result.add(new AS3SourceProposal(packageName, usePrefix, helper.offset, nodeClass)); 295 157 } 296 158 void addKeywordProposals() { 297 for (String key: Sym.getKeyWords()) {298 if (!key.equals( prefix) && key.startsWith(prefix)) {299 SourceProposal proposal = new SourceProposal(key, prefix,offset);159 for (String key:AS3TokenHelper.getKeyWords()) { 160 if (!key.equals(helper.prefix) && key.startsWith(helper.prefix)) { 161 SourceProposal proposal = new SourceProposal(key, helper.prefix, helper.offset); 300 162 result.add(proposal); 301 163 } … … 304 166 void addTemplateProposals(ITextViewer viewer) { 305 167 AS3TemplateCompletionProcessor processor = new AS3TemplateCompletionProcessor(); 306 result.addAll(processor.computeCompletionProposalList(viewer, offset,prefix));168 result.addAll(processor.computeCompletionProposalList(viewer, helper.offset, helper.prefix)); 307 169 } 308 170 ICompletionProposal[] getResult() { … … 311 173 } 312 174 } 313 public static class Sym implements AS3Parsersym {314 private static String[] keywords = null;315 316 public static String[] getKeyWords() {317 if (keywords == null)318 keywords = createKeywords();319 return keywords;320 }321 322 public static boolean isKeyword(IToken t) {323 int kind = t.getKind();324 if (kind > 1 && kind < orderedTerminalSymbols.length) {325 return orderedTerminalSymbols[kind].charAt(0) > 'Z';326 }327 return false;328 }329 330 public static String getPrefix(int o, IToken t) {331 return t.getKind() == Sym.TK_IDENTIFIER ?332 t.toString().substring(0, o-t.getStartOffset()) : "";333 }334 335 public static boolean isWithinToken(int o, IToken t) {336 return o >= t.getStartOffset() && o <= t.getEndOffset();337 }338 339 private static String[] createKeywords() {340 ArrayList<String> result = new ArrayList<String>();341 for (int i = 1; i < orderedTerminalSymbols.length; i++) {342 if (orderedTerminalSymbols[i].charAt(0) > 'Z')343 result.add(orderedTerminalSymbols[i]);344 }345 return result.toArray(new String[result.size()]);346 }347 }348 175 } -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3EditorService.java
r3d0622c r5c182b6 6 6 7 7 import org.axdt.as3.AS3Plugin; 8 import org.axdt.as3.imp.parser.AS3ParseController; 8 9 import org.eclipse.core.runtime.IPath; 9 10 import org.eclipse.core.runtime.IProgressMonitor; … … 38 39 public void update(IParseController parseController, 39 40 IProgressMonitor monitor) { 40 // TODO do update ?! we do the work in the as3 parse controller for now41 41 } 42 42 … … 71 71 if (editor != part) return; 72 72 partService.removePartListener(this); 73 if (path != null)openFilePaths.remove(path); 73 74 // clean up as long as there is the memory leak http://bugs.eclipse.org/281790 75 editor.fParserScheduler.cancel(); 76 editor.fParserScheduler = null; 77 if (editor.getParseController() instanceof AS3ParseController) { 78 AS3ParseController control = ((AS3ParseController) editor.getParseController()); 79 control.dispose(); 80 } 81 82 if (path != null) openFilePaths.remove(path); 74 83 AS3Plugin.getDefault().debug("as3 editor closed"); 75 84 } -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java
rb32f7a4 r5c182b6 3 3 import lpg.runtime.IAst; 4 4 5 import org.axdt.as3.imp.parser.AS3ParseController;6 5 import org.axdt.as3.imp.parser.SymbolTable; 7 6 import org.axdt.as3.imp.parser.Ast.Ident; … … 58 57 59 58 private Object lookInSymbolTable(IParseController controller, IAst node, String stringId) { 60 SymbolTable symtab = ((AS3ParseController) controller).getEnclosingSymbolTable(node);59 SymbolTable symtab = AS3ASTUtil.getEnclosingSymbolTable(node); 61 60 return symtab.findDeclaration(stringId); 62 61 } -
org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java
rb32f7a4 r5c182b6 4 4 import lpg.runtime.IToken; 5 5 6 import org.axdt.as3. imp.parser.AS3ParseController;6 import org.axdt.as3.analysis.AS3TokenHelper; 7 7 import org.axdt.as3.imp.parser.AS3Parsersym; 8 8 import org.eclipse.imp.parser.IParseController; … … 40 40 return null; 41 41 } 42 if ( ((AS3ParseController) controller).isKeyword(token.getKind()))42 if (AS3TokenHelper.isKeyword(token)) 43 43 return keywordAttribute; 44 44 return super.getColoring(controller, token); -
org.axdt.as3/src/org/axdt/as3/util/AS3ASTUtil.java
r69d1ca8 r5c182b6 3 3 import lpg.runtime.IAst; 4 4 5 import org.axdt.as3.imp.parser.SymbolTable; 5 6 import org.axdt.as3.imp.parser.Ast.ASTNode; 7 import org.axdt.as3.imp.parser.Ast.Block; 8 import org.axdt.as3.imp.parser.Ast.ClassDefinition; 9 import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 10 import org.axdt.as3.imp.parser.Ast.FunctionExpression; 6 11 import org.axdt.as3.imp.parser.Ast.IDirective; 7 12 import org.axdt.as3.imp.parser.Ast.IPackageDefinition; 13 import org.axdt.as3.imp.parser.Ast.ITypedIdentifier_noin; 8 14 import org.axdt.as3.imp.parser.Ast.Ident; 15 import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 9 16 import org.axdt.as3.imp.parser.Ast.Name; 17 import org.axdt.as3.imp.parser.Ast.Program; 10 18 11 19 public class AS3ASTUtil { … … 13 21 return parent instanceof IDirective 14 22 || parent instanceof IPackageDefinition; 23 } 24 public static boolean isNameParent(IAst parent) { 25 return parent instanceof IDirective 26 || parent instanceof IPackageDefinition 27 || parent instanceof ITypedIdentifier_noin; 15 28 } 16 29 public static ASTNode getDirective(ASTNode node) { … … 37 50 } 38 51 if (Boolean.FALSE.equals(declaration)) { 39 IAst parent = current .getParent();40 while (parent != null && !is Directive(parent.getParent()))52 IAst parent = current; 53 while (parent != null && !isNameParent(parent.getParent())) 41 54 parent = parent.getParent(); 42 55 return parent; … … 44 57 return declaration; 45 58 } 59 public static SymbolTable getEnclosingSymbolTable(IAst n) { 60 for (; n != null; n = n.getParent()) { 61 if (n instanceof Block) return ((Block) n).getSymbolTable(); 62 if (n instanceof FunctionDefinition) return ((FunctionDefinition) n).getSymbolTable(); 63 if (n instanceof FunctionExpression) return ((FunctionExpression) n).getSymbolTable(); 64 if (n instanceof ClassDefinition) return ((ClassDefinition) n).getSymbolTable(); 65 if (n instanceof InterfaceDefinition) return ((InterfaceDefinition) n).getSymbolTable(); 66 if (n instanceof Program) return ((Program) n).getSymbolTable(); 67 } 68 return null; 69 } 46 70 } -
org.axdt.axdoc.model/model/AXDoc.ecore
r2aa064d r5c182b6 26 26 </eClassifiers> 27 27 <eClassifiers xsi:type="ecore:EEnum" name="AXLevel"> 28 <eLiterals name="EMPTY" />29 <eLiterals name="PACKAGE" value="1" />30 <eLiterals name="TYPE" value="2" />31 <eLiterals name="MEMBER" value="4" />28 <eLiterals name="EMPTY" literal="e"/> 29 <eLiterals name="PACKAGE" value="1" literal="p"/> 30 <eLiterals name="TYPE" value="2" literal="t"/> 31 <eLiterals name="MEMBER" value="4" literal="m"/> 32 32 </eClassifiers> 33 33 <eClassifiers xsi:type="ecore:EClass" name="AXIndex" eSuperTypes="#//AXIndexNode"> … … 40 40 <eOperations name="getOrCreateReference" eType="#//AXPackage"/> 41 41 <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//AXPackage"/> 42 <eStructuralFeatures xsi:type="ecore:EAttribute" name="level" eType="#//AXLevel"43 transient="true"/>44 42 <eStructuralFeatures xsi:type="ecore:EReference" name="indexes" upperBound="-1" 45 43 eType="#//AXIndex" containment="true" resolveProxies="false" eOpposite="#//AXIndex/parent" … … 108 106 <eStructuralFeatures xsi:type="ecore:EReference" name="basicParent" eType="#//AXIndexNode" 109 107 changeable="false" volatile="true" transient="true"/> 108 <eStructuralFeatures xsi:type="ecore:EAttribute" name="level" eType="#//AXLevel"/> 110 109 </eClassifiers> 111 110 <eClassifiers xsi:type="ecore:EEnum" name="AXEntryType"> -
org.axdt.axdoc.model/model/AXDocXML.xsd
r2aa064d r5c182b6 103 103 </xsd:sequence> 104 104 <xsd:attribute name="name" type="xsd:string" use="required"/> 105 <xsd:attribute name="level" type="axdoc:AXLevel"/> 105 106 </xsd:complexType> 106 107 </xsd:schema> -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXDocPackage.java
r2aa064d r5c182b6 347 347 348 348 /** 349 * The feature id for the '<em><b>Level</b></em>' attribute. 350 * <!-- begin-user-doc --> 351 * <!-- end-user-doc --> 352 * @generated 353 * @ordered 354 */ 355 int AX_INDEX_NODE__LEVEL = 4; 356 357 /** 349 358 * The number of structural features of the '<em>AX Index Node</em>' class. 350 359 * <!-- begin-user-doc --> … … 353 362 * @ordered 354 363 */ 355 int AX_INDEX_NODE_FEATURE_COUNT = 4;364 int AX_INDEX_NODE_FEATURE_COUNT = 5; 356 365 357 366 /** … … 402 411 403 412 /** 413 * The feature id for the '<em><b>Level</b></em>' attribute. 414 * <!-- begin-user-doc --> 415 * <!-- end-user-doc --> 416 * @generated 417 * @ordered 418 */ 419 int AX_INDEX__LEVEL = AX_INDEX_NODE__LEVEL; 420 421 /** 404 422 * The feature id for the '<em><b>Reference</b></em>' reference. 405 423 * <!-- begin-user-doc --> … … 411 429 412 430 /** 413 * The feature id for the '<em><b>Level</b></em>' attribute.414 * <!-- begin-user-doc -->415 * <!-- end-user-doc -->416 * @generated417 * @ordered418 */419 int AX_INDEX__LEVEL = AX_INDEX_NODE_FEATURE_COUNT + 1;420 421 /**422 431 * The feature id for the '<em><b>Indexes</b></em>' containment reference list. 423 432 * <!-- begin-user-doc --> … … 426 435 * @ordered 427 436 */ 428 int AX_INDEX__INDEXES = AX_INDEX_NODE_FEATURE_COUNT + 2;437 int AX_INDEX__INDEXES = AX_INDEX_NODE_FEATURE_COUNT + 1; 429 438 430 439 /** … … 435 444 * @ordered 436 445 */ 437 int AX_INDEX__PARENT = AX_INDEX_NODE_FEATURE_COUNT + 3;446 int AX_INDEX__PARENT = AX_INDEX_NODE_FEATURE_COUNT + 2; 438 447 439 448 /** … … 444 453 * @ordered 445 454 */ 446 int AX_INDEX_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 4;455 int AX_INDEX_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 3; 447 456 448 457 /** … … 493 502 494 503 /** 504 * The feature id for the '<em><b>Level</b></em>' attribute. 505 * <!-- begin-user-doc --> 506 * <!-- end-user-doc --> 507 * @generated 508 * @ordered 509 */ 510 int AX_ROOT__LEVEL = AX_INDEX__LEVEL; 511 512 /** 495 513 * The feature id for the '<em><b>Reference</b></em>' reference. 496 514 * <!-- begin-user-doc --> … … 500 518 */ 501 519 int AX_ROOT__REFERENCE = AX_INDEX__REFERENCE; 502 503 /**504 * The feature id for the '<em><b>Level</b></em>' attribute.505 * <!-- begin-user-doc -->506 * <!-- end-user-doc -->507 * @generated508 * @ordered509 */510 int AX_ROOT__LEVEL = AX_INDEX__LEVEL;511 520 512 521 /** … … 618 627 */ 619 628 int AX_ENTRY__BASIC_PARENT = AX_INDEX_NODE__BASIC_PARENT; 629 630 /** 631 * The feature id for the '<em><b>Level</b></em>' attribute. 632 * <!-- begin-user-doc --> 633 * <!-- end-user-doc --> 634 * @generated 635 * @ordered 636 */ 637 int AX_ENTRY__LEVEL = AX_INDEX_NODE__LEVEL; 620 638 621 639 /** … … 824 842 825 843 /** 826 * Returns the meta object for the attribute '{@link org.axdt.axdoc.model.AXIndex#getLevel <em>Level</em>}'.827 * <!-- begin-user-doc -->828 * <!-- end-user-doc -->829 * @return the meta object for the attribute '<em>Level</em>'.830 * @see org.axdt.axdoc.model.AXIndex#getLevel()831 * @see #getAXIndex()832 * @generated833 */834 EAttribute getAXIndex_Level();835 836 /**837 844 * Returns the meta object for class '{@link org.axdt.axdoc.model.AXRoot <em>AX Root</em>}'. 838 845 * <!-- begin-user-doc --> … … 984 991 */ 985 992 EReference getAXIndexNode_BasicParent(); 993 994 /** 995 * Returns the meta object for the attribute '{@link org.axdt.axdoc.model.AXIndexNode#getLevel <em>Level</em>}'. 996 * <!-- begin-user-doc --> 997 * <!-- end-user-doc --> 998 * @return the meta object for the attribute '<em>Level</em>'. 999 * @see org.axdt.axdoc.model.AXIndexNode#getLevel() 1000 * @see #getAXIndexNode() 1001 * @generated 1002 */ 1003 EAttribute getAXIndexNode_Level(); 986 1004 987 1005 /** … … 1173 1191 1174 1192 /** 1175 * The meta object literal for the '<em><b>Level</b></em>' attribute feature.1176 * <!-- begin-user-doc -->1177 * <!-- end-user-doc -->1178 * @generated1179 */1180 EAttribute AX_INDEX__LEVEL = eINSTANCE.getAXIndex_Level();1181 1182 /**1183 1193 * The meta object literal for the '{@link org.axdt.axdoc.model.impl.AXRootImpl <em>AX Root</em>}' class. 1184 1194 * <!-- begin-user-doc --> … … 1300 1310 1301 1311 /** 1312 * The meta object literal for the '<em><b>Level</b></em>' attribute feature. 1313 * <!-- begin-user-doc --> 1314 * <!-- end-user-doc --> 1315 * @generated 1316 */ 1317 EAttribute AX_INDEX_NODE__LEVEL = eINSTANCE.getAXIndexNode_Level(); 1318 1319 /** 1302 1320 * The meta object literal for the '{@link org.axdt.axdoc.model.AXMemberHolder <em>AX Member Holder</em>}' class. 1303 1321 * <!-- begin-user-doc --> -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndex.java
r85b4650 r5c182b6 18 18 * <ul> 19 19 * <li>{@link org.axdt.axdoc.model.AXIndex#getReference <em>Reference</em>}</li> 20 * <li>{@link org.axdt.axdoc.model.AXIndex#getLevel <em>Level</em>}</li>21 20 * <li>{@link org.axdt.axdoc.model.AXIndex#getIndexes <em>Indexes</em>}</li> 22 21 * <li>{@link org.axdt.axdoc.model.AXIndex#getParent <em>Parent</em>}</li> … … 103 102 104 103 /** 105 * Returns the value of the '<em><b>Level</b></em>' attribute.106 * The literals are from the enumeration {@link org.axdt.axdoc.model.AXLevel}.107 * <!-- begin-user-doc -->108 * <p>109 * If the meaning of the '<em>Level</em>' attribute isn't clear,110 * there really should be more of a description here...111 * </p>112 * <!-- end-user-doc -->113 * @return the value of the '<em>Level</em>' attribute.114 * @see org.axdt.axdoc.model.AXLevel115 * @see #setLevel(AXLevel)116 * @see org.axdt.axdoc.model.AXDocPackage#getAXIndex_Level()117 * @model transient="true"118 * @generated119 */120 AXLevel getLevel();121 122 /**123 * Sets the value of the '{@link org.axdt.axdoc.model.AXIndex#getLevel <em>Level</em>}' attribute.124 * <!-- begin-user-doc -->125 * <!-- end-user-doc -->126 * @param value the new value of the '<em>Level</em>' attribute.127 * @see org.axdt.axdoc.model.AXLevel128 * @see #getLevel()129 * @generated130 */131 void setLevel(AXLevel value);132 133 /**134 104 * <!-- begin-user-doc --> 135 105 * <!-- end-user-doc --> -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndexNode.java
r2aa064d r5c182b6 22 22 * <li>{@link org.axdt.axdoc.model.AXIndexNode#getId <em>Id</em>}</li> 23 23 * <li>{@link org.axdt.axdoc.model.AXIndexNode#getBasicParent <em>Basic Parent</em>}</li> 24 * <li>{@link org.axdt.axdoc.model.AXIndexNode#getLevel <em>Level</em>}</li> 24 25 * </ul> 25 26 * </p> … … 105 106 106 107 /** 108 * Returns the value of the '<em><b>Level</b></em>' attribute. 109 * The literals are from the enumeration {@link org.axdt.axdoc.model.AXLevel}. 110 * <!-- begin-user-doc --> 111 * <p> 112 * If the meaning of the '<em>Level</em>' attribute isn't clear, 113 * there really should be more of a description here... 114 * </p> 115 * <!-- end-user-doc --> 116 * @return the value of the '<em>Level</em>' attribute. 117 * @see org.axdt.axdoc.model.AXLevel 118 * @see #setLevel(AXLevel) 119 * @see org.axdt.axdoc.model.AXDocPackage#getAXIndexNode_Level() 120 * @model 121 * @generated 122 */ 123 AXLevel getLevel(); 124 125 /** 126 * Sets the value of the '{@link org.axdt.axdoc.model.AXIndexNode#getLevel <em>Level</em>}' attribute. 127 * <!-- begin-user-doc --> 128 * <!-- end-user-doc --> 129 * @param value the new value of the '<em>Level</em>' attribute. 130 * @see org.axdt.axdoc.model.AXLevel 131 * @see #getLevel() 132 * @generated 133 */ 134 void setLevel(AXLevel value); 135 136 /** 107 137 * <!-- begin-user-doc --> 108 138 * <!-- end-user-doc --> -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXLevel.java
r79dd699 r5c182b6 31 31 * @ordered 32 32 */ 33 EMPTY(0, "EMPTY", " EMPTY"),33 EMPTY(0, "EMPTY", "e"), 34 34 35 35 /** … … 41 41 * @ordered 42 42 */ 43 PACKAGE(1, "PACKAGE", " PACKAGE"),43 PACKAGE(1, "PACKAGE", "p"), 44 44 45 45 /** … … 51 51 * @ordered 52 52 */ 53 TYPE(2, "TYPE", " TYPE"),53 TYPE(2, "TYPE", "t"), 54 54 55 55 /** … … 61 61 * @ordered 62 62 */ 63 MEMBER(4, "MEMBER", " MEMBER");63 MEMBER(4, "MEMBER", "m"); 64 64 65 65 /** … … 72 72 * <!-- end-user-doc --> 73 73 * @see #EMPTY 74 * @model 74 * @model literal="e" 75 75 * @generated 76 76 * @ordered … … 87 87 * <!-- end-user-doc --> 88 88 * @see #PACKAGE 89 * @model 89 * @model literal="p" 90 90 * @generated 91 91 * @ordered … … 102 102 * <!-- end-user-doc --> 103 103 * @see #TYPE 104 * @model 104 * @model literal="t" 105 105 * @generated 106 106 * @ordered … … 117 117 * <!-- end-user-doc --> 118 118 * @see #MEMBER 119 * @model 119 * @model literal="m" 120 120 * @generated 121 121 * @ordered -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXDocPackageImpl.java
r2aa064d r5c182b6 289 289 */ 290 290 public EReference getAXIndex_Indexes() { 291 return (EReference) axIndexEClass.getEStructuralFeatures().get(1); 292 } 293 294 /** 295 * <!-- begin-user-doc --> 296 * <!-- end-user-doc --> 297 * @generated 298 */ 299 public EReference getAXIndex_Parent() { 291 300 return (EReference) axIndexEClass.getEStructuralFeatures().get(2); 292 }293 294 /**295 * <!-- begin-user-doc -->296 * <!-- end-user-doc -->297 * @generated298 */299 public EReference getAXIndex_Parent() {300 return (EReference) axIndexEClass.getEStructuralFeatures().get(3);301 301 } 302 302 … … 315 315 * @generated 316 316 */ 317 public EAttribute getAXIndex_Level() {318 return (EAttribute) axIndexEClass.getEStructuralFeatures().get(1);319 }320 321 /**322 * <!-- begin-user-doc -->323 * <!-- end-user-doc -->324 * @generated325 */326 317 public EClass getAXRoot() { 327 318 return axRootEClass; … … 443 434 public EReference getAXIndexNode_BasicParent() { 444 435 return (EReference) axIndexNodeEClass.getEStructuralFeatures().get(3); 436 } 437 438 /** 439 * <!-- begin-user-doc --> 440 * <!-- end-user-doc --> 441 * @generated 442 */ 443 public EAttribute getAXIndexNode_Level() { 444 return (EAttribute) axIndexNodeEClass.getEStructuralFeatures().get(4); 445 445 } 446 446 … … 538 538 axIndexEClass = createEClass(AX_INDEX); 539 539 createEReference(axIndexEClass, AX_INDEX__REFERENCE); 540 createEAttribute(axIndexEClass, AX_INDEX__LEVEL);541 540 createEReference(axIndexEClass, AX_INDEX__INDEXES); 542 541 createEReference(axIndexEClass, AX_INDEX__PARENT); … … 558 557 createEAttribute(axIndexNodeEClass, AX_INDEX_NODE__ID); 559 558 createEReference(axIndexNodeEClass, AX_INDEX_NODE__BASIC_PARENT); 559 createEAttribute(axIndexNodeEClass, AX_INDEX_NODE__LEVEL); 560 560 561 561 // Create enums … … 650 650 !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, 651 651 !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); 652 initEAttribute(getAXIndex_Level(), this.getAXLevel(), "level", null, 0,653 1, AXIndex.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE,654 !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);655 652 initEReference(getAXIndex_Indexes(), this.getAXIndex(), this 656 653 .getAXIndex_Parent(), "indexes", null, 0, -1, AXIndex.class, … … 743 740 IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, 744 741 IS_ORDERED); 742 initEAttribute(getAXIndexNode_Level(), this.getAXLevel(), "level", 743 null, 0, 1, AXIndexNode.class, !IS_TRANSIENT, !IS_VOLATILE, 744 IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, 745 IS_ORDERED); 745 746 746 747 addEOperation(axIndexNodeEClass, this.getAXRoot(), "getRoot", 0, 1, -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXEntryImpl.java
r2aa064d r5c182b6 15 15 import org.axdt.axdoc.model.AXIndex; 16 16 import org.axdt.axdoc.model.AXIndexNode; 17 import org.axdt.axdoc.model.AXLevel; 17 18 import org.axdt.axdoc.model.AXMember; 18 19 import org.axdt.axdoc.model.AXMemberHolder; … … 281 282 return getBasicParent(); 282 283 return basicGetBasicParent(); 284 case AXDocPackage.AX_ENTRY__LEVEL: 285 return getLevel(); 283 286 case AXDocPackage.AX_ENTRY__TYPE: 284 287 return getType(); … … 309 312 getEntries().addAll((Collection<? extends AXEntry>) newValue); 310 313 return; 314 case AXDocPackage.AX_ENTRY__LEVEL: 315 setLevel((AXLevel) newValue); 316 return; 311 317 case AXDocPackage.AX_ENTRY__TYPE: 312 318 setType((AXEntryType) newValue); … … 335 341 case AXDocPackage.AX_ENTRY__ENTRIES: 336 342 getEntries().clear(); 343 return; 344 case AXDocPackage.AX_ENTRY__LEVEL: 345 setLevel(LEVEL_EDEFAULT); 337 346 return; 338 347 case AXDocPackage.AX_ENTRY__TYPE: … … 366 375 case AXDocPackage.AX_ENTRY__BASIC_PARENT: 367 376 return basicGetBasicParent() != null; 377 case AXDocPackage.AX_ENTRY__LEVEL: 378 return level != LEVEL_EDEFAULT; 368 379 case AXDocPackage.AX_ENTRY__TYPE: 369 380 return type != TYPE_EDEFAULT; … … 431 442 */ 432 443 public String getId() { 433 if (this.id != null) return this.id; 444 if (this.id != null) 445 return this.id; 434 446 if (name != null) { 435 447 AXIndexNode parent = getParent(); 436 448 if (parent == null && parent instanceof AXRoot) { 437 id = "::" +name +"#"+ getType();449 id = "::" + name + "#" + getType(); 438 450 } else { 439 451 id = parent.getId(); 440 452 id += parent instanceof AXIndex ? "::" : "."; 441 id += name + "#"+ getType();453 id += name + "#" + getType(); 442 454 } 443 455 } -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexImpl.java
r2aa064d r5c182b6 37 37 * <ul> 38 38 * <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getReference <em>Reference</em>}</li> 39 * <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getLevel <em>Level</em>}</li>40 39 * <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getIndexes <em>Indexes</em>}</li> 41 40 * <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getParent <em>Parent</em>}</li> … … 55 54 */ 56 55 protected AXPackage reference; 57 /**58 * The default value of the '{@link #getLevel() <em>Level</em>}' attribute.59 * <!-- begin-user-doc -->60 * <!-- end-user-doc -->61 * @see #getLevel()62 * @generated63 * @ordered64 */65 protected static final AXLevel LEVEL_EDEFAULT = AXLevel.EMPTY;66 /**67 * The cached value of the '{@link #getLevel() <em>Level</em>}' attribute.68 * <!-- begin-user-doc -->69 * <!-- end-user-doc -->70 * @see #getLevel()71 * @generated72 * @ordered73 */74 protected AXLevel level = LEVEL_EDEFAULT;75 56 /** 76 57 * The cached value of the '{@link #getIndexes() <em>Indexes</em>}' containment reference list. … … 237 218 * <!-- begin-user-doc --> 238 219 * <!-- end-user-doc --> 239 * @generated240 */241 public AXLevel getLevel() {242 return level;243 }244 245 /**246 * <!-- begin-user-doc -->247 * <!-- end-user-doc -->248 * @generated249 */250 public void setLevel(AXLevel newLevel) {251 AXLevel oldLevel = level;252 level = newLevel == null ? LEVEL_EDEFAULT : newLevel;253 if (eNotificationRequired())254 eNotify(new ENotificationImpl(this, Notification.SET,255 AXDocPackage.AX_INDEX__LEVEL, oldLevel, level));256 }257 258 /**259 * <!-- begin-user-doc -->260 * <!-- end-user-doc -->261 220 */ 262 221 public String fullUrl() { … … 390 349 return getBasicParent(); 391 350 return basicGetBasicParent(); 351 case AXDocPackage.AX_INDEX__LEVEL: 352 return getLevel(); 392 353 case AXDocPackage.AX_INDEX__REFERENCE: 393 354 if (resolve) 394 355 return getReference(); 395 356 return basicGetReference(); 396 case AXDocPackage.AX_INDEX__LEVEL:397 return getLevel();398 357 case AXDocPackage.AX_INDEX__INDEXES: 399 358 return getIndexes(); … … 420 379 getEntries().addAll((Collection<? extends AXEntry>) newValue); 421 380 return; 381 case AXDocPackage.AX_INDEX__LEVEL: 382 setLevel((AXLevel) newValue); 383 return; 422 384 case AXDocPackage.AX_INDEX__REFERENCE: 423 385 setReference((AXPackage) newValue); 424 386 return; 425 case AXDocPackage.AX_INDEX__LEVEL:426 setLevel((AXLevel) newValue);427 return;428 387 case AXDocPackage.AX_INDEX__INDEXES: 429 388 getIndexes().clear(); … … 451 410 getEntries().clear(); 452 411 return; 412 case AXDocPackage.AX_INDEX__LEVEL: 413 setLevel(LEVEL_EDEFAULT); 414 return; 453 415 case AXDocPackage.AX_INDEX__REFERENCE: 454 416 setReference((AXPackage) null); 455 return;456 case AXDocPackage.AX_INDEX__LEVEL:457 setLevel(LEVEL_EDEFAULT);458 417 return; 459 418 case AXDocPackage.AX_INDEX__INDEXES: … … 484 443 case AXDocPackage.AX_INDEX__BASIC_PARENT: 485 444 return basicGetBasicParent() != null; 445 case AXDocPackage.AX_INDEX__LEVEL: 446 return level != LEVEL_EDEFAULT; 486 447 case AXDocPackage.AX_INDEX__REFERENCE: 487 448 return reference != null; 488 case AXDocPackage.AX_INDEX__LEVEL:489 return level != LEVEL_EDEFAULT;490 449 case AXDocPackage.AX_INDEX__INDEXES: 491 450 return indexes != null && !indexes.isEmpty(); … … 494 453 } 495 454 return eDynamicIsSet(featureID); 496 }497 498 /**499 * <!-- begin-user-doc -->500 * <!-- end-user-doc -->501 * @generated502 */503 @Override504 public String toString() {505 if (eIsProxy())506 return super.toString();507 508 StringBuffer result = new StringBuffer(super.toString());509 result.append(" (level: ");510 result.append(level);511 result.append(')');512 return result.toString();513 455 } 514 456 -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexNodeImpl.java
r2aa064d r5c182b6 14 14 import org.axdt.axdoc.model.AXEntryType; 15 15 import org.axdt.axdoc.model.AXIndexNode; 16 import org.axdt.axdoc.model.AXLevel; 16 17 import org.axdt.axdoc.model.AXNode; 17 18 import org.axdt.axdoc.model.AXRoot; … … 38 39 * <li>{@link org.axdt.axdoc.model.impl.AXIndexNodeImpl#getId <em>Id</em>}</li> 39 40 * <li>{@link org.axdt.axdoc.model.impl.AXIndexNodeImpl#getBasicParent <em>Basic Parent</em>}</li> 41 * <li>{@link org.axdt.axdoc.model.impl.AXIndexNodeImpl#getLevel <em>Level</em>}</li> 40 42 * </ul> 41 43 * </p> … … 105 107 106 108 /** 109 * The default value of the '{@link #getLevel() <em>Level</em>}' attribute. 110 * <!-- begin-user-doc --> 111 * <!-- end-user-doc --> 112 * @see #getLevel() 113 * @generated 114 * @ordered 115 */ 116 protected static final AXLevel LEVEL_EDEFAULT = AXLevel.EMPTY; 117 118 /** 119 * The cached value of the '{@link #getLevel() <em>Level</em>}' attribute. 120 * <!-- begin-user-doc --> 121 * <!-- end-user-doc --> 122 * @see #getLevel() 123 * @generated 124 * @ordered 125 */ 126 protected AXLevel level = LEVEL_EDEFAULT; 127 128 /** 107 129 * <!-- begin-user-doc --> 108 130 * <!-- end-user-doc --> … … 184 206 */ 185 207 public abstract AXIndexNode basicGetBasicParent(); 208 209 /** 210 * <!-- begin-user-doc --> 211 * <!-- end-user-doc --> 212 * @generated 213 */ 214 public AXLevel getLevel() { 215 return level; 216 } 217 218 /** 219 * <!-- begin-user-doc --> 220 * <!-- end-user-doc --> 221 * @generated 222 */ 223 public void setLevel(AXLevel newLevel) { 224 AXLevel oldLevel = level; 225 level = newLevel == null ? LEVEL_EDEFAULT : newLevel; 226 if (eNotificationRequired()) 227 eNotify(new ENotificationImpl(this, Notification.SET, 228 AXDocPackage.AX_INDEX_NODE__LEVEL, oldLevel, level)); 229 } 186 230 187 231 /** … … 402 446 return getBasicParent(); 403 447 return basicGetBasicParent(); 448 case AXDocPackage.AX_INDEX_NODE__LEVEL: 449 return getLevel(); 404 450 } 405 451 return eDynamicGet(featureID, resolve, coreType); … … 422 468 getEntries().addAll((Collection<? extends AXEntry>) newValue); 423 469 return; 470 case AXDocPackage.AX_INDEX_NODE__LEVEL: 471 setLevel((AXLevel) newValue); 472 return; 424 473 } 425 474 eDynamicSet(featureID, newValue); … … 439 488 case AXDocPackage.AX_INDEX_NODE__ENTRIES: 440 489 getEntries().clear(); 490 return; 491 case AXDocPackage.AX_INDEX_NODE__LEVEL: 492 setLevel(LEVEL_EDEFAULT); 441 493 return; 442 494 } … … 461 513 case AXDocPackage.AX_INDEX_NODE__BASIC_PARENT: 462 514 return basicGetBasicParent() != null; 515 case AXDocPackage.AX_INDEX_NODE__LEVEL: 516 return level != LEVEL_EDEFAULT; 463 517 } 464 518 return eDynamicIsSet(featureID); … … 480 534 result.append(", id: "); 481 535 result.append(id); 536 result.append(", level: "); 537 result.append(level); 482 538 result.append(')'); 483 539 return result.toString(); -
org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXRootImpl.java
r2d81bf0 r5c182b6 275 275 return getBasicParent(); 276 276 return basicGetBasicParent(); 277 case AXDocPackage.AX_ROOT__LEVEL: 278 return getLevel(); 277 279 case AXDocPackage.AX_ROOT__REFERENCE: 278 280 if (resolve) 279 281 return getReference(); 280 282 return basicGetReference(); 281 case AXDocPackage.AX_ROOT__LEVEL:282 return getLevel();283 283 case AXDocPackage.AX_ROOT__INDEXES: 284 284 return getIndexes(); … … 313 313 getEntries().addAll((Collection<? extends AXEntry>) newValue); 314 314 return; 315 case AXDocPackage.AX_ROOT__LEVEL: 316 setLevel((AXLevel) newValue); 317 return; 315 318 case AXDocPackage.AX_ROOT__REFERENCE: 316 319 setReference((AXPackage) newValue); 317 return;318 case AXDocPackage.AX_ROOT__LEVEL:319 setLevel((AXLevel) newValue);320 320 return; 321 321 case AXDocPackage.AX_ROOT__INDEXES: … … 356 356 getEntries().clear(); 357 357 return; 358 case AXDocPackage.AX_ROOT__LEVEL: 359 setLevel(LEVEL_EDEFAULT); 360 return; 358 361 case AXDocPackage.AX_ROOT__REFERENCE: 359 362 setReference((AXPackage) null); 360 return;361 case AXDocPackage.AX_ROOT__LEVEL:362 setLevel(LEVEL_EDEFAULT);363 363 return; 364 364 case AXDocPackage.AX_ROOT__INDEXES: … … 401 401 case AXDocPackage.AX_ROOT__BASIC_PARENT: 402 402 return basicGetBasicParent() != null; 403 case AXDocPackage.AX_ROOT__LEVEL: 404 return level != LEVEL_EDEFAULT; 403 405 case AXDocPackage.AX_ROOT__REFERENCE: 404 406 return reference != null; 405 case AXDocPackage.AX_ROOT__LEVEL:406 return level != LEVEL_EDEFAULT;407 407 case AXDocPackage.AX_ROOT__INDEXES: 408 408 return indexes != null && !indexes.isEmpty(); -
org.axdt.axdoc.test/src/org/axdt/axdoc/util/Index0rTest.java
r2aa064d r5c182b6 46 46 // takes to long for a test... 47 47 // index.parseAsDoc(pathUrl,AXLevel.TYPE, null); 48 index.docParser.parseLocalTypeLevel(index.roots.get(pathUrl)); 48 AXDocParser docParser = new AXDocParser(); 49 docParser.parseLocalTypeLevel(index.roots.get(pathUrl)); 49 50 assertEquals(2, index.find("::Array").length); 50 51 AXEntry node1 = (AXEntry)index.find("::Array")[0]; -
org.axdt.axdoc/src/org/axdt/axdoc/util/AXDocParser.java
r2aa064d r5c182b6 21 21 import org.xml.sax.SAXException; 22 22 23 // TODO: use ProgressMonitor 24 // TODO: parse member level on request 25 @SuppressWarnings("unused") 23 26 public class AXDocParser { 24 27 protected static String[] SORTED_DOC_NAMES = new String[]{ … … 192 195 } 193 196 AXEntry memberIndex = index.createEntry(memberName, type); 197 memberIndex.getOrCreateReference(); 194 198 log(3,"[DDD] found member ", memberIndex); 195 199 } … … 211 215 } 212 216 AXEntry typeIndex = index.createEntry(typeName, entryType); 217 typeIndex.getOrCreateReference(); 213 218 // load type doc summary 214 219 if (loadSummary) { … … 233 238 Node[] contentDivs = loader.eIter(findMain, html); 234 239 // between the two is the summary 235 if (contentDivs.length<2 && debug>0) { 236 log(1,"[ww] no content div for ", result); 240 if (contentDivs.length<2) { 241 if (debug>0) 242 log(1,"[ww] no content div for ", result); 237 243 return; 238 244 } … … 243 249 parseTypeMembers(result, contentDivs[1]); 244 250 245 //result.setLevel(AXLevel.MEMBER);251 result.setLevel(AXLevel.MEMBER); 246 252 } catch (FileNotFoundException e) { /* ignore */ } 247 253 catch (SAXException e) { e.printStackTrace(); } … … 253 259 Node[] headers = loader.eIter(findTypeHeader, headerNode); 254 260 // TODO ATTENTION 255 if (debug < 2) return; 256 String logString = "[DDD] found header"; 257 for (Node headerInfo:headers) { 258 logString += " "+ headerInfo.getTextContent().trim(); 259 } 260 log(3,logString); 261 if (debug >= 2) { 262 String logString = "[DDD] found header"; 263 for (Node headerInfo:headers) { 264 logString += " "+ headerInfo.getTextContent().trim(); 265 } 266 log(3,logString); 267 } 261 268 } 262 269 … … 284 291 decl = split[1].trim(); 285 292 } 286 if (decl.contains("=")) { 287 // has initializer 288 String[] split = decl.split("=",2); 289 decl = split[0].trim(); 290 init = split[1].trim(); 291 } 292 if (decl.contains(":")) { 293 String[] split = decl.split(":",2); 294 name = split[0].trim(); 295 type = split[1].trim(); 293 if (!childCode.contains("function")) { 294 if (decl.contains("=")) { 295 // has initializer 296 String[] split = decl.split("=",2); 297 decl = split[0].trim(); 298 init = split[1].trim(); 299 } 300 } 301 int lastParen = decl.lastIndexOf(")"); 302 int last = decl.lastIndexOf(":"); 303 if (last > 0 && last > lastParen) { 304 name = decl.substring(0,last).trim(); 305 type = decl.substring(last+1).trim(); 296 306 } else { 297 307 // might be constructor … … 299 309 type = typeIndex.getId(); 300 310 } 301 if (name.endsWith("()")) { 302 name = name.substring(0,name.length()-2); 311 // check for parameters 312 if (lastParen > 0) { 313 name = name.substring(0,name.indexOf("(")); 303 314 } 304 315 AXEntry memberIndex = typeIndex.createEntry(name, entryType); 316 memberIndex.getOrCreateReference(); 305 317 // create reference 306 memberIndex.getOrCreateReference();307 318 typeIndex.getEntries().add(memberIndex); 308 319 return memberIndex; … … 321 332 } 322 333 } 334 private Node getReal(Node node) { 335 while (node != null 336 && ((node.getNodeType() == Node.TEXT_NODE && node.getTextContent().trim().length() == 0) 337 || "br".equals(node.getNodeName()) 338 )) { 339 node = node.getNextSibling(); 340 } 341 return node; 342 } 323 343 private void parseTypeMemberInfo(AXEntry typeIndex, Node detail) throws DOMException, XPathExpressionException { 324 344 AXEntryType entryType = parseTypeMemberEntryType(detail); 325 345 if (entryType == null) 326 346 return; 327 Node child = detail.getFirstChild();347 Node child = getReal(detail.getFirstChild()); 328 348 // child contains the declaration string 329 349 String childCode = child.getTextContent().trim(); 330 350 log(3,"[DDD] found detail: "+ childCode); 331 351 AXEntry memberIndex = createTypeMemberEntry(typeIndex,entryType,childCode); 332 child = child.getNextSibling(); 352 child = getReal(child.getNextSibling()); 353 if (child == null) 354 return; 333 355 boolean isGetterSetter = child.getNodeType() == Node.TEXT_NODE; 334 356 if (isGetterSetter) { 335 357 // if accessor property (getter setter) ignore 336 child = child.getNextSibling();358 child = getReal(child.getNextSibling()); 337 359 } 338 360 if (child.getNodeName().equals("div")) { 339 361 // ignore deprecated info divs 340 child = child.getNextSibling();362 child = getReal(child.getNextSibling()); 341 363 } 342 364 // ignore empty paragraph and following empty breaks 343 do {344 child = child.getNextSibling();345 } while (child != null && "br".equals(child.getNodeName()));346 365 // TODO tables with info about flash player version and the sort. 347 366 while (child != null && "table".equals(child.getNodeName())) { 348 child = child.getNextSibling();367 child = getReal(child.getNextSibling()); 349 368 } 350 369 // ignore all empty text nodes, breaks and paragraphs 351 370 while (child != null && !child.hasChildNodes()&&("".equals(child.getTextContent())||child.getNodeType() == Node.TEXT_NODE)) { 352 child = child.getNextSibling();371 child = getReal(child.getNextSibling()); 353 372 } 354 373 while (child != null && looksLikeDocNode(child)) { 355 374 // clean up doc and add to axmember 356 375 do { 357 child = child.getNextSibling();376 child = getReal(child.getNextSibling()); 358 377 } while (child != null && child.getNodeType() == Node.TEXT_NODE); 359 }360 while (child != null && "br".equals(child.getNodeName())) {361 child = child.getNextSibling();362 378 } 363 379 // we might be at the end … … 367 383 } 368 384 private AXEntryType getEntryType(String headerType) { 385 if (headerType == null) 386 return null; 387 headerType = headerType.toLowerCase(); 369 388 if ("method".equals(headerType)) { 370 389 return AXEntryType.METHOD; … … 373 392 return AXEntryType.PROPERTY; 374 393 } else 375 if (" Constant".equals(headerType)) {394 if ("constant".equals(headerType)) { 376 395 return AXEntryType.CONSTANT; 377 396 } else 378 if (" Constructor".equals(headerType)) {397 if ("constructor".equals(headerType)) { 379 398 return AXEntryType.CONSTRUCTOR; 380 399 } … … 383 402 private String parseTypeMemberHeader(Node detail) throws DOMException, XPathExpressionException { 384 403 Node header = detail.getPreviousSibling(); 385 if (header.getNodeName().equals("br")) header = header.getPreviousSibling(); 404 while (header.getNodeType() == Node.TEXT_NODE || header.getNodeName().equals("br")) 405 header = header.getPreviousSibling(); 386 406 if (header.getNodeName().equals("div")) return "Example"; 387 return loader.eval(findDetailType, header).getTextContent().trim(); 407 Node eval = loader.eval(findDetailType, header); 408 return eval == null || eval.getTextContent() == null ? null : eval.getTextContent().trim(); 388 409 } 389 410 protected boolean looksLikeDocNode(Node child) throws XPathExpressionException { -
org.axdt.axdoc/src/org/axdt/axdoc/util/Index0r.java
r2aa064d r5c182b6 15 15 import org.axdt.axdoc.model.AXIndexNode; 16 16 import org.axdt.axdoc.model.AXLevel; 17 import org.axdt.axdoc.model.AXNode; 17 18 import org.axdt.axdoc.model.AXRoot; 18 19 import org.axdt.axdoc.model.AXRootType; … … 28 29 import org.eclipse.emf.ecore.resource.ResourceSet; 29 30 import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 31 import org.eclipse.emf.ecore.util.EcoreUtil; 30 32 31 33 public class Index0r { … … 42 44 protected Map<String, AXRoot> roots; 43 45 protected Map<String, List<AXIndex>> packages; 44 protected AXDocParser docParser;45 46 protected URI baseURI; 46 47 … … 48 49 roots = Collections.synchronizedMap(new HashMap<String, AXRoot>()); 49 50 packages = Collections.synchronizedMap(new HashMap<String, List<AXIndex>>()); 50 docParser = new AXDocParser();51 51 52 baseURI = createBaseUri(); 52 53 } … … 118 119 } 119 120 public AXRoot addSourceRoot(IContainer sourcefolder) { 121 if (sourcefolder == null) return null; 120 122 String uri = getSourceUri(sourcefolder); 121 AXRoot root = roots.get(uri); 122 if (root == null) { 123 String path = sourcefolder.getFullPath().toString(); 124 root = Index0r.getInstance().addRoot("source "+path, uri, AXRootType.SOURCE); 125 } 123 String path = sourcefolder.getFullPath().toString(); 124 AXRoot root = Index0r.getInstance().addRoot("source "+path, uri, AXRootType.SOURCE); 126 125 return root; 127 126 } … … 162 161 if (root.getRootType() == AXRootType.ASDOC) { 163 162 try { 163 AXDocParser docParser = new AXDocParser(); 164 164 docParser.parseDoc(root, level); 165 165 if (root.isDirty()) … … 178 178 if (index == null) 179 179 return; 180 try {181 index.save(null);182 } catch (IOException e) {183 log("error saving asdoc at "+root.getUrl(), e);184 }185 180 EList<Resource> resources = index.getResourceSet().getResources(); 186 181 for (Resource res:resources) { 187 if (index.equals(res))188 continue;189 182 try { 190 183 res.save(null); … … 202 195 Resource[] resources = list.toArray(new Resource[list.size()]); 203 196 for (Resource res:resources) { 204 if (index.equals(res)) continue; 197 if (index.equals(res)) 198 continue; 205 199 try { 206 200 res.delete(null); … … 209 203 } 210 204 } 211 index.getContents().clear(); 205 for (EObject eobj:root.eContents()) 206 EcoreUtil.remove(eobj); 212 207 } 213 208 protected void log(String text, Exception e) { … … 267 262 return packages.get(packname); 268 263 } 264 public void requestFull(AXEntry entry) { 265 if (entry == null) return; 266 AXRoot root = entry.getRoot(); 267 if (root == null || !root.getRootType().equals(AXRootType.ASDOC)) return; 268 if (root.getRootLevel().getValue() > AXLevel.TYPE_VALUE) return; 269 if (entry.getLevel() != null && entry.getLevel().getValue() > AXLevel.TYPE_VALUE) return; 270 try { 271 AXDocParser docParser = new AXDocParser(); 272 docParser.parseTypeMemberLevel(entry); 273 saveEntry(entry); 274 } catch (Exception e) { 275 AXDocPlugin.getDefault().log("error parsing requested type", e); 276 } 277 } 278 protected void saveEntry(AXEntry entry) throws IOException { 279 AXNode reference = entry.getReference(); 280 if (reference != null) { 281 Resource resource = reference.eResource(); 282 resource.save(null); 283 } 284 Resource resource = entry.eResource(); 285 resource.save(null); 286 } 269 287 } -
org.axdt.common/src/org/axdt/util/IFlexErrorCodes.java
r79dd699 r5c182b6 177 177 int IncompatibleInterfaceMethodSignature = 1144; 178 178 // 57 to go 179 int NativeMethodBody = 1145; 180 int ConstructorAccessor = 1146; 181 int SourceFileNotSpecified = 1147; 182 int ReturnInStaticInitialization = 1148; 183 int ProtectedNotInClass = 1150; 184 int DefinitionNamespaceConflict = 1151; 185 int DefinitionNamespaceConflictInherited = 1152; 186 int ConstructorNotPublic = 1153; 187 int AttributesConflict = 1154; 179 188 }
