Commit 4a690627 authored by Lubomir Bulej's avatar Lubomir Bulej

DislClasses, ArgProcessorParser: move argument processor initialization loop into

ArgProcessorParser.
parent 0783910d
......@@ -19,6 +19,7 @@ import ch.usi.dag.disl.coderep.UnprocessedCode;
import ch.usi.dag.disl.exception.GuardException;
import ch.usi.dag.disl.exception.ParserException;
import ch.usi.dag.disl.guard.GuardHelper;
import ch.usi.dag.disl.localvar.LocalVars;
import ch.usi.dag.disl.processor.ArgProcessor;
import ch.usi.dag.disl.processor.ArgProcessorKind;
import ch.usi.dag.disl.processor.ArgProcessorMethod;
......@@ -35,7 +36,10 @@ class ArgProcessorParser extends AbstractParser {
private final Map <Type, ArgProcessor> __processors = new HashMap <> ();
public Map <Type, ArgProcessor> getProcessors () {
public Map <Type, ArgProcessor> initProcessors (final LocalVars localVars) {
__processors.values ().stream ().unordered ()
.forEach (processor -> processor.init (localVars));
return __processors;
}
......
package ch.usi.dag.disl.classparser;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -81,10 +82,7 @@ public final class DislClasses {
sp.getAllLocalVars (), app.getAllLocalVars ()
);
// TODO LB: Move the loop to the ArgProcessorParser class
for (final ArgProcessor processor : app.getProcessors ().values()) {
processor.init (localVars);
}
final Map <Type, ArgProcessor> processors = app.initProcessors (localVars);
// TODO LB: Consider whether we need to create the argument processor
// invocation map now -- we basically discard the argument processors
......@@ -92,7 +90,7 @@ public final class DislClasses {
// TODO LB: Move the loop to the SnippetParser class
for (final Snippet snippet : sp.getSnippets ()) {
snippet.init (localVars, app.getProcessors (), options);
snippet.init (localVars, processors, options);
}
return new DislClasses (sp);
......@@ -144,4 +142,11 @@ public final class DislClasses {
return __snippetParser.getSnippets ();
}
public List <Snippet> selectMatchingSnippets (
final String className, final String methodName, final String methodDesc
) {
return __snippetParser.getSnippets ().stream ().unordered ()
.filter (s -> s.getScope ().matches (className, methodName, methodDesc))
.collect (Collectors.toList ());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment