Changeset 5c182b6e475d5851c54cdb2117f25af21723b62a

Show
Ignore:
Timestamp:
06/29/09 07:06:59 (14 months ago)
Author:
mb0 <mb0@…>
Children:
8a0050b3611b877b0c6c480dc26f48d9afa9c369
Parents:
2aa064d78a2c1162da70e2413b7c386278a1473d
git-committer:
mb0 <mb0@…> (06/29/09 07:06:59)
Message:

memory clean up ! (and several minor fixes)

  • merged symboltablevisitor and indexingvisitor together with some basic syntax checks to form as3analysis
  • index0r can now be used to request details on demand.
  • axdoc parser ignores whitespace textnodes and now parses the member code span
  • axdoc model: moved level property to indexnode and changed it to be persisted
  • changed axlevel literals
  • discover memory leak  http://bugs.eclipse.org/281790, cleaned up with editor service.
  • moved usefull generally useful methods out of as3 content proposer into as3 source helper
  • when no index exists for a source folder the project will be built and cached.
  • builder does not cache anymore instead builds two times. the first time to index. the second time to resolve.
  • lexer helper error detection fixed ater working through the sparce documentation on lpgs deterministic parser.
  • moved top level symbol table to the program ast node
  • some minor parser changed
Files:
5 added
2 removed
33 modified

Legend:

Unmodified
Added
Removed
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/BasicParserTest.java

    rb32f7a4 r5c182b6  
    1919import org.axdt.as3.imp.parser.Ast.StringLiteral; 
    2020import org.axdt.as3.imp.parser.Ast.VariableDefinition; 
     21import org.axdt.as3.imp.parser.ParseUtil.ParserContext; 
    2122 
    2223public class BasicParserTest extends TestCase { 
    23         private AS3Parser parser; 
     24        private ParserContext context; 
    2425        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); 
    2728        } 
    2829        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); 
    3132                return assertFirstDirective(result, clazz); 
    3233        } 
     
    3839                } else { 
    3940                        // TODO gather some info 
    40                         ArrayList tokens = parser.getIPrsStream().getTokens(); 
     41                        ArrayList tokens = context.parser.getIPrsStream().getTokens(); 
    4142                        assertNotNull("parser error "+ tokens.toString(),prog); 
    4243                } 
     
    7980 
    8081                // bom works just as expected 
    81                 assertNotNull(parse("\u00ef\u00bb\u00bf package {}")); 
     82                prog = parse("\u00ef\u00bb\u00bf package {}"); 
     83                assertNotNull(prog); 
    8284                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); 
    8488                 
    8589                prog = parse("package P{} package Q{}"); 
     
    9397                System.out.print("expected"); 
    9498                prog = parse("package P{} function f(){} package Q{}"); 
     99                // when using parseActions finds the first package but fails to parse the following directives  
    95100                assertNull(prog); 
    96101        } 
     
    157162                def = assertFirstDirective("function f():void{}",FunctionDefinition.class); 
    158163 
    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); 
    160165                assertEquals("f", def.getName().toString()); 
    161166                assertEquals(2, def.getBlock().getDirectives().size()); 
    162167                FunctionCommon common = def.getCommon(); 
    163168                assertEquals(null, common.getResultType()); 
     169                assertEquals(2, common.getParameters().size()); 
    164170 
    165171                def = assertFirstDirective("function f(){}",FunctionDefinition.class); 
     
    171177                def = assertFirstDirective("function get f(i){}",FunctionDefinition.class); 
    172178                def = assertFirstDirective("function get f(a:A,b:B){}",FunctionDefinition.class); 
    173                 // TODO fix parameter declaration 
    174179                def = assertFirstDirective("function set(){}",FunctionDefinition.class); 
    175180                def = assertFirstDirective("function get(a,b){}",FunctionDefinition.class); 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/ExpressionTest.java

    rb32f7a4 r5c182b6  
    122122                assertExpression(parse("i..x"), Query.class); 
    123123                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); 
    125126                assertExpression(parse("i++"), PostIncrementExpression.class); 
    126127                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); 
    127131        } 
    128132        public void testNew() throws Exception { 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/ParseUtil.java

    rb32f7a4 r5c182b6  
    2020        } 
    2121        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); 
    2424        } 
    2525        public static Program parse(AS3Parser parser, int repair) { 
     
    2929                return null; 
    3030        } 
    31         public static AS3Parser parser(String content) { 
     31        public static ParserContext parser(String content) { 
    3232                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                } 
    3959        } 
    4060} 
  • org.axdt.as3.test/src/org/axdt/as3/imp/parser/VirtualSemiTest.java

    rb32f7a4 r5c182b6  
    11package org.axdt.as3.imp.parser; 
    22 
     3import java.util.ArrayList; 
     4 
    35import org.axdt.as3.imp.parser.Ast.Program; 
     6import org.axdt.as3.imp.parser.ParseUtil.ParserContext; 
    47 
    58import junit.framework.TestCase; 
     9import lpg.runtime.IToken; 
    610 
    711public class VirtualSemiTest extends TestCase { 
    812 
    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); 
    1125        } 
    1226        public void testLineBreakVirtualSemi() throws Exception { 
    13                 // TODO check that the parser should not insert v semi 
    14                 assertNotNull(parse("{var i = 0;\nvar j = 1;}")); 
    15                 // TODO dont insert if there is a semi  
    16                 assertNotNull(parse("{var i = 0\n;var j = 1;}")); 
    17                 assertNotNull(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); 
    1832        } 
    1933        public void testGrammarVirtualSemi() throws Exception { 
    2034                // abbrev semi is inserted before RCURLY or EOF 
    21                 assertNotNull(parse("var j = 1")); 
    22                 assertNotNull(parse("var j = 1;")); 
    23                 assertNotNull(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); 
    2438        } 
    2539} 
  • org.axdt.as3/src/org/axdt/as3/AS3Plugin.java

    r364575f r5c182b6  
    44import java.net.URL; 
    55 
     6import org.axdt.as3.imp.builders.AS3Builder; 
    67import org.axdt.as3.imp.builders.AS3Nature; 
    78import org.axdt.as3.preferences.AS3Preferences; 
    89import org.axdt.as3.templates.AS3ContextType; 
    9 import org.axdt.axdoc.model.AXRootType; 
     10import org.axdt.axdoc.model.AXRoot; 
    1011import org.axdt.axdoc.util.Index0r; 
    1112import org.axdt.common.preferences.AxdtPreferences; 
    1213import org.eclipse.core.resources.IContainer; 
    1314import org.eclipse.core.resources.IProject; 
     15import org.eclipse.core.resources.IncrementalProjectBuilder; 
    1416import org.eclipse.core.resources.ResourcesPlugin; 
    1517import org.eclipse.core.runtime.CoreException; 
    1618import org.eclipse.core.runtime.FileLocator; 
    1719import org.eclipse.core.runtime.IPath; 
     20import org.eclipse.core.runtime.IProgressMonitor; 
    1821import org.eclipse.core.runtime.Path; 
    1922import org.eclipse.core.runtime.Status; 
    2023import org.eclipse.core.runtime.preferences.ConfigurationScope; 
    2124import org.eclipse.core.runtime.preferences.IScopeContext; 
    22 import org.eclipse.emf.common.util.URI; 
    2325import org.eclipse.imp.runtime.PluginBase; 
    2426import org.eclipse.jface.preference.IPreferenceStore; 
     
    161163         
    162164        private void initializeIndex() { 
     165                IProgressMonitor monitor = null; 
    163166                Index0r index0r = Index0r.getInstance(); 
    164167                // asdoc locations are added on axdoc plugin start 
     
    172175                        } 
    173176                        IContainer[] paths = AS3Preferences.getSourcePaths(project); 
     177                        boolean needsBuild = false; 
    174178                        for (IContainer srcPath:paths) { 
    175179                                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                                } 
    179193                        } 
    180194                } 
  • org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java

    r2aa064d r5c182b6  
    11package org.axdt.as3.imp.builders; 
    22 
    3 import java.util.ArrayList; 
    43import java.util.Arrays; 
     4import java.util.Collection; 
     5import java.util.HashSet; 
    56import java.util.List; 
    67import java.util.Map; 
     
    89import org.axdt.as3.AS3Plugin; 
    910import org.axdt.as3.imp.parser.AS3ParseController; 
     11import org.axdt.as3.imp.parser.ResolvingVisitor; 
     12import org.axdt.as3.imp.parser.Ast.ASTNode; 
    1013import org.axdt.as3.preferences.AS3Preferences; 
    11 import org.axdt.as3.util.AS3Util; 
    1214import org.axdt.axdoc.model.AXRoot; 
    1315import org.axdt.axdoc.util.Index0r; 
     
    1618import org.eclipse.core.resources.IProject; 
    1719import org.eclipse.core.resources.IResource; 
     20import org.eclipse.core.resources.IResourceDelta; 
     21import org.eclipse.core.resources.IResourceDeltaVisitor; 
     22import org.eclipse.core.resources.IResourceVisitor; 
     23import org.eclipse.core.resources.IncrementalProjectBuilder; 
    1824import org.eclipse.core.runtime.CoreException; 
    1925import org.eclipse.core.runtime.IPath; 
    2026import org.eclipse.core.runtime.IProgressMonitor; 
     27import org.eclipse.core.runtime.SubProgressMonitor; 
    2128import org.eclipse.core.runtime.content.IContentDescription; 
    22 import org.eclipse.imp.builder.BuilderBase; 
    2329import org.eclipse.imp.builder.BuilderUtils; 
    2430import org.eclipse.imp.builder.MarkerCreator; 
     
    2834import org.eclipse.imp.model.ModelFactory; 
    2935import org.eclipse.imp.model.ModelFactory.ModelException; 
     36import org.eclipse.imp.parser.IMessageHandler; 
    3037import org.eclipse.imp.runtime.PluginBase; 
    3138import org.eclipse.imp.services.IAnnotationTypeInfo; 
     
    3643 * "Build" a project. 
    3744 */ 
    38 public class AS3Builder extends BuilderBase { 
    39  
     45public class AS3Builder extends IncrementalProjectBuilder { 
    4046        public static final String BUILDER_ID = AS3Plugin.PLUGIN_ID + ".imp.builder"; 
    4147        public static final String PROBLEM_MARKER_ID = AS3Plugin.PLUGIN_ID + ".imp.builder.problem"; 
    4248        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; 
    4954 
    5055        protected PluginBase getPlugin() { 
     
    5661        } 
    5762 
    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         
    11077        @Override 
    11178        @SuppressWarnings("unchecked") 
    11279        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); 
    12090                        } 
    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); 
    122123                        // 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); 
    128126                        // 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 
    140178        /** 
    141179         * Compile one AS3 file. 
    142180         * It will not actually compile, but analyze and index the model. 
    143181         */ 
    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); 
    146184                // if controller could not be created or initialized  
    147185                if (parse == null || parse.getProject() == null)  
    148186                        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) { 
    149197                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) { 
    158202                // first char might be misread utf8 char 
    159203                return contents.charAt(0) == 0xfeff ?    
     
    161205        } 
    162206 
    163         private boolean hasBom(IFile file) { 
     207        protected boolean hasBom(IFile file) { 
    164208                try { 
    165209                        IContentDescription info = file.getContentDescription(); 
     
    170214 
    171215        @SuppressWarnings("unchecked") 
    172         private AS3ParseController getParseController(IFile file) { 
     216        protected AS3ParseController getParseController(IFile file, boolean reportErrors) { 
    173217                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) { 
    175231                List<List<String>> lists = Arrays.asList(typeInfo.getProblemMarkerTypes()); 
    176232                boolean found = false; 
     
    182238                } 
    183239                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; 
    201267        } 
    202268} 
     269class 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  
    6363                        HelperAst ast = parseXml(offset); 
    6464                        return tryAst(ast, AS3Parsersym.TK_Xml); 
    65                 } else 
    66                         errorDetected(); 
     65                } 
    6766                return false; 
    6867        } 
     
    7473                        HelperAst ast = parseRegex(offset); 
    7574                        return tryAst(ast, AS3Parsersym.TK_RegularExpression); 
    76                 } else 
    77                         errorDetected(); 
     75                } 
    7876                return false; 
    7977        } 
     
    8482                prs.makeToken(ast.start, ast.end, kind); 
    8583                lexer.getParser().resetTokenStream(ast.end + 1); 
     84                prs.reset(ast.end + 1); 
    8685                return true; 
    8786        } 
     
    146145                boolean isNewLine = detectedLineBreak; 
    147146                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; 
    157170                                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)) { 
    172178                        if (isNewLine) { 
    173179                                // line-break semicolon insertion 
     
    183189                                        int end = getLast().getEndOffset(); 
    184190                                        prs.makeToken(end + 1, end, AS3Parsersym.TK_NO_LINE_BREAK); 
    185                                 } else 
    186                                         errorDetected(); 
    187                         } 
     191                                } 
     192                        } 
     193                        if (tryXmlOrRegex(kind,s)) return; 
    188194                        if (hasError(kind)) 
    189195                                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) { 
    191202                switch (kind) { 
    192203                // check for xml 
    193204                case AS3Parsersym.TK_LT: 
    194                         if (tryXml(s)) 
    195                                 return; 
    196                         else 
    197                                 break; 
     205                        return tryXml(s); 
    198206                        // check for regex 
    199207                case AS3Parsersym.TK_DIV: 
    200208                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        } 
    209213        private void tryToInsertSemicolon() { 
    210214                if (!hasError(AS3Parsersym.TK_VirtualSemicolon)) { 
     
    212216                        prs.makeToken(end + 1, end, AS3Parsersym.TK_VirtualSemicolon); 
    213217                        insertedVirtualSemicolons++; 
    214                 } else 
    215                         errorDetected(); 
     218                } 
    216219        } 
    217220 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Lexer.gi

    rb32f7a4 r5c182b6  
    632632                lexParser.parseCharacters(monitor); 
    633633                make.eof(); 
    634                 return !make.detectedError; 
     634                boolean hadErrors = make.detectedError; 
     635                make = null; 
     636                return !hadErrors; 
    635637            } 
    636638            public int [] getKeywordKinds() { 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3ParseController.java

    rb32f7a4 r5c182b6  
    44import java.util.Iterator; 
    55 
    6 import lpg.runtime.IAst; 
    7  
    86import org.axdt.as3.AS3Plugin; 
     7import org.axdt.as3.analysis.AS3Analysis; 
    98import org.axdt.as3.imp.parser.Ast.ASTNode; 
    109import org.axdt.as3.imp.services.AS3SyntaxProperties; 
    1110import org.eclipse.core.runtime.IPath; 
    1211import org.eclipse.core.runtime.IProgressMonitor; 
    13 import org.eclipse.core.runtime.NullProgressMonitor; 
    1412import org.eclipse.imp.model.ISourceProject; 
    1513import org.eclipse.imp.parser.ILexer; 
     
    3331        private IPath location; 
    3432 
    35         private SymbolTable topLevelSymbolTable = null; 
     33        private AS3Analysis analysis; 
    3634 
    3735        public AS3ParseController() { 
     
    7775         */ 
    7876        public Object parse(String contents, boolean resolve, IProgressMonitor monitor) { 
    79                 if (monitor == null) monitor = new NullProgressMonitor(); 
     77                //if (monitor == null) monitor = new NullProgressMonitor(); 
    8078                int newHash = contents.hashCode(); 
    8179                if (lastHash == newHash) { 
     
    8583                AS3Plugin.getDefault().debug("parsing "+ getPath().toString()); 
    8684                lastHash = newHash; 
    87                 topLevelSymbolTable = null; 
    8885                PMMonitor my_monitor = new PMMonitor(monitor); 
    8986                char[] contentsArray = contents.toCharArray(); 
     
    9693 
    9794                if (parser == null) { 
    98                         parser = new AS3Parser(lexer.getILexStream()); 
     95                        parser = new AS3Parser(); 
    9996                } 
    10097                parser.reset(lexer.getILexStream()); 
     
    10299 
    103100                // Lex the stream to produce the token stream 
    104                 lexer.lexer(my_monitor, parser);  
     101                boolean success = lexer.lexer(my_monitor, parser);  
    105102                // fCurrentAst might (probably will) be 
    106103                // inconsistent wrt the lex stream now 
     
    109106                if (fCurrentAst != null) 
    110107                        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); 
    111123 
    112                 fCurrentAst = parser.parser(my_monitor, -1); 
    113  
    114                 if (fCurrentAst instanceof ASTNode) { 
     124                if (resolve && fCurrentAst instanceof ASTNode) { 
    115125                        ASTNode node = (ASTNode) fCurrentAst; 
    116                         topLevelSymbolTable = resolveSymbolTable(node); 
    117                         buildIndex(node); 
    118                         if (resolve) { 
    119                                 resolveDeclarations(node); 
    120                         } 
     126                        resolveDeclarations(node); 
    121127                } 
    122128 
     
    124130 
    125131                return fCurrentAst; 
    126         } 
    127          
    128         public void buildIndex(Object object) { 
    129                 if (object instanceof ASTNode) { 
    130                         ((ASTNode)object).accept(new IndexingVisitor(this)); 
    131                 } 
    132132        } 
    133133         
     
    138138        } 
    139139 
    140         protected SymbolTable resolveSymbolTable(ASTNode root) { 
    141                 SymbolTableVisitor symbolTableVisitor = new SymbolTableVisitor(this); 
    142                 root.accept(symbolTableVisitor); 
    143                 return symbolTableVisitor.getTopLevelSymbolTable(); 
    144         } 
    145  
    146140        public Object getBackupAst() { 
    147141                return backupAst; 
    148         } 
    149  
    150         public SymbolTable getEnclosingSymbolTable(IAst node) { 
    151                 if (topLevelSymbolTable  != null) { 
    152                         return topLevelSymbolTable.getEnclosingSymbolTable(node); 
    153                 } 
    154                 return null; 
    155142        } 
    156143 
     
    161148                return super.getTokenIterator(region); 
    162149        } 
     150 
     151        public void dispose() { 
     152                parser = null; 
     153                lexer = null; 
     154                backupAst = null; 
     155                fCurrentAst = null; 
     156                handler = null; 
     157                analysis = null; 
     158        } 
    163159} 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/AS3Parser.g

    rb32f7a4 r5c182b6  
    487487          | Statement_sif 
    488488          | VariableDefinition_allowin 
    489           | Attributes --NO_LINE_BREAK$  
    490                 LCURLY$ Substatements RCURLY$ 
     489--        | Attributes --NO_LINE_BREAK$  
     490--              LCURLY$ Substatements RCURLY$ 
    491491 
    492492Substatement_nosif$Substatement 
     
    494494          | Statement_nosif 
    495495          | VariableDefinition_allowin 
    496           | Attributes --NO_LINE_BREAK$  
    497                 LCURLY$ Substatements RCURLY$ 
    498  
    499 Substatements$Substatements$Substatement ::= %empty 
    500 Substatements$Substatements$Substatement ::= Substatements Substatement_sif 
     496--        | Attributes --NO_LINE_BREAK$  
     497--              LCURLY$ Substatements RCURLY$ 
     498 
     499--Substatements$Substatements$Substatement ::= %empty 
     500--Substatements$Substatements$Substatement ::= Substatements Substatement_sif 
    501501 
    502502-- no empty semicolon ! use virtual semi instead ! 
     
    521521Block$Block ::= LCURLY$ RCURLY$ 
    522522/. 
    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; 
    530523        SymbolTable symbolTable; 
    531524        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
     
    626619AnnotatedDirective 
    627620        ::= Attributes --NO_LINE_BREAK$  
    628                 AnnotatableDirective 
    629           | AnnotatableDirective 
     621                AnnotatableDirective$Directive 
     622          | AnnotatableDirective$Directive 
    630623Directive ::= AnnotatedDirective 
    631624          | EmptyStatment 
     
    710703VariableBindingList_noin$VariableBindingsNoin$VariableBinding_noin ::= VariableBindingList_noin COMMA$ VariableBinding_noin 
    711704 
    712 VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 
     705 
    713706 --B 
    714707VariableBinding_allowin$VariableBinding  
     
    766759-- 17.2.1 Function body 
    767760FunctionCommon$FunctionCommon ::= LPAREN$ Parameters RPAREN$ ResultType 
     761FunctionCommon$FunctionCommon ::= LPAREN$ RPAREN$ ResultType 
    768762 
    769763-- 17.2.2 Function signature 
    770764 
    771765-- 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 
     766Parameters$Parameters$Parameter ::= Parameter 
     767-- rest is only allowed as last parameter but check that later 
     768Parameters$Parameters$Parameter ::= Parameter COMMA$ Parameters 
    776769Parameter ::= PlainParameter | RestParameter 
    777770PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident 
    778771PlainParameter$PlainParameter ::= TypedIdentifier_allowin$Ident ASSIGN$ AssignmentExpression_allowin$Initializer 
    779772RestParameter$RestParameter ::= REST$ 
    780 RestParameter$RestParameter ::= REST$ Identifier$Untyped 
    781773RestParameter$RestParameter ::= REST$ TypedIdentifier_allowin$Ident 
    782774 
     
    826818InterfaceDefinition ::= interface$ Name ExtendsList InterfaceBlock$Body 
    827819/. 
     820        SymbolTable symbolTable; 
     821        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
     822        public SymbolTable getSymbolTable() { return symbolTable; } 
    828823        public Attributes getAttributes() { 
    829824                if (!(getParent() instanceof AnnotatedDirective)) return null; 
     
    842837InterfaceBlock$InterfaceBlock ::= LCURLY$ RCURLY$ 
    843838InterfaceBlock$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 
    849840InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= FunctionSignature 
    850841InterfaceDirectives$InterfaceDirectives$FunctionSignature ::= InterfaceDirectives FunctionSignature 
     
    874865                return _Packages.getPackageDefinitionAt(0); 
    875866        } 
     867        SymbolTable symbolTable; 
     868        public void setSymbolTable(SymbolTable symbolTable) { this.symbolTable = symbolTable; } 
     869        public SymbolTable getSymbolTable() { return symbolTable; } 
    876870./ 
    877871 
     
    883877VariableDefinition ::= VariableDefinition_allowin | VariableDefinition_noin 
    884878VariableBinding ::= VariableBinding_allowin | VariableBinding_noin 
     879VariableBindingList ::= VariableBindingList_allowin | VariableBindingList_noin 
    885880Statement ::= Statement_sif | Statement_nosif 
    886881Substatement ::= Substatement_sif | Substatement_nosif 
     
    890885%Headers 
    891886/. 
     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    } 
    892905./ 
    893906%End 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/DiagnoseVisitor.java

    r25b5d22 r5c182b6  
    11package org.axdt.as3.imp.parser; 
    22 
     3import lpg.runtime.IAst; 
    34import lpg.runtime.ILexStream; 
    45import lpg.runtime.IMessageHandler; 
    5 import lpg.runtime.IPrsStream; 
    66import lpg.runtime.IToken; 
    77import lpg.runtime.ParseErrorCodes; 
    88 
    9 import org.axdt.as3.imp.parser.Ast.ASTNode; 
    109import org.axdt.as3.imp.parser.Ast.AbstractVisitor; 
    1110import org.eclipse.core.resources.IFile; 
     
    1312 
    1413public class DiagnoseVisitor extends AbstractVisitor { 
    15         protected static int[] NULL_LOCATION = new int[] {0,0}; 
     14        protected static int[] NULL_LOCATION = null; 
    1615         
    17         protected final IPrsStream prsStream; 
    1816        protected final ILexStream lexStream; 
    19         protected AS3ParseController parseController; 
    20         protected int errorCount = 0; 
     17        protected final IFile file; 
     18         
     19        public int errorCount = 0; 
    2120        protected boolean severeError = false; 
    2221 
    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; 
    2725        } 
    2826 
    2927        protected IProject getProject() { 
    30                 return parseController.getProject().getRawProject(); 
     28                return file.getProject(); 
    3129        } 
    3230         
    3331        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); 
    3537        } 
    3638 
     
    3941        } 
    4042 
    41         public void emitError(ASTNode node, String message) { 
     43        public void emitError(IAst node, String message) { 
    4244                emitError(node.getLeftIToken().getStartOffset(), node.getRightIToken().getEndOffset(), message); 
    4345        } 
     
    4648                emitError(ParseErrorCodes.NO_MESSAGE_CODE, startOffset, endOffset, message); 
    4749        } 
     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        } 
    4858        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); 
    5062                String[] msgs = new String[] {message}; 
    5163                IMessageHandler handler = lexStream.getMessageHandler(); 
    52                 handler.handleMessage(code, loc, NULL_LOCATION, prsStream.getFileName(), msgs); 
     64                handler.handleMessage(code, loc, NULL_LOCATION, file.getName(), msgs); 
    5365                errorCount++; 
    5466        } 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/ResolvingVisitor.java

    r2aa064d r5c182b6  
    55 
    66import lpg.runtime.IAst; 
     7import lpg.runtime.ILexStream; 
    78 
    89import org.axdt.as3.AS3Plugin; 
     
    1415import org.axdt.as3.imp.parser.Ast.ExtendsList; 
    1516import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
    16 import org.axdt.as3.imp.parser.Ast.FunctionExpression; 
    1717import org.axdt.as3.imp.parser.Ast.IName; 
    18 import org.axdt.as3.imp.parser.Ast.IPostfixExpression; 
    1918import org.axdt.as3.imp.parser.Ast.ITypeExpression_allowin; 
    20 import org.axdt.as3.imp.parser.Ast.ITypeExpression_noin; 
    2119import org.axdt.as3.imp.parser.Ast.Ident; 
    2220import org.axdt.as3.imp.parser.Ast.ImportDirective; 
     
    2422import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 
    2523import org.axdt.as3.imp.parser.Ast.Name; 
     24import org.axdt.as3.imp.parser.Ast.NewExpression; 
    2625import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
     26import org.axdt.as3.imp.parser.Ast.Parameters; 
     27import org.axdt.as3.imp.parser.Ast.RestParameter; 
    2728import org.axdt.as3.imp.parser.Ast.ResultType; 
    2829import org.axdt.as3.imp.parser.Ast.TypeExpressionList; 
    2930import org.axdt.as3.imp.parser.Ast.TypedIdentifier; 
    30 import org.axdt.as3.imp.parser.Ast.VariableBinding; 
     31import org.axdt.as3.util.AS3ASTUtil; 
    3132import org.axdt.as3.util.AS3Util; 
    3233import org.axdt.axdoc.model.AXEntry; 
     
    3536import org.axdt.axdoc.util.Index0r; 
    3637import org.axdt.common.preferences.AxdtPreferences; 
     38import org.eclipse.core.resources.IFile; 
    3739 
    3840public class ResolvingVisitor extends DiagnoseVisitor { 
     
    4244        private ArrayList<AXEntry> importedTypes; 
    4345        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); 
    4751                addDebugErrors = AS3Plugin.getDefault() != null && AxdtPreferences.doDebug(); 
    4852                index0r = Index0r.getInstance(); 
     
    6064                        } 
    6165                } 
     66                // add same package 
    6267                AXIndex[] sameIndexes = index0r.findPackage(expectedPackageName); 
    6368                for (AXIndex index:sameIndexes) { 
    6469                        importedPackages.add(index); 
    6570                } 
     71                // file private names are resolved with the local symbol table 
    6672        } 
    6773        protected AXEntry resolveType(String name) { 
    6874                for (AXEntry entry:importedTypes) { 
    69                         if (entry.getName().equals(name)) 
     75                        if (entry.getName().equals(name)) { 
     76                                index0r.requestFull(entry); 
    7077                                return entry; 
     78                        } 
    7179                } 
    7280                for (AXIndex index:importedPackages) { 
    7381                        for (AXEntry entry:index.getTypes()) { 
    7482                                if (entry.getName().equals(name)) { 
     83                                        index0r.requestFull(entry); 
    7584                                        return entry; 
    7685                                } 
     
    7988                return null; 
    8089        } 
    81         protected String resolveType(ITypeExpression_noin type) { 
     90        protected Object resolveType(Object type) { 
    8291                return type instanceof ASTNode ? resolveNode((ASTNode) type) : null; 
    8392        } 
    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; 
    9395                String typeName = type.toString(); 
    9496                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                } 
    107142        } 
    108143        protected void resolveTypes(TypeExpressionList list) { 
     
    121156        @Override 
    122157        public boolean visit(PackageDefinition n) { 
    123                 String packageName = AS3Util.getExpectedPackageName(getFile()); 
    124                 // is not inside a valid source path 
    125                 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 names 
    130                 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 false 
    136                         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                 } 
    145158                return true; 
    146159        } 
     
    187200        } 
    188201        @Override 
    189         public boolean visit(ClassDefinition n) { 
    190                 Name name = (Name) n.getName(); 
    191                 checkTypeName(name); 
    192                 checkPackageDirectiveName(name); 
    193                 return true; 
    194         } 
    195         @Override 
    196202        public boolean visit(Inheritance n) { 
    197203                ClassDefinition parent = (ClassDefinition) n.getParent(); 
     
    202208        } 
    203209        @Override 
    204         public boolean visit(InterfaceDefinition n) { 
    205                 Name name = (Name) n.getName(); 
    206                 checkTypeName(name); 
    207                 checkPackageDirectiveName(name); 
    208                 return true; 
    209         } 
    210         @Override 
    211210        public boolean visit(ExtendsList n) { 
    212211                InterfaceDefinition parent = (InterfaceDefinition) n.getParent(); 
     
    214213                return false; 
    215214        } 
    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         } 
    235215         
     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 
    236241        public boolean visit(TypedIdentifier n) { 
    237                 if (n != null) 
     242                if (n != null) { 
    238243                        resolveNode(n.getType()); 
    239                 return false; 
    240         } 
     244                        n.getName().setDeclaration(Boolean.FALSE); 
     245                } 
     246                return false; 
     247        } 
     248        @Override 
    241249        public boolean visit(ResultType n) { 
    242250                if (n != null) 
     
    244252                return false; 
    245253        } 
    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        } 
    247270} 
  • org.axdt.as3/src/org/axdt/as3/imp/parser/SymbolTable.java

    re9006de r5c182b6  
    22 
    33import java.util.ArrayList; 
    4 import java.util.Hashtable; 
     4import java.util.HashMap; 
    55import java.util.List; 
     6import java.util.Map; 
    67 
    78import lpg.runtime.IAst; 
    89 
    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; 
     10import org.axdt.as3.util.AS3ASTUtil; 
    1411 
    15 public class SymbolTable extends Hashtable<String, IAst> { 
     12public 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        } 
    1626        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; 
    1930         
    20         SymbolTable(SymbolTable parent, Class<?> clazz) { 
     31        public SymbolTable(SymbolTable parent, Class<?> clazz) { 
    2132                this.parent = parent; 
    2233                this.nodeClass = clazz; 
     34                store = new HashMap<String, SymbolEntry>(); 
    2335        } 
    2436 
    2537        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(); 
    2840                if (parent != null) return parent.findDeclaration(name); 
    2941                return null; 
     
    3345                return parent; 
    3446        } 
     47        public SymbolTable getRoot() { 
     48                return parent == null ? this : parent.getRoot(); 
     49        } 
    3550 
    3651        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)); 
    3954                        return true; 
    4055                } 
     
    4560                if (list == null) 
    4661                        list = new ArrayList<String>(); 
    47                 list.addAll(keySet()); 
     62                list.addAll(store.keySet()); 
    4863                if (parent != null) parent.getAllKeys(list); 
    4964                return list; 
    5065        } 
    5166        public SymbolTable getEnclosingSymbolTable(IAst n) { 
    52                 SymbolTable enclosing = getEnclosing(n); 
     67                SymbolTable enclosing = AS3ASTUtil.getEnclosingSymbolTable(n); 
    5368                if (enclosing != null) return enclosing; 
    5469                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; 
    6570        } 
    6671        public String cleanName(String key) { 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3ContentProposer.java

    rb32f7a4 r5c182b6  
    77 
    88import lpg.runtime.IAst; 
    9 import lpg.runtime.IPrsStream; 
    10 import lpg.runtime.IToken; 
    119 
    12 import org.axdt.as3.AS3Plugin; 
    13 import org.axdt.as3.imp.parser.AS3ASTNodeLocator; 
     10import org.axdt.as3.analysis.AS3TokenHelper; 
    1411import org.axdt.as3.imp.parser.AS3ParseController; 
    15 import org.axdt.as3.imp.parser.AS3Parsersym; 
    1612import org.axdt.as3.imp.parser.SymbolTable; 
    1713import org.axdt.as3.imp.parser.Ast.ASTNode; 
    18 import org.axdt.as3.imp.parser.Ast.IAnnotatableDirective; 
    1914import org.axdt.as3.imp.parser.Ast.IName; 
    2015import org.axdt.as3.imp.parser.Ast.ImportDirective; 
    2116import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
    2217import org.axdt.as3.templates.AS3TemplateCompletionProcessor; 
     18import org.axdt.as3.util.AS3ASTUtil; 
    2319import org.axdt.as3.util.AS3Util; 
    2420import org.axdt.axdoc.model.AXEntry; 
     
    2824import org.eclipse.imp.editor.SourceProposal; 
    2925import org.eclipse.imp.parser.IParseController; 
    30 import org.eclipse.imp.parser.IParser; 
    3126import org.eclipse.imp.services.IContentProposer; 
    3227import org.eclipse.jface.text.ITextViewer; 
     
    3530public class AS3ContentProposer implements IContentProposer { 
    3631         
    37         private static AS3ASTNodeLocator locator = new AS3ASTNodeLocator(); 
     32        private AS3SourceHelper helper; 
    3833         
    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  
    7434        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_SEMI  
    115                                 || (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 IAnnotatableDirective 
    146                          || n instanceof ImportDirective 
    147                          || n instanceof PackageDefinition 
    148                          ) { 
    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; 
    16035        } 
    16136        /** 
     
    18055        public ICompletionProposal[] getContentProposals(IParseController controller, int offset, 
    18156                        ITextViewer viewer) { 
    182                 boolean precede = collectInfo(controller, offset, viewer); 
     57                helper = new AS3SourceHelper((AS3ParseController)controller, viewer); 
     58                boolean precede = helper.init(offset); 
    18359                if (!precede) { 
    18460                        return new ICompletionProposal[0]; 
    18561                } 
    18662                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); 
    19066                                if (ancestor instanceof PackageDefinition) { 
    19167                                        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()) { 
    19369                                                // in package header 
    19470                                                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); 
    20176                                        } 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")) { 
    20580                                                        for (String packname:Index0r.getInstance().getPackageNames()) { 
    20681                                                                String proposed = (isImport ? "":"import ")+packname+".*"; 
    207                                                                 proposals.addSourceProposal(proposed, prefix, ImportDirective.class, !nextIsSemi); 
     82                                                                proposals.addSourceProposal(proposed, helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 
    20883                                                        } 
    20984                                                } 
     
    21186                                } else if (ancestor instanceof ImportDirective) { 
    21287                                        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('.'); 
    21690                                        Collection<String> packageNames = Index0r.getInstance().getPackageNames(); 
    21791                                        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); 
    22094                                                if (packageNames.contains(packname)) { 
    22195                                                        if ("*".equals(rest)) { 
     
    226100                                                                        String entryname = entry.getName(); 
    227101                                                                        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()); 
    229103                                                                        } 
    230104                                                                } 
    231105                                                                if (rest.length() == 0) { 
    232                                                                         proposals.addSourceProposal(packname+".*", prefix, ImportDirective.class, !nextIsSemi); 
     106                                                                        proposals.addSourceProposal(packname+".*", helper.prefix, ImportDirective.class, !helper.nextIsSemi()); 
    233107                                                                } 
    234108                                                        } 
     
    236110                                        } 
    237111                                        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()); 
    240114                                                } 
    241115                                        } 
    242116                                } else { 
    243                                         proposals.addUnitScopeProposals(node); 
     117                                        proposals.addUnitScopeProposals(helper.node); 
    244118                                } 
    245119                        } else { 
     
    247121                        } 
    248122                } 
    249                 if (prefix != null && prefix.length() > 0) { 
     123                if (helper.hasPrefix()) { 
    250124                        proposals.addKeywordProposals(); 
    251125                        proposals.addTemplateProposals(viewer); 
    252126                } 
    253127                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; 
    266128        } 
    267129        public static final Comparator<ICompletionProposal> ProposalComparator = new Comparator<ICompletionProposal>() { 
     
    270132                } 
    271133        }; 
    272         private class ProposalHelper implements AS3Parsersym { 
     134        private class ProposalHelper { 
    273135                ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal>(); 
    274136                 
    275137                void addUnitScopeProposals(ASTNode node) { 
    276                         SymbolTable table = SymbolTable.getEnclosing(node); 
     138                        SymbolTable table = AS3ASTUtil.getEnclosingSymbolTable(node); 
    277139                        if (table == null) return; 
    278140                        for (String key:table.getAllKeys(null)) { 
    279141                                String name = table.cleanName(key); 
    280                                 if (name.startsWith(prefix)) { 
     142                                if (name.startsWith(helper.prefix)) { 
    281143                                        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())); 
    283145                                } 
    284146                        } 
    285147                } 
    286148                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())); 
    288150                } 
    289151                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)); 
    291153                } 
    292154                void addSourceProposal(String packageName, String usePrefix, Class<?> nodeClass, boolean addSemi) { 
    293155                        if (addSemi) packageName += ";"; 
    294                         result.add(new AS3SourceProposal(packageName, usePrefix, offset, nodeClass)); 
     156                        result.add(new AS3SourceProposal(packageName, usePrefix, helper.offset, nodeClass)); 
    295157                } 
    296158                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); 
    300162                                        result.add(proposal); 
    301163                                } 
     
    304166                void addTemplateProposals(ITextViewer viewer) { 
    305167                        AS3TemplateCompletionProcessor processor = new AS3TemplateCompletionProcessor(); 
    306                         result.addAll(processor.computeCompletionProposalList(viewer, offset, prefix)); 
     168                        result.addAll(processor.computeCompletionProposalList(viewer, helper.offset, helper.prefix)); 
    307169                } 
    308170                ICompletionProposal[] getResult() { 
     
    311173                } 
    312174        } 
    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         } 
    348175} 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3EditorService.java

    r3d0622c r5c182b6  
    66 
    77import org.axdt.as3.AS3Plugin; 
     8import org.axdt.as3.imp.parser.AS3ParseController; 
    89import org.eclipse.core.runtime.IPath; 
    910import org.eclipse.core.runtime.IProgressMonitor; 
     
    3839        public void update(IParseController parseController, 
    3940                        IProgressMonitor monitor) { 
    40                 // TODO do update ?! we do the work in the as3 parse controller for now  
    4141        } 
    4242 
     
    7171                        if (editor != part) return; 
    7272                        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); 
    7483                        AS3Plugin.getDefault().debug("as3 editor closed"); 
    7584                } 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3ReferenceResolver.java

    rb32f7a4 r5c182b6  
    33import lpg.runtime.IAst; 
    44 
    5 import org.axdt.as3.imp.parser.AS3ParseController; 
    65import org.axdt.as3.imp.parser.SymbolTable; 
    76import org.axdt.as3.imp.parser.Ast.Ident; 
     
    5857 
    5958        private Object lookInSymbolTable(IParseController controller, IAst node, String stringId) { 
    60                 SymbolTable symtab = ((AS3ParseController) controller).getEnclosingSymbolTable(node); 
     59                SymbolTable symtab = AS3ASTUtil.getEnclosingSymbolTable(node); 
    6160                return symtab.findDeclaration(stringId); 
    6261        } 
  • org.axdt.as3/src/org/axdt/as3/imp/services/AS3TokenColorer.java

    rb32f7a4 r5c182b6  
    44import lpg.runtime.IToken; 
    55 
    6 import org.axdt.as3.imp.parser.AS3ParseController; 
     6import org.axdt.as3.analysis.AS3TokenHelper; 
    77import org.axdt.as3.imp.parser.AS3Parsersym; 
    88import org.eclipse.imp.parser.IParseController; 
     
    4040                                return null; 
    4141                        } 
    42                         if (((AS3ParseController) controller).isKeyword(token.getKind())) 
     42                        if (AS3TokenHelper.isKeyword(token)) 
    4343                                return keywordAttribute; 
    4444                        return super.getColoring(controller, token); 
  • org.axdt.as3/src/org/axdt/as3/util/AS3ASTUtil.java

    r69d1ca8 r5c182b6  
    33import lpg.runtime.IAst; 
    44 
     5import org.axdt.as3.imp.parser.SymbolTable; 
    56import org.axdt.as3.imp.parser.Ast.ASTNode; 
     7import org.axdt.as3.imp.parser.Ast.Block; 
     8import org.axdt.as3.imp.parser.Ast.ClassDefinition; 
     9import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
     10import org.axdt.as3.imp.parser.Ast.FunctionExpression; 
    611import org.axdt.as3.imp.parser.Ast.IDirective; 
    712import org.axdt.as3.imp.parser.Ast.IPackageDefinition; 
     13import org.axdt.as3.imp.parser.Ast.ITypedIdentifier_noin; 
    814import org.axdt.as3.imp.parser.Ast.Ident; 
     15import org.axdt.as3.imp.parser.Ast.InterfaceDefinition; 
    916import org.axdt.as3.imp.parser.Ast.Name; 
     17import org.axdt.as3.imp.parser.Ast.Program; 
    1018 
    1119public class AS3ASTUtil { 
     
    1321                return parent instanceof IDirective 
    1422                        || 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; 
    1528        } 
    1629        public static ASTNode getDirective(ASTNode node) { 
     
    3750                } 
    3851                if (Boolean.FALSE.equals(declaration)) { 
    39                         IAst parent = current.getParent(); 
    40                         while (parent != null && !isDirective(parent.getParent())) 
     52                        IAst parent = current; 
     53                        while (parent != null && !isNameParent(parent.getParent())) 
    4154                                parent = parent.getParent(); 
    4255                        return parent; 
     
    4457                return declaration; 
    4558        } 
     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        } 
    4670} 
  • org.axdt.axdoc.model/model/AXDoc.ecore

    r2aa064d r5c182b6  
    2626  </eClassifiers> 
    2727  <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"/> 
    3232  </eClassifiers> 
    3333  <eClassifiers xsi:type="ecore:EClass" name="AXIndex" eSuperTypes="#//AXIndexNode"> 
     
    4040    <eOperations name="getOrCreateReference" eType="#//AXPackage"/> 
    4141    <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//AXPackage"/> 
    42     <eStructuralFeatures xsi:type="ecore:EAttribute" name="level" eType="#//AXLevel" 
    43         transient="true"/> 
    4442    <eStructuralFeatures xsi:type="ecore:EReference" name="indexes" upperBound="-1" 
    4543        eType="#//AXIndex" containment="true" resolveProxies="false" eOpposite="#//AXIndex/parent" 
     
    108106    <eStructuralFeatures xsi:type="ecore:EReference" name="basicParent" eType="#//AXIndexNode" 
    109107        changeable="false" volatile="true" transient="true"/> 
     108    <eStructuralFeatures xsi:type="ecore:EAttribute" name="level" eType="#//AXLevel"/> 
    110109  </eClassifiers> 
    111110  <eClassifiers xsi:type="ecore:EEnum" name="AXEntryType"> 
  • org.axdt.axdoc.model/model/AXDocXML.xsd

    r2aa064d r5c182b6  
    103103    </xsd:sequence> 
    104104    <xsd:attribute name="name" type="xsd:string" use="required"/> 
     105    <xsd:attribute name="level" type="axdoc:AXLevel"/> 
    105106  </xsd:complexType> 
    106107</xsd:schema> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXDocPackage.java

    r2aa064d r5c182b6  
    347347 
    348348        /** 
     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        /** 
    349358         * The number of structural features of the '<em>AX Index Node</em>' class. 
    350359         * <!-- begin-user-doc --> 
     
    353362         * @ordered 
    354363         */ 
    355         int AX_INDEX_NODE_FEATURE_COUNT = 4; 
     364        int AX_INDEX_NODE_FEATURE_COUNT = 5; 
    356365 
    357366        /** 
     
    402411 
    403412        /** 
     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        /** 
    404422         * The feature id for the '<em><b>Reference</b></em>' reference. 
    405423         * <!-- begin-user-doc --> 
     
    411429 
    412430        /** 
    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_FEATURE_COUNT + 1; 
    420  
    421         /** 
    422431         * The feature id for the '<em><b>Indexes</b></em>' containment reference list. 
    423432         * <!-- begin-user-doc --> 
     
    426435         * @ordered 
    427436         */ 
    428         int AX_INDEX__INDEXES = AX_INDEX_NODE_FEATURE_COUNT + 2; 
     437        int AX_INDEX__INDEXES = AX_INDEX_NODE_FEATURE_COUNT + 1; 
    429438 
    430439        /** 
     
    435444         * @ordered 
    436445         */ 
    437         int AX_INDEX__PARENT = AX_INDEX_NODE_FEATURE_COUNT + 3; 
     446        int AX_INDEX__PARENT = AX_INDEX_NODE_FEATURE_COUNT + 2; 
    438447 
    439448        /** 
     
    444453         * @ordered 
    445454         */ 
    446         int AX_INDEX_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 4; 
     455        int AX_INDEX_FEATURE_COUNT = AX_INDEX_NODE_FEATURE_COUNT + 3; 
    447456 
    448457        /** 
     
    493502 
    494503        /** 
     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        /** 
    495513         * The feature id for the '<em><b>Reference</b></em>' reference. 
    496514         * <!-- begin-user-doc --> 
     
    500518         */ 
    501519        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          * @generated 
    508          * @ordered 
    509          */ 
    510         int AX_ROOT__LEVEL = AX_INDEX__LEVEL; 
    511520 
    512521        /** 
     
    618627         */ 
    619628        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; 
    620638 
    621639        /** 
     
    824842 
    825843        /** 
    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          * @generated 
    833          */ 
    834         EAttribute getAXIndex_Level(); 
    835  
    836         /** 
    837844         * Returns the meta object for class '{@link org.axdt.axdoc.model.AXRoot <em>AX Root</em>}'. 
    838845         * <!-- begin-user-doc --> 
     
    984991         */ 
    985992        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(); 
    9861004 
    9871005        /** 
     
    11731191 
    11741192                /** 
    1175                  * The meta object literal for the '<em><b>Level</b></em>' attribute feature. 
    1176                  * <!-- begin-user-doc --> 
    1177                  * <!-- end-user-doc --> 
    1178                  * @generated 
    1179                  */ 
    1180                 EAttribute AX_INDEX__LEVEL = eINSTANCE.getAXIndex_Level(); 
    1181  
    1182                 /** 
    11831193                 * The meta object literal for the '{@link org.axdt.axdoc.model.impl.AXRootImpl <em>AX Root</em>}' class. 
    11841194                 * <!-- begin-user-doc --> 
     
    13001310 
    13011311                /** 
     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                /** 
    13021320                 * The meta object literal for the '{@link org.axdt.axdoc.model.AXMemberHolder <em>AX Member Holder</em>}' class. 
    13031321                 * <!-- begin-user-doc --> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndex.java

    r85b4650 r5c182b6  
    1818 * <ul> 
    1919 *   <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> 
    2120 *   <li>{@link org.axdt.axdoc.model.AXIndex#getIndexes <em>Indexes</em>}</li> 
    2221 *   <li>{@link org.axdt.axdoc.model.AXIndex#getParent <em>Parent</em>}</li> 
     
    103102 
    104103        /** 
    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.AXLevel 
    115          * @see #setLevel(AXLevel) 
    116          * @see org.axdt.axdoc.model.AXDocPackage#getAXIndex_Level() 
    117          * @model transient="true" 
    118          * @generated 
    119          */ 
    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.AXLevel 
    128          * @see #getLevel() 
    129          * @generated 
    130          */ 
    131         void setLevel(AXLevel value); 
    132  
    133         /** 
    134104         * <!-- begin-user-doc --> 
    135105         * <!-- end-user-doc --> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXIndexNode.java

    r2aa064d r5c182b6  
    2222 *   <li>{@link org.axdt.axdoc.model.AXIndexNode#getId <em>Id</em>}</li> 
    2323 *   <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> 
    2425 * </ul> 
    2526 * </p> 
     
    105106 
    106107        /** 
     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        /** 
    107137         * <!-- begin-user-doc --> 
    108138         * <!-- end-user-doc --> 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/AXLevel.java

    r79dd699 r5c182b6  
    3131         * @ordered 
    3232         */ 
    33         EMPTY(0, "EMPTY", "EMPTY"), 
     33        EMPTY(0, "EMPTY", "e"), 
    3434 
    3535        /** 
     
    4141         * @ordered 
    4242         */ 
    43         PACKAGE(1, "PACKAGE", "PACKAGE"), 
     43        PACKAGE(1, "PACKAGE", "p"), 
    4444 
    4545        /** 
     
    5151         * @ordered 
    5252         */ 
    53         TYPE(2, "TYPE", "TYPE"), 
     53        TYPE(2, "TYPE", "t"), 
    5454 
    5555        /** 
     
    6161         * @ordered 
    6262         */ 
    63         MEMBER(4, "MEMBER", "MEMBER"); 
     63        MEMBER(4, "MEMBER", "m"); 
    6464 
    6565        /** 
     
    7272         * <!-- end-user-doc --> 
    7373         * @see #EMPTY 
    74          * @model 
     74         * @model literal="e" 
    7575         * @generated 
    7676         * @ordered 
     
    8787         * <!-- end-user-doc --> 
    8888         * @see #PACKAGE 
    89          * @model 
     89         * @model literal="p" 
    9090         * @generated 
    9191         * @ordered 
     
    102102         * <!-- end-user-doc --> 
    103103         * @see #TYPE 
    104          * @model 
     104         * @model literal="t" 
    105105         * @generated 
    106106         * @ordered 
     
    117117         * <!-- end-user-doc --> 
    118118         * @see #MEMBER 
    119          * @model 
     119         * @model literal="m" 
    120120         * @generated 
    121121         * @ordered 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXDocPackageImpl.java

    r2aa064d r5c182b6  
    289289         */ 
    290290        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() { 
    291300                return (EReference) axIndexEClass.getEStructuralFeatures().get(2); 
    292         } 
    293  
    294         /** 
    295          * <!-- begin-user-doc --> 
    296          * <!-- end-user-doc --> 
    297          * @generated 
    298          */ 
    299         public EReference getAXIndex_Parent() { 
    300                 return (EReference) axIndexEClass.getEStructuralFeatures().get(3); 
    301301        } 
    302302 
     
    315315         * @generated 
    316316         */ 
    317         public EAttribute getAXIndex_Level() { 
    318                 return (EAttribute) axIndexEClass.getEStructuralFeatures().get(1); 
    319         } 
    320  
    321         /** 
    322          * <!-- begin-user-doc --> 
    323          * <!-- end-user-doc --> 
    324          * @generated 
    325          */ 
    326317        public EClass getAXRoot() { 
    327318                return axRootEClass; 
     
    443434        public EReference getAXIndexNode_BasicParent() { 
    444435                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); 
    445445        } 
    446446 
     
    538538                axIndexEClass = createEClass(AX_INDEX); 
    539539                createEReference(axIndexEClass, AX_INDEX__REFERENCE); 
    540                 createEAttribute(axIndexEClass, AX_INDEX__LEVEL); 
    541540                createEReference(axIndexEClass, AX_INDEX__INDEXES); 
    542541                createEReference(axIndexEClass, AX_INDEX__PARENT); 
     
    558557                createEAttribute(axIndexNodeEClass, AX_INDEX_NODE__ID); 
    559558                createEReference(axIndexNodeEClass, AX_INDEX_NODE__BASIC_PARENT); 
     559                createEAttribute(axIndexNodeEClass, AX_INDEX_NODE__LEVEL); 
    560560 
    561561                // Create enums 
     
    650650                                !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, 
    651651                                !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); 
    655652                initEReference(getAXIndex_Indexes(), this.getAXIndex(), this 
    656653                                .getAXIndex_Parent(), "indexes", null, 0, -1, AXIndex.class, 
     
    743740                                IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, 
    744741                                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); 
    745746 
    746747                addEOperation(axIndexNodeEClass, this.getAXRoot(), "getRoot", 0, 1, 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXEntryImpl.java

    r2aa064d r5c182b6  
    1515import org.axdt.axdoc.model.AXIndex; 
    1616import org.axdt.axdoc.model.AXIndexNode; 
     17import org.axdt.axdoc.model.AXLevel; 
    1718import org.axdt.axdoc.model.AXMember; 
    1819import org.axdt.axdoc.model.AXMemberHolder; 
     
    281282                                return getBasicParent(); 
    282283                        return basicGetBasicParent(); 
     284                case AXDocPackage.AX_ENTRY__LEVEL: 
     285                        return getLevel(); 
    283286                case AXDocPackage.AX_ENTRY__TYPE: 
    284287                        return getType(); 
     
    309312                        getEntries().addAll((Collection<? extends AXEntry>) newValue); 
    310313                        return; 
     314                case AXDocPackage.AX_ENTRY__LEVEL: 
     315                        setLevel((AXLevel) newValue); 
     316                        return; 
    311317                case AXDocPackage.AX_ENTRY__TYPE: 
    312318                        setType((AXEntryType) newValue); 
     
    335341                case AXDocPackage.AX_ENTRY__ENTRIES: 
    336342                        getEntries().clear(); 
     343                        return; 
     344                case AXDocPackage.AX_ENTRY__LEVEL: 
     345                        setLevel(LEVEL_EDEFAULT); 
    337346                        return; 
    338347                case AXDocPackage.AX_ENTRY__TYPE: 
     
    366375                case AXDocPackage.AX_ENTRY__BASIC_PARENT: 
    367376                        return basicGetBasicParent() != null; 
     377                case AXDocPackage.AX_ENTRY__LEVEL: 
     378                        return level != LEVEL_EDEFAULT; 
    368379                case AXDocPackage.AX_ENTRY__TYPE: 
    369380                        return type != TYPE_EDEFAULT; 
     
    431442         */ 
    432443        public String getId() { 
    433                 if (this.id != null) return this.id; 
     444                if (this.id != null) 
     445                        return this.id; 
    434446                if (name != null) { 
    435447                        AXIndexNode parent = getParent(); 
    436448                        if (parent == null && parent instanceof AXRoot) { 
    437                                 id = "::"+name +"#"+ getType(); 
     449                                id = "::" + name + "#" + getType(); 
    438450                        } else { 
    439451                                id = parent.getId(); 
    440452                                id += parent instanceof AXIndex ? "::" : "."; 
    441                                 id += name +"#"+ getType(); 
     453                                id += name + "#" + getType(); 
    442454                        } 
    443455                } 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexImpl.java

    r2aa064d r5c182b6  
    3737 * <ul> 
    3838 *   <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> 
    4039 *   <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getIndexes <em>Indexes</em>}</li> 
    4140 *   <li>{@link org.axdt.axdoc.model.impl.AXIndexImpl#getParent <em>Parent</em>}</li> 
     
    5554         */ 
    5655        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          * @generated 
    63          * @ordered 
    64          */ 
    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          * @generated 
    72          * @ordered 
    73          */ 
    74         protected AXLevel level = LEVEL_EDEFAULT; 
    7556        /** 
    7657         * The cached value of the '{@link #getIndexes() <em>Indexes</em>}' containment reference list. 
     
    237218         * <!-- begin-user-doc --> 
    238219         * <!-- end-user-doc --> 
    239          * @generated 
    240          */ 
    241         public AXLevel getLevel() { 
    242                 return level; 
    243         } 
    244  
    245         /** 
    246          * <!-- begin-user-doc --> 
    247          * <!-- end-user-doc --> 
    248          * @generated 
    249          */ 
    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 --> 
    261220         */ 
    262221        public String fullUrl() { 
     
    390349                                return getBasicParent(); 
    391350                        return basicGetBasicParent(); 
     351                case AXDocPackage.AX_INDEX__LEVEL: 
     352                        return getLevel(); 
    392353                case AXDocPackage.AX_INDEX__REFERENCE: 
    393354                        if (resolve) 
    394355                                return getReference(); 
    395356                        return basicGetReference(); 
    396                 case AXDocPackage.AX_INDEX__LEVEL: 
    397                         return getLevel(); 
    398357                case AXDocPackage.AX_INDEX__INDEXES: 
    399358                        return getIndexes(); 
     
    420379                        getEntries().addAll((Collection<? extends AXEntry>) newValue); 
    421380                        return; 
     381                case AXDocPackage.AX_INDEX__LEVEL: 
     382                        setLevel((AXLevel) newValue); 
     383                        return; 
    422384                case AXDocPackage.AX_INDEX__REFERENCE: 
    423385                        setReference((AXPackage) newValue); 
    424386                        return; 
    425                 case AXDocPackage.AX_INDEX__LEVEL: 
    426                         setLevel((AXLevel) newValue); 
    427                         return; 
    428387                case AXDocPackage.AX_INDEX__INDEXES: 
    429388                        getIndexes().clear(); 
     
    451410                        getEntries().clear(); 
    452411                        return; 
     412                case AXDocPackage.AX_INDEX__LEVEL: 
     413                        setLevel(LEVEL_EDEFAULT); 
     414                        return; 
    453415                case AXDocPackage.AX_INDEX__REFERENCE: 
    454416                        setReference((AXPackage) null); 
    455                         return; 
    456                 case AXDocPackage.AX_INDEX__LEVEL: 
    457                         setLevel(LEVEL_EDEFAULT); 
    458417                        return; 
    459418                case AXDocPackage.AX_INDEX__INDEXES: 
     
    484443                case AXDocPackage.AX_INDEX__BASIC_PARENT: 
    485444                        return basicGetBasicParent() != null; 
     445                case AXDocPackage.AX_INDEX__LEVEL: 
     446                        return level != LEVEL_EDEFAULT; 
    486447                case AXDocPackage.AX_INDEX__REFERENCE: 
    487448                        return reference != null; 
    488                 case AXDocPackage.AX_INDEX__LEVEL: 
    489                         return level != LEVEL_EDEFAULT; 
    490449                case AXDocPackage.AX_INDEX__INDEXES: 
    491450                        return indexes != null && !indexes.isEmpty(); 
     
    494453                } 
    495454                return eDynamicIsSet(featureID); 
    496         } 
    497  
    498         /** 
    499          * <!-- begin-user-doc --> 
    500          * <!-- end-user-doc --> 
    501          * @generated 
    502          */ 
    503         @Override 
    504         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(); 
    513455        } 
    514456 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXIndexNodeImpl.java

    r2aa064d r5c182b6  
    1414import org.axdt.axdoc.model.AXEntryType; 
    1515import org.axdt.axdoc.model.AXIndexNode; 
     16import org.axdt.axdoc.model.AXLevel; 
    1617import org.axdt.axdoc.model.AXNode; 
    1718import org.axdt.axdoc.model.AXRoot; 
     
    3839 *   <li>{@link org.axdt.axdoc.model.impl.AXIndexNodeImpl#getId <em>Id</em>}</li> 
    3940 *   <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> 
    4042 * </ul> 
    4143 * </p> 
     
    105107 
    106108        /** 
     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        /** 
    107129         * <!-- begin-user-doc --> 
    108130         * <!-- end-user-doc --> 
     
    184206         */ 
    185207        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        } 
    186230 
    187231        /** 
     
    402446                                return getBasicParent(); 
    403447                        return basicGetBasicParent(); 
     448                case AXDocPackage.AX_INDEX_NODE__LEVEL: 
     449                        return getLevel(); 
    404450                } 
    405451                return eDynamicGet(featureID, resolve, coreType); 
     
    422468                        getEntries().addAll((Collection<? extends AXEntry>) newValue); 
    423469                        return; 
     470                case AXDocPackage.AX_INDEX_NODE__LEVEL: 
     471                        setLevel((AXLevel) newValue); 
     472                        return; 
    424473                } 
    425474                eDynamicSet(featureID, newValue); 
     
    439488                case AXDocPackage.AX_INDEX_NODE__ENTRIES: 
    440489                        getEntries().clear(); 
     490                        return; 
     491                case AXDocPackage.AX_INDEX_NODE__LEVEL: 
     492                        setLevel(LEVEL_EDEFAULT); 
    441493                        return; 
    442494                } 
     
    461513                case AXDocPackage.AX_INDEX_NODE__BASIC_PARENT: 
    462514                        return basicGetBasicParent() != null; 
     515                case AXDocPackage.AX_INDEX_NODE__LEVEL: 
     516                        return level != LEVEL_EDEFAULT; 
    463517                } 
    464518                return eDynamicIsSet(featureID); 
     
    480534                result.append(", id: "); 
    481535                result.append(id); 
     536                result.append(", level: "); 
     537                result.append(level); 
    482538                result.append(')'); 
    483539                return result.toString(); 
  • org.axdt.axdoc.model/src/org/axdt/axdoc/model/impl/AXRootImpl.java

    r2d81bf0 r5c182b6  
    275275                                return getBasicParent(); 
    276276                        return basicGetBasicParent(); 
     277                case AXDocPackage.AX_ROOT__LEVEL: 
     278                        return getLevel(); 
    277279                case AXDocPackage.AX_ROOT__REFERENCE: 
    278280                        if (resolve) 
    279281                                return getReference(); 
    280282                        return basicGetReference(); 
    281                 case AXDocPackage.AX_ROOT__LEVEL: 
    282                         return getLevel(); 
    283283                case AXDocPackage.AX_ROOT__INDEXES: 
    284284                        return getIndexes(); 
     
    313313                        getEntries().addAll((Collection<? extends AXEntry>) newValue); 
    314314                        return; 
     315                case AXDocPackage.AX_ROOT__LEVEL: 
     316                        setLevel((AXLevel) newValue); 
     317                        return; 
    315318                case AXDocPackage.AX_ROOT__REFERENCE: 
    316319                        setReference((AXPackage) newValue); 
    317                         return; 
    318                 case AXDocPackage.AX_ROOT__LEVEL: 
    319                         setLevel((AXLevel) newValue); 
    320320                        return; 
    321321                case AXDocPackage.AX_ROOT__INDEXES: 
     
    356356                        getEntries().clear(); 
    357357                        return; 
     358                case AXDocPackage.AX_ROOT__LEVEL: 
     359                        setLevel(LEVEL_EDEFAULT); 
     360                        return; 
    358361                case AXDocPackage.AX_ROOT__REFERENCE: 
    359362                        setReference((AXPackage) null); 
    360                         return; 
    361                 case AXDocPackage.AX_ROOT__LEVEL: 
    362                         setLevel(LEVEL_EDEFAULT); 
    363363                        return; 
    364364                case AXDocPackage.AX_ROOT__INDEXES: 
     
    401401                case AXDocPackage.AX_ROOT__BASIC_PARENT: 
    402402                        return basicGetBasicParent() != null; 
     403                case AXDocPackage.AX_ROOT__LEVEL: 
     404                        return level != LEVEL_EDEFAULT; 
    403405                case AXDocPackage.AX_ROOT__REFERENCE: 
    404406                        return reference != null; 
    405                 case AXDocPackage.AX_ROOT__LEVEL: 
    406                         return level != LEVEL_EDEFAULT; 
    407407                case AXDocPackage.AX_ROOT__INDEXES: 
    408408                        return indexes != null && !indexes.isEmpty(); 
  • org.axdt.axdoc.test/src/org/axdt/axdoc/util/Index0rTest.java

    r2aa064d r5c182b6  
    4646//              takes to long for a test... 
    4747//              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)); 
    4950                assertEquals(2, index.find("::Array").length); 
    5051                AXEntry node1 = (AXEntry)index.find("::Array")[0]; 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/AXDocParser.java

    r2aa064d r5c182b6  
    2121import org.xml.sax.SAXException; 
    2222 
     23// TODO: use ProgressMonitor 
     24// TODO: parse member level on request 
     25@SuppressWarnings("unused") 
    2326public class AXDocParser { 
    2427        protected static String[] SORTED_DOC_NAMES = new String[]{ 
     
    192195                                                } 
    193196                                                AXEntry memberIndex = index.createEntry(memberName, type); 
     197                                                memberIndex.getOrCreateReference(); 
    194198                                                log(3,"[DDD] found member ", memberIndex); 
    195199                                        } 
     
    211215                                        } 
    212216                                        AXEntry typeIndex = index.createEntry(typeName, entryType); 
     217                                        typeIndex.getOrCreateReference(); 
    213218                                        // load type doc summary 
    214219                                        if (loadSummary) { 
     
    233238                        Node[] contentDivs = loader.eIter(findMain, html); 
    234239                        // 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); 
    237243                                return; 
    238244                        } 
     
    243249                        parseTypeMembers(result, contentDivs[1]); 
    244250                         
    245                         // result.setLevel(AXLevel.MEMBER); 
     251                        result.setLevel(AXLevel.MEMBER); 
    246252                }       catch (FileNotFoundException e) { /* ignore */ }  
    247253                        catch (SAXException e) { e.printStackTrace(); } 
     
    253259                Node[] headers = loader.eIter(findTypeHeader, headerNode); 
    254260                // 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                } 
    261268        } 
    262269 
     
    284291                        decl = split[1].trim(); 
    285292                } 
    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(); 
    296306                } else { 
    297307                        // might be constructor  
     
    299309                        type = typeIndex.getId(); 
    300310                } 
    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("(")); 
    303314                } 
    304315                AXEntry memberIndex = typeIndex.createEntry(name, entryType); 
     316                memberIndex.getOrCreateReference(); 
    305317                // create reference 
    306                 memberIndex.getOrCreateReference(); 
    307318                typeIndex.getEntries().add(memberIndex); 
    308319                return memberIndex; 
     
    321332                } 
    322333        } 
     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        } 
    323343        private void parseTypeMemberInfo(AXEntry typeIndex, Node detail) throws DOMException, XPathExpressionException { 
    324344                AXEntryType entryType = parseTypeMemberEntryType(detail); 
    325345                if (entryType == null) 
    326346                        return; 
    327                 Node child = detail.getFirstChild(); 
     347                Node child = getReal(detail.getFirstChild()); 
    328348                // child contains the declaration string 
    329349                String childCode = child.getTextContent().trim(); 
    330350                log(3,"[DDD] found detail: "+ childCode); 
    331351                AXEntry memberIndex = createTypeMemberEntry(typeIndex,entryType,childCode); 
    332                 child = child.getNextSibling(); 
     352                child = getReal(child.getNextSibling()); 
     353                if (child == null) 
     354                        return; 
    333355                boolean isGetterSetter = child.getNodeType() == Node.TEXT_NODE; 
    334356                if (isGetterSetter) { 
    335357                        // if accessor property (getter setter) ignore 
    336                         child = child.getNextSibling(); 
     358                        child = getReal(child.getNextSibling()); 
    337359                } 
    338360                if (child.getNodeName().equals("div")) { 
    339361                        // ignore deprecated info divs 
    340                         child = child.getNextSibling(); 
     362                        child = getReal(child.getNextSibling()); 
    341363                } 
    342364                // ignore empty paragraph and following empty breaks  
    343                 do { 
    344                         child = child.getNextSibling(); 
    345                 } while (child != null && "br".equals(child.getNodeName())); 
    346365                // TODO tables with info about flash player version and the sort. 
    347366                while (child != null && "table".equals(child.getNodeName())) { 
    348                         child = child.getNextSibling(); 
     367                        child = getReal(child.getNextSibling()); 
    349368                } 
    350369                // ignore all empty text nodes, breaks and paragraphs 
    351370                while (child != null && !child.hasChildNodes()&&("".equals(child.getTextContent())||child.getNodeType() == Node.TEXT_NODE)) { 
    352                         child = child.getNextSibling(); 
     371                        child = getReal(child.getNextSibling()); 
    353372                } 
    354373                while (child != null && looksLikeDocNode(child)) { 
    355374                        // clean up doc and add to axmember 
    356375                        do { 
    357                                 child = child.getNextSibling(); 
     376                                child = getReal(child.getNextSibling()); 
    358377                        } while (child != null && child.getNodeType() == Node.TEXT_NODE); 
    359                 } 
    360                 while (child != null && "br".equals(child.getNodeName())) { 
    361                         child = child.getNextSibling(); 
    362378                } 
    363379                // we might be at the end 
     
    367383        } 
    368384        private AXEntryType getEntryType(String headerType) { 
     385                if (headerType == null) 
     386                        return null; 
     387                headerType = headerType.toLowerCase(); 
    369388                if ("method".equals(headerType)) { 
    370389                        return AXEntryType.METHOD; 
     
    373392                        return AXEntryType.PROPERTY; 
    374393                } else 
    375                 if ("Constant".equals(headerType)) { 
     394                if ("constant".equals(headerType)) { 
    376395                        return AXEntryType.CONSTANT; 
    377396                } else 
    378                 if ("Constructor".equals(headerType)) { 
     397                if ("constructor".equals(headerType)) { 
    379398                        return AXEntryType.CONSTRUCTOR; 
    380399                } 
     
    383402        private String parseTypeMemberHeader(Node detail) throws DOMException, XPathExpressionException { 
    384403                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(); 
    386406                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(); 
    388409        } 
    389410        protected boolean looksLikeDocNode(Node child) throws XPathExpressionException { 
  • org.axdt.axdoc/src/org/axdt/axdoc/util/Index0r.java

    r2aa064d r5c182b6  
    1515import org.axdt.axdoc.model.AXIndexNode; 
    1616import org.axdt.axdoc.model.AXLevel; 
     17import org.axdt.axdoc.model.AXNode; 
    1718import org.axdt.axdoc.model.AXRoot; 
    1819import org.axdt.axdoc.model.AXRootType; 
     
    2829import org.eclipse.emf.ecore.resource.ResourceSet; 
    2930import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
     31import org.eclipse.emf.ecore.util.EcoreUtil; 
    3032 
    3133public class Index0r { 
     
    4244        protected Map<String, AXRoot> roots; 
    4345        protected Map<String, List<AXIndex>> packages; 
    44         protected AXDocParser docParser; 
    4546        protected URI baseURI; 
    4647         
     
    4849                roots = Collections.synchronizedMap(new HashMap<String, AXRoot>()); 
    4950                packages = Collections.synchronizedMap(new HashMap<String, List<AXIndex>>()); 
    50                 docParser = new AXDocParser(); 
     51                 
    5152                baseURI = createBaseUri(); 
    5253        } 
     
    118119        } 
    119120        public AXRoot addSourceRoot(IContainer sourcefolder) { 
     121                if (sourcefolder == null) return null; 
    120122                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); 
    126125                return root; 
    127126        } 
     
    162161                if (root.getRootType() == AXRootType.ASDOC) { 
    163162                        try { 
     163                                AXDocParser docParser = new AXDocParser(); 
    164164                                docParser.parseDoc(root, level); 
    165165                                if (root.isDirty()) 
     
    178178                if (index == null) 
    179179                        return; 
    180                 try { 
    181                         index.save(null); 
    182                 } catch (IOException e) { 
    183                         log("error saving asdoc at "+root.getUrl(), e); 
    184                 } 
    185180                EList<Resource> resources = index.getResourceSet().getResources(); 
    186181                for (Resource res:resources) { 
    187                         if (index.equals(res))  
    188                                 continue; 
    189182                        try { 
    190183                                res.save(null); 
     
    202195                Resource[] resources = list.toArray(new Resource[list.size()]); 
    203196                for (Resource res:resources) { 
    204                         if (index.equals(res)) continue; 
     197                        if (index.equals(res)) 
     198                                continue; 
    205199                        try { 
    206200                                res.delete(null); 
     
    209203                        } 
    210204                } 
    211                 index.getContents().clear(); 
     205                for (EObject eobj:root.eContents()) 
     206                        EcoreUtil.remove(eobj); 
    212207        } 
    213208        protected void log(String text, Exception e) { 
     
    267262                return packages.get(packname); 
    268263        } 
     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        } 
    269287} 
  • org.axdt.common/src/org/axdt/util/IFlexErrorCodes.java

    r79dd699 r5c182b6  
    177177        int IncompatibleInterfaceMethodSignature = 1144; 
    178178        // 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; 
    179188}