Loading de.ugoe.cs.swe.TTCN3.ui/src/de/ugoe/cs/swe/ui/ScopeRebuild.java +18 −14 Original line number Diff line number Diff line Loading @@ -84,12 +84,14 @@ public class ScopeRebuild extends BuilderParticipant { for (IResourceDescription d : resourceDescriptionsProvider.getResourceDescriptions(context.getResourceSet()).getAllResourceDescriptions()) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); System.out.println("Reset: "+d.getURI()); TTCN3Module module = CommonHelper.getModule(r); List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { if (!TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); } } } for (IResourceDescription d : resourceDescriptionsProvider.getResourceDescriptions(context.getResourceSet()).getAllResourceDescriptions()) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); Loading @@ -107,7 +109,8 @@ public class ScopeRebuild extends BuilderParticipant { } } else { Resource r = resource; TTCN3Module module = CommonHelper.getModule(r); List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { //TODO: remove old resource? -> seems like no need TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); Loading @@ -118,6 +121,7 @@ public class ScopeRebuild extends BuilderParticipant { } catch (Exception e) { e.printStackTrace(); } } //TODO: refreshing a bit laggy // //TODO: rerun on others? // for (int i = 0; i < TTCN3GlobalScopeProvider.RESOURCES.size(); i++) { Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/CommonHelper.java +9 −3 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import java.util.ArrayList; import java.util.List; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; Loading @@ -7,14 +10,17 @@ import org.eclipse.emf.ecore.resource.Resource; import de.ugoe.cs.swe.tTCN3.TTCN3Module; public class CommonHelper { public static TTCN3Module getModule(Resource resource) { //TODO: this supports single modules per file only, apart from the fact that where and why is it used -> EcoreUtil should be able to do the job just as well.. //-> apparently EcoreUtil and EcoreUtil2 in particular only work on EObjects public static List<TTCN3Module> getModules(Resource resource) { List<TTCN3Module> modules = new ArrayList<>(); final TreeIterator<EObject> contentIterator = resource.getAllContents(); while (contentIterator.hasNext()) { final EObject next = contentIterator.next(); if (next instanceof TTCN3Module) { return (TTCN3Module) next; modules.add((TTCN3Module) next); } } return null; return modules; } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/PreAnalyzer.java +56 −50 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.emf.ecore.resource.Resource; Loading @@ -19,28 +20,30 @@ public class PreAnalyzer implements Callable<Boolean> { } private boolean findImports() { TTCN3Module currentModule = CommonHelper.getModule(this.resource); List<TTCN3Module> modules = CommonHelper.getModules(this.resource); for (TTCN3Module currentModule : modules) { for (ImportDef i : EcoreUtil2.getAllContentsOfType(currentModule, ImportDef.class)) { TTCN3Module importedModule = TTCN3GlobalScopeProvider.NAMED_MODULES.get(i.getName()); String key = this.resource.getURI().toString(); if (importedModule != null) { synchronized (TTCN3GlobalScopeProvider.IMPORTS) { if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTS.get(this.resource.getURI().toString()) //TODO: this is done on resource level, should be on module.. if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTS.get(key) .add(initializeImportedObjects(i, importedModule)); } else { TTCN3GlobalScopeProvider.IMPORTS.put(this.resource.getURI().toString(), TTCN3GlobalScopeProvider.IMPORTS.put(key, initializeImportedObjects(i, importedModule)); } } synchronized (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES) { if (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.get(this.resource.getURI().toString()).add(importedModule.eResource().getURI().toString()); if (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.get(key).add(importedModule.eResource().getURI().toString()); } else { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.put(this.resource.getURI().toString(), importedModule.eResource().getURI().toString()); TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.put(key, importedModule.eResource().getURI().toString()); } } Loading @@ -63,14 +66,15 @@ public class PreAnalyzer implements Callable<Boolean> { } } } // isASN = false; //TODO: is this still applicable with ASN support? if (!isASN) { synchronized (TTCN3GlobalScopeProvider.IMPORTS) { if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTS.get(this.resource.getURI().toString()) if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTS.get(key) .add(initializeImportedObjects(i, importedModule)); } else { TTCN3GlobalScopeProvider.IMPORTS.put(this.resource.getURI().toString(), TTCN3GlobalScopeProvider.IMPORTS.put(key, initializeImportedObjects(i, importedModule)); } } Loading @@ -78,6 +82,7 @@ public class PreAnalyzer implements Callable<Boolean> { } } } return true; } Loading @@ -86,7 +91,8 @@ public class PreAnalyzer implements Callable<Boolean> { if (module != null) { synchronized (TTCN3GlobalScopeProvider.EXPORTED_OBJECTS) { data.getExportedObjects().addAll(TTCN3GlobalScopeProvider.EXPORTED_OBJECTS.get(module.eResource().getURI().toString())); String string = module.eResource().getURI().toString(); data.getExportedObjects().addAll(TTCN3GlobalScopeProvider.EXPORTED_OBJECTS.get(string)); } } Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/scoping/TTCN3GlobalScopeProvider.java +6 −4 Original line number Diff line number Diff line Loading @@ -202,14 +202,16 @@ public class TTCN3GlobalScopeProvider extends AbstractGlobalScopeProvider { for (IResourceDescription d : rdp.getResourceDescriptions(resourceSet).getAllResourceDescriptions()) { if (d.getURI().lastSegment().endsWith("ttcn3") || d.getURI().lastSegment().endsWith("ttcn")) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); TTCN3Module module = CommonHelper.getModule(r); if (module !=null && !TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { if (!TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { // System.out.println(r.getURI()); TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); } } } } for (IResourceDescription d : rdp.getResourceDescriptions(resourceSet).getAllResourceDescriptions()) { if (d.getURI().lastSegment().endsWith("ttcn3") || d.getURI().lastSegment().endsWith("ttcn")) { Loading Loading
de.ugoe.cs.swe.TTCN3.ui/src/de/ugoe/cs/swe/ui/ScopeRebuild.java +18 −14 Original line number Diff line number Diff line Loading @@ -84,12 +84,14 @@ public class ScopeRebuild extends BuilderParticipant { for (IResourceDescription d : resourceDescriptionsProvider.getResourceDescriptions(context.getResourceSet()).getAllResourceDescriptions()) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); System.out.println("Reset: "+d.getURI()); TTCN3Module module = CommonHelper.getModule(r); List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { if (!TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); } } } for (IResourceDescription d : resourceDescriptionsProvider.getResourceDescriptions(context.getResourceSet()).getAllResourceDescriptions()) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); Loading @@ -107,7 +109,8 @@ public class ScopeRebuild extends BuilderParticipant { } } else { Resource r = resource; TTCN3Module module = CommonHelper.getModule(r); List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { //TODO: remove old resource? -> seems like no need TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); Loading @@ -118,6 +121,7 @@ public class ScopeRebuild extends BuilderParticipant { } catch (Exception e) { e.printStackTrace(); } } //TODO: refreshing a bit laggy // //TODO: rerun on others? // for (int i = 0; i < TTCN3GlobalScopeProvider.RESOURCES.size(); i++) { Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/CommonHelper.java +9 −3 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import java.util.ArrayList; import java.util.List; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; Loading @@ -7,14 +10,17 @@ import org.eclipse.emf.ecore.resource.Resource; import de.ugoe.cs.swe.tTCN3.TTCN3Module; public class CommonHelper { public static TTCN3Module getModule(Resource resource) { //TODO: this supports single modules per file only, apart from the fact that where and why is it used -> EcoreUtil should be able to do the job just as well.. //-> apparently EcoreUtil and EcoreUtil2 in particular only work on EObjects public static List<TTCN3Module> getModules(Resource resource) { List<TTCN3Module> modules = new ArrayList<>(); final TreeIterator<EObject> contentIterator = resource.getAllContents(); while (contentIterator.hasNext()) { final EObject next = contentIterator.next(); if (next instanceof TTCN3Module) { return (TTCN3Module) next; modules.add((TTCN3Module) next); } } return null; return modules; } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/PreAnalyzer.java +56 −50 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.emf.ecore.resource.Resource; Loading @@ -19,28 +20,30 @@ public class PreAnalyzer implements Callable<Boolean> { } private boolean findImports() { TTCN3Module currentModule = CommonHelper.getModule(this.resource); List<TTCN3Module> modules = CommonHelper.getModules(this.resource); for (TTCN3Module currentModule : modules) { for (ImportDef i : EcoreUtil2.getAllContentsOfType(currentModule, ImportDef.class)) { TTCN3Module importedModule = TTCN3GlobalScopeProvider.NAMED_MODULES.get(i.getName()); String key = this.resource.getURI().toString(); if (importedModule != null) { synchronized (TTCN3GlobalScopeProvider.IMPORTS) { if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTS.get(this.resource.getURI().toString()) //TODO: this is done on resource level, should be on module.. if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTS.get(key) .add(initializeImportedObjects(i, importedModule)); } else { TTCN3GlobalScopeProvider.IMPORTS.put(this.resource.getURI().toString(), TTCN3GlobalScopeProvider.IMPORTS.put(key, initializeImportedObjects(i, importedModule)); } } synchronized (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES) { if (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.get(this.resource.getURI().toString()).add(importedModule.eResource().getURI().toString()); if (TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.get(key).add(importedModule.eResource().getURI().toString()); } else { TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.put(this.resource.getURI().toString(), importedModule.eResource().getURI().toString()); TTCN3GlobalScopeProvider.IMPORTED_RESOURCES.put(key, importedModule.eResource().getURI().toString()); } } Loading @@ -63,14 +66,15 @@ public class PreAnalyzer implements Callable<Boolean> { } } } // isASN = false; //TODO: is this still applicable with ASN support? if (!isASN) { synchronized (TTCN3GlobalScopeProvider.IMPORTS) { if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(this.resource.getURI().toString())) { TTCN3GlobalScopeProvider.IMPORTS.get(this.resource.getURI().toString()) if (TTCN3GlobalScopeProvider.IMPORTS.containsKey(key)) { TTCN3GlobalScopeProvider.IMPORTS.get(key) .add(initializeImportedObjects(i, importedModule)); } else { TTCN3GlobalScopeProvider.IMPORTS.put(this.resource.getURI().toString(), TTCN3GlobalScopeProvider.IMPORTS.put(key, initializeImportedObjects(i, importedModule)); } } Loading @@ -78,6 +82,7 @@ public class PreAnalyzer implements Callable<Boolean> { } } } return true; } Loading @@ -86,7 +91,8 @@ public class PreAnalyzer implements Callable<Boolean> { if (module != null) { synchronized (TTCN3GlobalScopeProvider.EXPORTED_OBJECTS) { data.getExportedObjects().addAll(TTCN3GlobalScopeProvider.EXPORTED_OBJECTS.get(module.eResource().getURI().toString())); String string = module.eResource().getURI().toString(); data.getExportedObjects().addAll(TTCN3GlobalScopeProvider.EXPORTED_OBJECTS.get(string)); } } Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/scoping/TTCN3GlobalScopeProvider.java +6 −4 Original line number Diff line number Diff line Loading @@ -202,14 +202,16 @@ public class TTCN3GlobalScopeProvider extends AbstractGlobalScopeProvider { for (IResourceDescription d : rdp.getResourceDescriptions(resourceSet).getAllResourceDescriptions()) { if (d.getURI().lastSegment().endsWith("ttcn3") || d.getURI().lastSegment().endsWith("ttcn")) { Resource r = resource.getResourceSet().getResource(d.getURI(), true); TTCN3Module module = CommonHelper.getModule(r); if (module !=null && !TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { List<TTCN3Module> modules = CommonHelper.getModules(r); for (TTCN3Module module : modules) { if (!TTCN3GlobalScopeProvider.NAMED_MODULES.containsKey(module.getName())) { // System.out.println(r.getURI()); TTCN3GlobalScopeProvider.RESOURCES.add(r); TTCN3GlobalScopeProvider.NAMED_MODULES.put(module.getName(), module); } } } } for (IResourceDescription d : rdp.getResourceDescriptions(resourceSet).getAllResourceDescriptions()) { if (d.getURI().lastSegment().endsWith("ttcn3") || d.getURI().lastSegment().endsWith("ttcn")) { Loading