Changeset 1231

Show
Ignore:
Timestamp:
07/18/08 22:27:10 (2 months ago)
Author:
asterite
Message:

Optimizations for autocompletion, uploaded a new nightly build

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/META-INF/MANIFEST.MF

    r1228 r1231  
    33Bundle-Name: %pluginName 
    44Bundle-SymbolicName: descent.core;singleton:=true 
    5 Bundle-Version: 0.5.3.20080713 
     5Bundle-Version: 0.5.3.20080718 
    66Bundle-Activator: descent.core.JavaCore 
    77Bundle-Vendor: %providerName 
  • trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java

    r1228 r1231  
    722722         
    723723        if (node.mod != null) { 
    724             node.mod = node.mod.unlazy(semanticContext); 
    725724            if (node.selectiveName == null) { 
    726725                this.startPosition = actualCompletionPosition; 
     
    730729                this.currentName = computePrefixAndSourceRange(node.selectiveName); 
    731730            } 
     731             
     732            node.mod = node.mod.unlazy(this.currentName, semanticContext); 
     733             
    732734            this.wantArguments = false; 
    733735            suggestMembers(node.mod.members, false, new HashtableOfCharArrayAndObject(), INCLUDE_TYPES | INCLUDE_VARIABLES | INCLUDE_FUNCTIONS); 
     
    10961098         
    10971099        if (sym instanceof ClassDeclaration) { 
    1098             ClassDeclaration cd = ((ClassDeclaration) sym).unlazy(semanticContext); 
     1100            ClassDeclaration cd = ((ClassDeclaration) sym).unlazy(this.currentName, semanticContext); 
    10991101             
    11001102            Declaration func = cd.ctor; 
     
    11281130            } 
    11291131        } else if (sym instanceof StructDeclaration) { 
    1130             StructDeclaration struct = ((StructDeclaration) sym).unlazy(semanticContext); 
     1132            StructDeclaration struct = ((StructDeclaration) sym).unlazy(CharOperation.NO_CHAR, semanticContext); 
    11311133            suggestMembers(struct.members, onlyStatics, 0, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
    11321134        } 
     
    18861888     
    18871889    private void completeTypeClassRecursively(TypeClass type, boolean onlyStatics, HashtableOfCharArrayAndObject funcSignatures) { 
    1888         ClassDeclaration decl = type.sym == null ? null : type.sym.unlazy(semanticContext); 
     1890        ClassDeclaration decl = type.sym == null ? null : type.sym.unlazy(this.currentName, semanticContext); 
    18891891        if (decl == null) { 
    18901892            return; 
     
    19101912     
    19111913    private void completeTypeStruct(TypeStruct type, boolean onlyStatics) { 
    1912         StructDeclaration decl = type.sym == null ? null : type.sym.unlazy(semanticContext); 
     1914        StructDeclaration decl = type.sym == null ? null : type.sym.unlazy(this.currentName, semanticContext); 
    19131915        if (decl == null) { 
    19141916            return; 
     
    20492051                if (!suggestedModules.containsKey(fqn)) { 
    20502052                    suggestedModules.put(fqn, this); 
    2051                      
    2052                     mod = mod.unlazy(semanticContext); 
    2053                      
     2053                    mod = mod.unlazy(this.currentName, semanticContext); 
    20542054                    suggestMembers(mod.members, false, funcSignatures, includes & (~INCLUDE_IMPORTS)); 
    20552055                } 
     
    22412241                    if (parser.inNewExp) { 
    22422242                        if (type instanceof TypeClass) { 
    2243                             ClassDeclaration cd = ((TypeClass) type).sym.unlazy(semanticContext); 
     2243                            ClassDeclaration cd = ((TypeClass) type).sym.unlazy(this.currentName, semanticContext); 
    22442244                            if (cd.isClassDeclaration() != null && cd.isInterfaceDeclaration() == null) { 
    22452245                                // If it's abstract, skip 
     
    25482548        // opCall 
    25492549        case ASTDmdNode.TYPE_STRUCT: { 
    2550             StructDeclaration sym = (((TypeStruct) type).sym).unlazy(semanticContext); 
    25512550            currentName = ident; 
     2551            StructDeclaration sym = (((TypeStruct) type).sym).unlazy(this.currentName, semanticContext);             
    25522552            suggestMembers(sym.members, onlyStatics, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
    25532553            break; 
    25542554        } 
    2555         case ASTDmdNode.TYPE_CLASS: {            
    2556             ClassDeclaration sym = (((TypeClass) type).sym).unlazy(semanticContext); 
     2555        case ASTDmdNode.TYPE_CLASS: { 
    25572556            currentName = ident; 
     2557            ClassDeclaration sym = (((TypeClass) type).sym).unlazy(this.currentName, semanticContext);           
    25582558            suggestMembers(sym.members, onlyStatics, new HashtableOfCharArrayAndObject(), INCLUDE_OPCALL); 
    25592559             
  • trunk/descent.core/src/descent/internal/codeassist/impl/AssistOptions.java

    r1224 r1231  
    247247                String[] strings = moduleNames.split(","); 
    248248                for(String string : strings) { 
    249                     ignoredNonImportedModules.put(string.trim().toCharArray(), this); 
     249                    string = string.trim(); 
     250                    if (string.length() > 0) { 
     251                        ignoredNonImportedModules.put(string.toCharArray(), this); 
     252                    } 
    250253                } 
    251254            } 
  • trunk/descent.core/src/descent/internal/compiler/lookup/ILazyAggregate.java

    r1208 r1231  
    3131    void symtab(DsymbolTable table); 
    3232 
     33    boolean isUnlazy(); 
     34 
    3335} 
  • trunk/descent.core/src/descent/internal/compiler/lookup/LazyAggregateDeclaration.java

    r1222 r1231  
    2020public class LazyAggregateDeclaration { 
    2121     
    22     private HashtableOfCharArrayAndObject javaElementMembersCache; 
    23     private List<Dsymbol> pendingPublicImports; 
    24     private List<Dsymbol> pendingPrivateImports; 
    25     private boolean cancelLazyness; 
    26     private ILazyAggregate lazy; 
     22    HashtableOfCharArrayAndObject javaElementMembersCache; 
     23    List<Dsymbol> pendingPublicImports; 
     24    List<Dsymbol> pendingPrivateImports; 
     25    boolean cancelLazyness; 
     26    ILazyAggregate lazy; 
    2727     
    2828    public LazyAggregateDeclaration(ILazyAggregate lazy) { 
     
    3939        if (s == null) { 
    4040            if (javaElementMembersCache == null) { 
    41                 javaElementMembersCache = new HashtableOfCharArrayAndObject(); 
    42                 List<Dsymbol> privateImports = new ArrayList<Dsymbol>(); 
    43                 List<Dsymbol> publicImports = new ArrayList<Dsymbol>(); 
    44                 FillResult result = null ; 
    45                 try { 
    46                     result = lazy.builder().fillJavaElementMembersCache(lazy, lazy.getJavaElement().getChildren(), javaElementMembersCache, lazy.members(), privateImports, publicImports, context); 
    47                 } catch (JavaModelException e) { 
    48                     Util.log(e); 
    49                 } 
     41                FillResult result = fillJavaElementMemebrsCache(context); 
    5042                 
    5143                if (result.hasMixinDeclaration || result.hasStaticIf || result.hasAnon) { 
    52                     cancelLazyness = true; 
    53                     lazy.members(new Dsymbols()); 
    54                     try { 
    55                         lazy.builder().fill(lazy.getModule(), lazy.members(), lazy.getJavaElement().getChildren(), null); 
    56                     } catch (JavaModelException e) { 
    57                         Util.log(e); 
    58                     } 
    59                      
    60                     int size = lazy.members().size(); 
    61                      
    62                     for (int i = 0; i < size; i++) { 
    63                         Dsymbol sym = lazy.members().get(i); 
    64                         sym.addMember(lazy.semanticScope(), lazy.asScopeDsymbol(), 0, context); 
    65                         lazy.runMissingSemantic(sym, context); 
    66                     } 
    67                      
    6844                    return search(loc, ident, flags, context); 
    69                 } 
    70                  
    71                 if (!privateImports.isEmpty()) { 
    72                     pendingPrivateImports = privateImports;  
    73                 } 
    74                 if (!publicImports.isEmpty()) { 
    75                     pendingPublicImports = publicImports;    
    7645                } 
    7746                 
     
    159128        return s; 
    160129    } 
     130 
     131    FillResult fillJavaElementMemebrsCache(SemanticContext context) { 
     132        javaElementMembersCache = new HashtableOfCharArrayAndObject(); 
     133        List<Dsymbol> privateImports = new ArrayList<Dsymbol>(); 
     134        List<Dsymbol> publicImports = new ArrayList<Dsymbol>(); 
     135        FillResult result = null ; 
     136        try { 
     137            result = lazy.builder().fillJavaElementMembersCache(lazy, lazy.getJavaElement().getChildren(), javaElementMembersCache, lazy.members(), privateImports, publicImports, context); 
     138        } catch (JavaModelException e) { 
     139            Util.log(e); 
     140        } 
     141         
     142        if (!privateImports.isEmpty()) { 
     143            pendingPrivateImports = privateImports;  
     144        } 
     145        if (!publicImports.isEmpty()) { 
     146            pendingPublicImports = publicImports;    
     147        } 
     148         
     149        if (result.hasMixinDeclaration || result.hasStaticIf || result.hasAnon) { 
     150            cancelLazyness = true; 
     151            lazy.members(new Dsymbols()); 
     152            try { 
     153                lazy.builder().fill(lazy.getModule(), lazy.members(), lazy.getJavaElement().getChildren(), null); 
     154            } catch (JavaModelException e) { 
     155                Util.log(e); 
     156            } 
     157             
     158            int size = lazy.members().size(); 
     159             
     160            for (int i = 0; i < size; i++) { 
     161                Dsymbol sym = lazy.members().get(i); 
     162                sym.addMember(lazy.semanticScope(), lazy.asScopeDsymbol(), 0, context); 
     163                lazy.runMissingSemantic(sym, context); 
     164            } 
     165        } 
     166         
     167        return result; 
     168    } 
    161169     
    162170    public void runMissingSemantic(Dsymbol sym, SemanticContext context) { 
     
    165173            sym.semantic(Scope.copy(lazy.semanticScope()), context); 
    166174        } 
    167         if (lazy.semantic2Scope() != null) { 
    168             sym.semantic2(Scope.copy(lazy.semantic2Scope()), context); 
    169         } 
    170         if (lazy.semantic3Scope() != null) { 
    171             sym.semantic3(Scope.copy(lazy.semantic3Scope()), context); 
     175        if (!lazy.isUnlazy()) { 
     176            if (lazy.semantic2Scope() != null) { 
     177                sym.semantic2(Scope.copy(lazy.semantic2Scope()), context); 
     178            } 
     179            if (lazy.semantic3Scope() != null) { 
     180                sym.semantic3(Scope.copy(lazy.semantic3Scope()), context); 
     181            } 
    172182        } 
    173183        context.muteProblems--; 
  • trunk/descent.core/src/descent/internal/compiler/lookup/LazyClassDeclaration.java

    r1207 r1231  
    11package descent.internal.compiler.lookup; 
    22 
    3 import descent.core.JavaModelException; 
     3import descent.core.compiler.CharOperation; 
    44import descent.internal.compiler.parser.BaseClasses; 
    55import descent.internal.compiler.parser.ClassDeclaration; 
     
    1212import descent.internal.compiler.parser.ScopeDsymbol; 
    1313import descent.internal.compiler.parser.SemanticContext; 
    14 import descent.internal.core.util.Util; 
    1514 
    1615public class LazyClassDeclaration extends ClassDeclaration implements ILazyAggregate { 
     
    3029    } 
    3130     
    32     private ClassDeclaration unlazyOne; 
    33     public ClassDeclaration unlazy(SemanticContext context) { 
    34         if (unlazyOne == null) { 
     31    private boolean isUnlazy; 
     32     
     33    public boolean isUnlazy() { 
     34        return isUnlazy; 
     35    } 
     36     
     37    public ClassDeclaration unlazy(char[] prefix, SemanticContext context) { 
     38        if (!isUnlazy) { 
     39            isUnlazy = true; 
     40             
    3541            if (baseClass != null) { 
    36                 baseClass = baseClass.unlazy(context); 
     42                baseClass = baseClass.unlazy(prefix, context); 
    3743            } 
    3844             
    3945            for (int i = 0; i < size(baseclasses); i++) { 
    40                 unlazy(baseclasses.get(i), context); 
     46                unlazy(baseclasses.get(i), prefix, context); 
    4147            } 
    4248             
    43             unlazyOne = new ClassDeclaration(loc, ident, baseclasses); 
    44             unlazyOne.parent = this.parent; 
    45             unlazyOne.members = new Dsymbols(); 
    46             try { 
    47                 builder.fill(getModule(), unlazyOne.members, javaElement.getChildren(), null); 
    48             } catch (JavaModelException e) { 
    49                 Util.log(e); 
     49            if (lazy.javaElementMembersCache == null) { 
     50                lazy.fillJavaElementMemebrsCache(context); 
    5051            } 
    51             unlazyOne.setJavaElement(this.javaElement); 
    52             runMissingSemantic(unlazyOne, context); 
     52             
     53            if (!lazy.cancelLazyness) { 
     54                 
     55                for(char[] key : lazy.javaElementMembersCache.keys()) { 
     56                    if (key != null && CharOperation.prefixEquals(prefix, key, false)) { 
     57                        search(Loc.ZERO, key, 0, context); 
     58                    } 
     59                } 
     60            } 
    5361        } 
    54         return unlazyOne
     62        return this
    5563    } 
    5664     
  • trunk/descent.core/src/descent/internal/compiler/lookup/LazyInterfaceDeclaration.java

    r1207 r1231  
    11package descent.internal.compiler.lookup; 
    22 
    3 import descent.core.JavaModelException; 
     3import descent.core.compiler.CharOperation; 
    44import descent.internal.compiler.parser.BaseClasses; 
    55import descent.internal.compiler.parser.Dsymbol; 
     
    1212import descent.internal.compiler.parser.ScopeDsymbol; 
    1313import descent.internal.compiler.parser.SemanticContext; 
    14 import descent.internal.core.util.Util; 
    1514 
    1615public class LazyInterfaceDeclaration extends InterfaceDeclaration implements ILazyAggregate { 
     
    3029    } 
    3130     
    32     private InterfaceDeclaration unlazyOne; 
    33     public InterfaceDeclaration unlazy(SemanticContext context) { 
    34         if (unlazyOne == null) { 
     31    private boolean isUnlazy; 
     32     
     33    public boolean isUnlazy() { 
     34        return isUnlazy; 
     35    } 
     36     
     37    public InterfaceDeclaration unlazy(char[] prefix, SemanticContext context) { 
     38        if (!isUnlazy) { 
     39            isUnlazy = true; 
     40             
    3541            if (baseClass != null) { 
    36                 baseClass = baseClass.unlazy(context); 
     42                baseClass = baseClass.unlazy(prefix, context); 
    3743            } 
    3844             
    3945            for (int i = 0; i < size(baseclasses); i++) { 
    40                 unlazy(baseclasses.get(i), context); 
     46                unlazy(baseclasses.get(i), prefix, context); 
    4147            } 
    4248             
    43             unlazyOne = new InterfaceDeclaration(loc, ident, baseclasses); 
    44             unlazyOne.parent = this.parent; 
    45             unlazyOne.members = new Dsymbols(); 
    46             try { 
    47                 builder.fill(getModule(), unlazyOne.members, javaElement.getChildren(), null); 
    48             } catch (JavaModelException e) { 
    49                 Util.log(e); 
     49            if (lazy.javaElementMembersCache == null) { 
     50                lazy.fillJavaElementMemebrsCache(context); 
    5051            } 
    51             unlazyOne.setJavaElement(this.javaElement); 
    52             runMissingSemantic(unlazyOne, context); 
     52             
     53            if (!lazy.cancelLazyness) { 
     54                for(char[] key : lazy.javaElementMembersCache.keys()) { 
     55                    if (key != null && CharOperation.prefixEquals(prefix, key, false)) { 
     56                        search(Loc.ZERO, key, 0, context); 
     57                    } 
     58                } 
     59            } 
    5360        } 
    54         return unlazyOne
     61        return this
    5562    } 
    5663     
  • trunk/descent.core/src/descent/internal/compiler/lookup/LazyModule.java

    r1222 r1231  
    44import java.util.List; 
    55 
     6import descent.core.IConditional; 
     7import descent.core.IInitializer; 
    68import descent.core.IJavaElement; 
    79import descent.core.IType; 
     
    8486    } 
    8587     
    86     private Module unlazyOne; 
    87     public Module unlazy(SemanticContext context) { 
    88         if (unlazyOne == null) { 
    89             unlazyOne = builder.buildNonLazyModule(javaElement); 
    90             unlazyOne.semantic(context); 
    91         } 
    92         return unlazyOne; 
     88    private boolean isUnlazy; 
     89    public Module unlazy(char[] prefix, SemanticContext context) { 
     90        if (!isUnlazy) { 
     91            isUnlazy = true; 
     92            for(char[] key : topLevelIdentifiers.keys()) { 
     93                if (key != null && CharOperation.prefixEquals(prefix, key, false)) { 
     94                    search(Loc.ZERO, key, 0, context); 
     95                } 
     96            } 
     97        } 
     98        return this; 
    9399    } 
    94100     
     
    140146            if (javaElementMembersCache == null) { 
    141147                Object target = topLevelIdentifiers.get(ident); 
     148                 
     149                target = filter(target); 
    142150                 
    143151                if (target != null) { 
     
    212220    } 
    213221 
     222    // Remove element that are under false conditionals 
     223    private Object filter(Object target) { 
     224        if (target == null) { 
     225            return null; 
     226        } 
     227         
     228        if (target instanceof IJavaElement) { 
     229            IJavaElement element = (IJavaElement) target; 
     230            return isActive(element) ? element : null; 
     231        } else if (target instanceof List) { 
     232            List<IJavaElement> elements = (List<IJavaElement>) target; 
     233            List<IJavaElement> filteredElements = new ArrayList<IJavaElement>(elements.size()); 
     234            for(IJavaElement element : elements) { 
     235                if (isActive(element)) { 
     236                    filteredElements.add(element); 
     237                } 
     238            } 
     239            if (filteredElements.isEmpty()) { 
     240                return null; 
     241            } else if (filteredElements.size() == 1) { 
     242                return filteredElements.get(0); 
     243            } else { 
     244                return filteredElements; 
     245            } 
     246        } 
     247         
     248        return target; 
     249    } 
     250 
     251    private boolean isActive(IJavaElement element) { 
     252        switch(element.getParent().getElementType()) { 
     253        case IJavaElement.COMPILATION_UNIT: 
     254            return true; 
     255        case IJavaElement.INITIALIZER: 
     256            IInitializer init = (IInitializer) element.getParent(); 
     257            try { 
     258                if (init.isThen()) { 
     259                    return builder.isThenActive((IConditional) init.getParent(), this); 
     260                } else if (init.isElse()) { 
     261                    return !builder.isThenActive((IConditional) init.getParent(), this); 
     262                } else { 
     263                    return true; 
     264                } 
     265            } catch (JavaModelException e) { 
     266                Util.log(e); 
     267                return true; 
     268            } 
     269        case IJavaElement.CONDITIONAL: 
     270            IConditional cond = (IConditional) element.getParent(); 
     271            try { 
     272                return builder.isThenActive(cond, this); 
     273            } catch (JavaModelException e) { 
     274                Util.log(e); 
     275                return true; 
     276            } 
     277        } 
     278        return false; 
     279    } 
     280 
    214281    private boolean isEasy(IJavaElement element) { 
    215         return element.getParent().getElementType() == IJavaElement.COMPILATION_UNIT; 
     282        switch(element.getParent().getElementType()) { 
     283        case IJavaElement.COMPILATION_UNIT: 
     284            return true; 
     285        case IJavaElement.CONDITIONAL: 
     286            return isEasy(element.getParent()); 
     287        default: 
     288            return false; 
     289        } 
    216290    } 
    217291 
     
    310384            sym.semantic(Scope.copy(semanticScope), context); 
    311385        } 
    312         if (semantic2Scope != null) { 
    313             sym.semantic2(Scope.copy(semantic2Scope), context); 
    314         } 
    315         if (semantic3Scope != null) { 
    316             sym.semantic3(Scope.copy(semantic3Scope), context); 
     386        if (!isUnlazy) { 
     387            if (semantic2Scope != null) { 
     388                sym.semantic2(Scope.copy(semantic2Scope), context); 
     389            } 
     390            if (semantic3Scope != null) { 
     391                sym.semantic3(Scope.copy(semantic3Scope), context); 
     392            } 
    317393        } 
    318394        context.muteProblems--; 
  • trunk/descent.core/src/descent/internal/compiler/lookup/LazyStructDeclaration.java

    r1207 r1231  
    11package descent.internal.compiler.lookup; 
    22 
    3 import descent.core.JavaModelException; 
     3import descent.core.compiler.CharOperation; 
    44import descent.internal.compiler.parser.Dsymbol; 
    55import descent.internal.compiler.parser.DsymbolTable; 
     
    1111import descent.internal.compiler.parser.SemanticContext; 
    1212import descent.internal.compiler.parser.StructDeclaration; 
    13 import descent.internal.core.util.Util; 
    1413 
    1514public class LazyStructDeclaration extends StructDeclaration implements ILazyAggregate { 
     
    2928    } 
    3029     
    31     private StructDeclaration unlazyOne; 
    32     public StructDeclaration unlazy(SemanticContext context) { 
    33         if (unlazyOne == null) { 
    34             unlazyOne = new StructDeclaration(loc, ident); 
    35             unlazyOne.parent = this.parent; 
    36             unlazyOne.members = new Dsymbols(); 
    37             try { 
    38                 builder.fill(getModule(), unlazyOne.members, javaElement.getChildren(), null); 
    39             } catch (JavaModelException e) { 
    40                 Util.log(e); 
     30    private boolean isUnlazy; 
     31     
     32    public boolean isUnlazy() { 
     33        return isUnlazy; 
     34    } 
     35     
     36    public StructDeclaration unlazy(char[] prefix, SemanticContext context) { 
     37        if (!isUnlazy) { 
     38            isUnlazy = true; 
     39             
     40            if (lazy.javaElementMembersCache == null) { 
     41                lazy.fillJavaElementMemebrsCache(context); 
    4142            } 
    42             unlazyOne.setJavaElement(this.javaElement); 
    43             runMissingSemantic(unlazyOne, context); 
     43             
     44            if (!lazy.cancelLazyness) { 
     45                 
     46                for(char[] key : lazy.javaElementMembersCache.keys()) { 
     47                    if (key != null && CharOperation.prefixEquals(prefix, key, false)) { 
     48                        search(Loc.ZERO, key, 0, context); 
     49                    } 
     50                } 
     51            } 
    4452        } 
    45         return unlazyOne
     53        return this
    4654    } 
    4755     
  • trunk/descent.core/src/descent/internal/compiler/lookup/ModuleBuilder.java

    r1222 r1231  
    263263                    buildConditional(module, members, cond, state, nameC, value, false /* not debug */); 
    264264                } else { 
    265                     if (config.isVersionEnabled(value) || value >= module.versionlevel) { 
     265                    if (config.isVersionEnabled(value) || module.versionlevel >= value) { 
    266266                        fill(module, members, cond.getThenChildren(), state); 
    267267                    } else { 
     
    288288                    buildConditional(module, members, cond, state, nameC, value, true /* debug */); 
    289289                } else {                     
    290                     if (config.isDebugEnabled(value) || value >= module.debuglevel) { 
     290                    if (config.isDebugEnabled(value) || module.debuglevel >= value) { 
    291291                        fill(module, members, cond.getThenChildren(), state); 
    292292                    } else { 
     
    839839                    if (cond.isStaticIfDeclaration()) { 
    840840                        result.hasStaticIf = true; 
    841                     } else if (cond.isVersionDeclaration()) { 
    842                         String name = cond.getElementName(); 
    843                         char[] nameC = name.toCharArray(); 
    844                         try { 
    845                             long value = Long.parseLong(name); 
    846                             if (config.isVersionEnabled(value) || value >= lazy.getModule().versionlevel) { 
    847                                 internalFillJavaElementMembersCache(lazy, cond.getThenChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    848                             } else { 
    849                                 internalFillJavaElementMembersCache(lazy, cond.getElseChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    850                             } 
    851                         } catch(NumberFormatException e) { 
    852                             if (config.isVersionEnabled(nameC) || (lazy.getModule().versionids != null && lazy.getModule().versionids.containsKey(nameC))) { 
    853                                 internalFillJavaElementMembersCache(lazy, cond.getThenChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    854                             } else { 
    855                                 internalFillJavaElementMembersCache(lazy, cond.getElseChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    856                             } 
    857                         } 
    858                     } else if (cond.isDebugDeclaration()) { 
    859                         String name = cond.getElementName(); 
    860                         char[] nameC = name.toCharArray(); 
    861                         try { 
    862                             long value = Long.parseLong(name); 
    863                             if (config.isDebugEnabled(value) || value >= lazy.getModule().debuglevel) { 
    864                                 internalFillJavaElementMembersCache(lazy, cond.getThenChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    865                             } else { 
    866                                 internalFillJavaElementMembersCache(lazy, cond.getElseChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    867                             } 
    868                         } catch(NumberFormatException e) { 
    869                             if (config.isDebugEnabled(nameC) || (lazy.getModule().debugids != null && lazy.getModule().debugids.containsKey(nameC))) { 
    870                                 internalFillJavaElementMembersCache(lazy, cond.getThenChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    871                             } else { 
    872                                 internalFillJavaElementMembersCache(lazy, cond.getElseChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    873                             } 
     841                    } else if (cond.isVersionDeclaration() || cond.isDebugDeclaration()) { 
     842                        if (isThenActive(cond, lazy)) { 
     843                            internalFillJavaElementMembersCache(lazy, cond.getThenChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
     844                        } else { 
     845                            internalFillJavaElementMembersCache(lazy, cond.getElseChildren(), javaElementMembersCache, symbols, privateImports, publicImports, context, result); 
    874846                        } 
    875847                    } 
     
    948920    } 
    949921     
     922    public boolean isThenActive(IConditional cond, ILazy lazy) throws JavaModelException { 
     923        if (cond.isVersionDeclaration()) { 
     924            String name = cond.getElementName(); 
     925            char[] nameC = name.toCharArray(); 
     926            try { 
     927                long value = Long.parseLong(name); 
     928                return config.isVersionEnabled(value) || lazy.getModule().versionlevel >= value; 
     929            } catch(NumberFormatException e) { 
     930                return config.isVersionEnabled(nameC) || (lazy.getModule().versionids != null && lazy.getModule().versionids.containsKey(nameC)); 
     931            } 
     932        } else if (cond.isDebugDeclaration()) { 
     933            String name = cond.getElementName(); 
     934            char[] nameC = name.toCharArray(); 
     935            try { 
     936                long value = Long.parseLong(name); 
     937                return config.isDebugEnabled(value) || lazy.getModule().debuglevel >= value; 
     938            } catch(NumberFormatException e) { 
     939                return config.isDebugEnabled(nameC) || (lazy.getModule().debugids != null && lazy.getModule().debugids.containsKey(nameC)); 
     940            } 
     941        } else { 
     942            throw new IllegalStateException("Can't happen"); 
     943        } 
     944    } 
     945     
    950946    public void fillImports(ILazy lazy, IJavaElement[] elements, List<Dsymbol> privateImports, List<Dsymbol> publicImports, SemanticContext context, int lastImportLocation) { 
    951947        try { 
     
    977973                    if (cond.isStaticIfDeclaration()) { 
    978974                         
    979                     } else if (cond.isVersionDeclaration()) { 
    980                         String name = cond.getElementName(); 
    981                         char[] nameC = name.toCharArray(); 
    982                         try { 
    983                             long value = Long.parseLong(name); 
    984                             if (config.isVersionEnabled(value) || value >= lazy.getModule().versionlevel) { 
    985                                 fillImports(lazy, cond.getThenChildren(), privateImports, publicImports, context, lastImportLocation); 
    986                             } else { 
    987                                 fillImports(lazy, cond.getElseChildren(), privateImports, publicImports, context, lastImportLocation); 
    988                             } 
    989                         } catch(NumberFormatException e) { 
    990                             if (config.isVersionEnabled(nameC) || (lazy.getModule().versionids != null && lazy.getModule().versionids.containsKey(nameC))) { 
    991                                 fillImports(lazy, cond.getThenChildren(), privateImports, publicImports, context, lastImportLocation); 
    992                             } else { 
    993                                 fillImports(lazy, cond.getElseChildren(), privateImports, publicImports, context, lastImportLocation); 
    994                             } 
    995                         } 
    996                     } else if (cond.isDebugDeclaration()) { 
    997                         String name = cond.getElementName(); 
    998                         char[] nameC = name.toCharArray(); 
    999                         try { 
    1000                             long value = Long.parseLong(name); 
    1001                             if (config.isDebugEnabled(value) || value >= lazy.getModule().debuglevel) { 
    1002                                 fillImports(lazy, cond.getThenChildren(), privateImports, publicImports, context, lastImportLocation); 
    1003                             } else { 
    1004                                 fillImports(lazy, cond.getElseChildren(), privateImports, publicImports, context, lastImportLocation); 
    1005                             } 
    1006                         } catch(NumberFormatException e) { 
    1007                             if (config.isDebugEnabled(nameC) || (lazy.getModule().debugids != null && lazy.getModule().debugids.containsKey(nameC))) { 
    1008                                 fillImports(lazy, cond.getThenChildren(), privateImports, publicImports, context, lastImportLocation); 
    1009                             } else { 
    1010                                 fillImports(lazy, cond.getElseChildren(), privateImports, publicImports, context, lastImportLocation); 
    1011                             } 
     975                    } else if (cond.isVersionDeclaration() || cond.isDebugDeclaration()) { 
     976                        if (isThenActive(cond, lazy)) { 
     977                            fillImports(lazy, cond.getThenChildren(), privateImports, publicImports, context, lastImportLocation); 
     978                        } else { 
     979                            fillImports(lazy, cond.getElseChildren(), privateImports, publicImports, context, lastImportLocation); 
    1012980                        } 
    1013981                    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/AggregateDeclaration.java

    r1203 r1231  
    457457    } 
    458458     
    459     public AggregateDeclaration unlazy(SemanticContext context) { 
     459    @Override 
     460    public AggregateDeclaration unlazy(char[] prefix, SemanticContext context) { 
    460461        return this; 
    461462    } 
  • trunk/descent.core/src/descent/internal/compiler/parser/ClassDeclaration.java

    r1203 r1231  
    2121 
    2222import descent.core.Signature; 
     23import descent.core.compiler.CharOperation; 
    2324import descent.core.compiler.IProblem; 
    2425import descent.internal.compiler.lookup.ModuleBuilder; 
     
    845846     
    846847    protected void unlazy(BaseClass bc, SemanticContext context) { 
     848        unlazy(bc, CharOperation.NO_CHAR, context); 
     849    } 
     850     
     851    protected void unlazy(BaseClass bc, char[] prefix, SemanticContext context) { 
    847852        if (bc.type instanceof TypeClass) { 
    848             unlazy((TypeClass) bc.type, context); 
    849         } 
    850         bc.base = bc.base == null ? null : bc.base.unlazy(context); 
    851     } 
    852  
     853            unlazy((TypeClass) bc.type, prefix, context); 
     854        } 
     855        bc.base = bc.base == null ? null : bc.base.unlazy(prefix, context); 
     856    } 
     857     
    853858    protected void unlazy(TypeClass type, SemanticContext context) { 
    854         type.sym = type.sym.unlazy(