From 13e422ef463ad464f4e58573c94b5434423252b7 Mon Sep 17 00:00:00 2001 From: Rene Schneider Date: Fri, 26 Jan 2018 15:28:54 +0100 Subject: [PATCH] scoping speedup stuff --- .../integrity/scoping/DSLScopeProvider.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/de.gebit.integrity.dsl/src/de/gebit/integrity/scoping/DSLScopeProvider.java b/de.gebit.integrity.dsl/src/de/gebit/integrity/scoping/DSLScopeProvider.java index 5ccbcac81..099107f1a 100644 --- a/de.gebit.integrity.dsl/src/de/gebit/integrity/scoping/DSLScopeProvider.java +++ b/de.gebit.integrity.dsl/src/de/gebit/integrity/scoping/DSLScopeProvider.java @@ -831,8 +831,7 @@ private IScope getVisibleGlobalConstantsAndVariablesScope(EObject aStatement) { // Now use the cache to build a scope of all visible global constants and variables, taking imports into // account try { - // Import all packages defined in the current file by default. This is mostly to get global stuff - // defined in other packagedefs that have the same name as ours. + // Import all packages defined in the current file by default. List tempImports = new ArrayList<>(); for (Statement tempStatement : tempRootModel.getStatements()) { if (tempStatement instanceof PackageDefinition) { @@ -866,27 +865,33 @@ private IScope getVisibleGlobalConstantsAndVariablesScope(EObject aStatement) { tempImportedGlobalVariablesScope = cachedImportedGlobalVariablesScope; } - // Import all vars/consts from the packages defined in the current file by default. This is the highest-priority - // outermost scope, and it is not cached or generated from cached data, because if it was, we would generate - // dangling references while files are being edited and partially parsed in the Eclipse editor. - List tempImportedGlobalVariablesFromLocalPackages = new ArrayList(); - for (Statement tempStatement : tempRootModel.getStatements()) { - if (tempStatement instanceof PackageDefinition) { - for (PackageStatement tempPackageStatement : ((PackageDefinition) tempStatement).getStatements()) { - if (tempPackageStatement instanceof VariableDefinition) { - tempImportedGlobalVariablesFromLocalPackages.add(EObjectDescription.create( - ((VariableDefinition) tempPackageStatement).getName().getName(), - ((VariableDefinition) tempPackageStatement).getName())); - } else if (tempPackageStatement instanceof ConstantDefinition) { - tempImportedGlobalVariablesFromLocalPackages.add(EObjectDescription.create( - ((ConstantDefinition) tempPackageStatement).getName().getName(), - ((ConstantDefinition) tempPackageStatement).getName())); + IScope tempScope = tempImportedGlobalVariablesScope; + if (!insideFullBuildCycle) { + // Import all vars/consts from the packages defined in the current file by default. This is the + // highest-priority outermost scope, it just imports stuff that is already imported by the cache, so we + // don't need this in case we largely rely on cached data (like with full builds). In case of incremental + // builds however, this thing is used, and it is not cached or generated from cached data, because if it + // was, we would generate dangling references while files are being edited and partially parsed in the + // Eclipse editor. + List tempImportedGlobalVariablesFromLocalPackages = new ArrayList(); + for (Statement tempStatement : tempRootModel.getStatements()) { + if (tempStatement instanceof PackageDefinition) { + for (PackageStatement tempPackageStatement : ((PackageDefinition) tempStatement).getStatements()) { + if (tempPackageStatement instanceof VariableDefinition) { + tempImportedGlobalVariablesFromLocalPackages.add(EObjectDescription.create( + ((VariableDefinition) tempPackageStatement).getName().getName(), + ((VariableDefinition) tempPackageStatement).getName())); + } else if (tempPackageStatement instanceof ConstantDefinition) { + tempImportedGlobalVariablesFromLocalPackages.add(EObjectDescription.create( + ((ConstantDefinition) tempPackageStatement).getName().getName(), + ((ConstantDefinition) tempPackageStatement).getName())); + } } } } + + tempScope = new SimpleScope(tempImportedGlobalVariablesScope, tempImportedGlobalVariablesFromLocalPackages); } - IScope tempScope = new SimpleScope(tempImportedGlobalVariablesScope, - tempImportedGlobalVariablesFromLocalPackages); // Finally, filter out private variables not in the current package by wrapping this in a filtering scope return filterPrivateElements(tempScope, aStatement);