diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/completion/JSGLRCompletionService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/completion/JSGLRCompletionService.java index 23e54df22..e70f3c482 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/completion/JSGLRCompletionService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/completion/JSGLRCompletionService.java @@ -140,11 +140,11 @@ public Collection completionEmptyProgram(Iterable Collection completions = Lists.newLinkedList(); final String languageName = language.belongsTo().name(); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(ILanguageComponent component : language.components()) { // call Stratego part of the framework to compute change final HybridInterpreter runtime = strategoRuntimeService.runtime(component, location); - final ITermFactory termFactory = termFactoryService.get(component, null); for(String startSymbol : startSymbols) { String placeholderName = startSymbol + "-Plhdr"; @@ -219,12 +219,10 @@ public Collection completionCorrectPrograms(int position, boolean b final FileObject location = parseResult.source(); final ILanguageImpl language = parseResult.input().langImpl(); final String languageName = language.belongsTo().name(); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(ILanguageComponent component : language.components()) { - - final HybridInterpreter runtime = strategoRuntimeService.runtime(component, location); - final ITermFactory termFactory = termFactoryService.get(component, null); final Map leftRecursiveTerms = new HashMap(); final Map rightRecursiveTerms = new HashMap(); @@ -268,7 +266,7 @@ private Collection recursiveCompletions(Iterable placeholderCompletions(IStrategoAppl placeholder, // call Stratego part of the framework to compute change final HybridInterpreter runtime = strategoRuntimeService.runtime(component, location); - final ITermFactory termFactory = termFactoryService.get(component, null); + final ITermFactory termFactory = termFactoryService.getGeneric(); IStrategoTerm placeholderParent = ParentAttachment.getParent(placeholder); if(placeholderParent == null) { @@ -444,7 +442,7 @@ public Collection optionalCompletions(Iterable optio Collection completions = Lists.newLinkedList(); - final ITermFactory termFactory = termFactoryService.get(component, null); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(IStrategoTerm optional : optionals) { @@ -509,7 +507,7 @@ public Collection listsCompletions(int position, boolean blankLineC Collection completions = Lists.newLinkedList(); - final ITermFactory termFactory = termFactoryService.get(component, null); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(IStrategoList list : lists) { ListImploderAttachment attachment = list.getAttachment(null); @@ -800,9 +798,9 @@ public Collection completionErroneousPrograms(int cursorPosition, final String languageName = language.belongsTo().name(); final Collection completions = Lists.newLinkedList(); final Collection proposalsTerm = Lists.newLinkedList(); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(ILanguageComponent component : language.components()) { - final ITermFactory termFactory = termFactoryService.get(component, null); for(IStrategoTerm completionTerm : completionTerms) { IStrategoTerm completionAst = completionParseResult.ast(); final IStrategoTerm topMostAmb = findTopMostAmbNode(completionTerm); @@ -1168,9 +1166,9 @@ public Collection completionErroneousProgramsNested(int c final String languageName = language.belongsTo().name(); final Collection completions = Lists.newLinkedList(); IStrategoTerm completionAst = completionParseResult.ast(); + final ITermFactory termFactory = termFactoryService.getGeneric(); for(ILanguageComponent component : language.components()) { - final ITermFactory termFactory = termFactoryService.get(component, null); for(IStrategoTerm nestedCompletionTerm : nestedCompletionTerms) { final HybridInterpreter runtime = strategoRuntimeService.runtime(component, location); diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/context/IndexTaskContext.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/context/IndexTaskContext.java index b88367352..4453fcc0e 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/context/IndexTaskContext.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/context/IndexTaskContext.java @@ -47,7 +47,7 @@ public class IndexTaskContext implements IContext, IContextInternal, IIndexTaskC public IndexTaskContext(Injector injector, ITermFactoryService termFactoryService, ContextIdentifier identifier) { this.injector = injector; - this.termFactory = termFactoryService.get(identifier.language, null); + this.termFactory = termFactoryService.getGeneric(); this.lock = new ReentrantReadWriteLock(true); this.persistentIdentifier = FileUtils.sanitize(identifier.language.id().toString()); this.identifier = identifier; diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/shell/StatixGenerator.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/shell/StatixGenerator.java index cc14e597a..051496baa 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/shell/StatixGenerator.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/shell/StatixGenerator.java @@ -111,7 +111,7 @@ private Tuple2 loadSpec(FileObject resource) throws MetaborgE } final StrategoTerms strategoTerms = - new StrategoTerms(S.termFactoryService.get(statixLang, context.project())); + new StrategoTerms(S.termFactoryService.getGeneric()); final IConstraint constraint = StatixTerms.constraint().match(strategoTerms.fromStratego(evalPair.getSubterm(0))) .orElseThrow(() -> new MetaborgException("Expected constraint")); @@ -136,7 +136,7 @@ public static TermFormatter pretty(Spoofax S, IContext context, String strategy) final ITermFactory tf; final HybridInterpreter runtime; try { - tf = S.termFactoryService.get(lc, context.project()); + tf = S.termFactoryService.getGeneric(); runtime = S.strategoRuntimeService.runtime(lc, context); } catch(MetaborgException e) { throw new MetaborgRuntimeException(e); diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/stratego/StrategoRuntimeService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/stratego/StrategoRuntimeService.java index 470f3639f..64fefed91 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/stratego/StrategoRuntimeService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/stratego/StrategoRuntimeService.java @@ -42,7 +42,6 @@ public class StrategoRuntimeService implements IStrategoRuntimeService, AutoClos private final ITermFactoryService termFactoryService; private final Set strategoLibraries; private final ParseStrategoFileStrategy parseStrategoFileStrategy; - private final IProjectService projectService; private final Set additionalClassLoaders; private final Map prototypes = new HashMap<>(); @@ -50,12 +49,11 @@ public class StrategoRuntimeService implements IStrategoRuntimeService, AutoClos @Inject public StrategoRuntimeService(IResourceService resourceService, ITermFactoryService termFactoryService, Set strategoLibraries, ParseStrategoFileStrategy parseStrategoFileStrategy, - IProjectService projectService, Set additionalClassLoaders) { + Set additionalClassLoaders) { this.resourceService = resourceService; this.termFactoryService = termFactoryService; this.strategoLibraries = strategoLibraries; this.parseStrategoFileStrategy = parseStrategoFileStrategy; - this.projectService = projectService; this.additionalClassLoaders = additionalClassLoaders; } @@ -78,7 +76,7 @@ public class StrategoRuntimeService implements IStrategoRuntimeService, AutoClos prototype = createPrototype(component); } - final HybridInterpreter runtime = clone(prototype, context.location(), component, context.project()); + final HybridInterpreter runtime = clone(prototype, context.location(), component); runtime.getContext().setContextObject(context); runtime.getCompiledContext().setContextObject(context); return runtime; @@ -91,8 +89,7 @@ public class StrategoRuntimeService implements IStrategoRuntimeService, AutoClos prototype = createPrototype(component); } - final IProject project = projectService.get(location); - final HybridInterpreter runtime = clone(prototype, location, component, project); + final HybridInterpreter runtime = clone(prototype, location, component); return runtime; } @@ -122,7 +119,7 @@ public class StrategoRuntimeService implements IStrategoRuntimeService, AutoClos private HybridInterpreter clone(HybridInterpreter prototype, FileObject workingLocation, - ILanguageComponent component, @Nullable IProject project) { + ILanguageComponent component) { // TODO: this seems to copy operator registries, but they should be recreated to isolate interpreters? final HybridInterpreter runtime = new HybridInterpreter(prototype); @@ -138,7 +135,7 @@ private HybridInterpreter clone(HybridInterpreter prototype, FileObject workingL runtime.getCompiledContext().addOperatorRegistry(library); } - final ITermFactory termFactory = termFactoryService.get(component, project); + final ITermFactory termFactory = termFactoryService.getGeneric(); runtime.getContext().setFactory(termFactory); runtime.getCompiledContext().setFactory(termFactory); @@ -165,7 +162,7 @@ private HybridInterpreter createNew(ITermFactory termFactory) { private HybridInterpreter createPrototype(ILanguageComponent component) throws MetaborgException { logger.debug("Creating prototype runtime for {}", component); - final ITermFactory termFactory = termFactoryService.get(component, null); + final ITermFactory termFactory = termFactoryService.getGeneric(); final HybridInterpreter runtime = createNew(termFactory); loadFiles(runtime, component); prototypes.put(component, runtime); diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/syntax/JSGLRParseService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/syntax/JSGLRParseService.java index 6d1454603..0b4367250 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/syntax/JSGLRParseService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/syntax/JSGLRParseService.java @@ -143,7 +143,7 @@ private JSGLRI getParser(ISpoofaxInputUnit input, JSGLRParserConfiguration pa if(!parserMap.containsKey(langImpl) || overrideImploder != null || overrideJSGLRVersion != null) { final IParserConfig config = getParserConfig(langImpl, input, parserConfig.completion, overrideJSGLRVersion, overrideImploder); - final ITermFactory termFactory = termFactoryService.get(langImpl, null); + final ITermFactory termFactory = termFactoryService.getGeneric(); final JSGLRVersion version = jsglrVersion(input, overrideJSGLRVersion); final JSGLRI parser; diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/ITermFactoryService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/ITermFactoryService.java index 132711000..c4df304ae 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/ITermFactoryService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/ITermFactoryService.java @@ -8,31 +8,9 @@ import org.spoofax.interpreter.terms.ITermFactory; /** - * Interface for retrieving term factories for languages and generic use. + * Interface for retrieving term factories for generic use. */ public interface ITermFactoryService { - /** - * Return the term factory to be used when constructing new terms for given language implementation. - * - * @param impl - * Implementation to get the term factory for. - * @param project - * The current project. - * @return Language-specific term factory. - */ - ITermFactory get(ILanguageImpl impl, @Nullable IProject project); - - /** - * Return the term factory to be used when constructing new terms for given language component. - * - * @param component - * Component to get the term factory for. - * @param project - * The current project. - * @return Language-specific term factory. - */ - ITermFactory get(ILanguageComponent component, @Nullable IProject project); - /** * Returns the generic term factory. * diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/TermFactoryService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/TermFactoryService.java index 1fdb1f7a8..743a2aedb 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/TermFactoryService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/terms/TermFactoryService.java @@ -21,14 +21,6 @@ public class TermFactoryService implements ITermFactoryService { private final ITermFactory genericFactory = new ImploderOriginTermFactory(new TermFactory()); - @Override public ITermFactory get(ILanguageImpl impl, @Nullable IProject project) { - return genericFactory; - } - - @Override public ITermFactory get(ILanguageComponent component, @Nullable IProject project) { - return genericFactory; - } - @Override public ITermFactory getGeneric() { return genericFactory; } diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/HoverService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/HoverService.java index bafc00196..2036959aa 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/HoverService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/HoverService.java @@ -84,7 +84,7 @@ public class HoverService implements ISpoofaxHoverService { final String strategy = facet.strategyName; try { - final ITermFactory termFactory = termFactoryService.get(contributor, project); + final ITermFactory termFactory = termFactoryService.getGeneric(); final HybridInterpreter interpreter; if(context == null) { interpreter = strategoRuntimeService.runtime(contributor, source); @@ -115,7 +115,7 @@ public class HoverService implements ISpoofaxHoverService { try { final IProject project = context.project(); - final ITermFactory termFactory = termFactoryService.get(facetContrib.contributor, project); + final ITermFactory termFactory = termFactoryService.getGeneric(); final HybridInterpreter interpreter = strategoRuntimeService.runtime(facetContrib.contributor, context); final Iterable inRegion = tracingService.fragments(result, new SourceRegion(offset)); diff --git a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/ResolverService.java b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/ResolverService.java index f16250c9f..4e353e1bd 100644 --- a/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/ResolverService.java +++ b/org.metaborg.spoofax.core/src/main/java/org/metaborg/spoofax/core/tracing/ResolverService.java @@ -89,7 +89,7 @@ public class ResolverService implements ISpoofaxResolverService { final String strategy = facet.strategyName; try { - final ITermFactory termFactory = termFactoryService.get(contributor, project); + final ITermFactory termFactory = termFactoryService.getGeneric(); final HybridInterpreter interpreter; if(context == null) { interpreter = strategoRuntimeService.runtime(contributor, source); @@ -120,7 +120,7 @@ public class ResolverService implements ISpoofaxResolverService { final String strategy = facet.strategyName; try { - final ITermFactory termFactory = termFactoryService.get(facetContrib.contributor, project); + final ITermFactory termFactory = termFactoryService.getGeneric(); final HybridInterpreter interpreter = strategoRuntimeService.runtime(facetContrib.contributor, context); final Iterable inRegion = tracingService.fragments(result, new SourceRegion(offset));