From 9c0b5edc2776d8ac1ed7a37ffe6a05c70c7e2092 Mon Sep 17 00:00:00 2001 From: Balletie Date: Tue, 14 Jun 2016 23:14:24 +0200 Subject: [PATCH 1/4] Add error highlighting of failed results. Adds back IDisplay, which contains default implementations. TerminalUI and EclipseDisplay are now IDisplays again. Extended StyledText to be able to add style to multiple sourceregions at once. Tested too. --- .../console/impl/TerminalUserInterface.java | 27 ++----- .../spoofax/shell/client/IDisplay.java | 79 +++++++++++++++++++ .../spoofax/shell/output/StyledText.java | 45 ++++++++++- .../spoofax/shell/output/StyledTextTest.java | 60 ++++++++++++++ .../client/eclipse/impl/EclipseDisplay.java | 35 +------- 5 files changed, 192 insertions(+), 54 deletions(-) create mode 100644 org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java diff --git a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/TerminalUserInterface.java b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/TerminalUserInterface.java index 59c5c301..24c9be8a 100644 --- a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/TerminalUserInterface.java +++ b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/TerminalUserInterface.java @@ -17,10 +17,8 @@ import org.fusesource.jansi.Ansi; import org.metaborg.core.style.IStyle; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.client.IInputHistory; -import org.metaborg.spoofax.shell.client.IResultVisitor; -import org.metaborg.spoofax.shell.output.FailResult; -import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.StyledText; import com.google.inject.Inject; @@ -29,10 +27,10 @@ import jline.console.ConsoleReader; /** - * A terminal UI, offering a way of entering input and implementing {@link IResultVisitor} to + * A terminal UI, offering a way of entering input and implementing {@link IDisplay} to * display results. */ -public class TerminalUserInterface implements IResultVisitor { +public class TerminalUserInterface implements IDisplay { private final ConsoleReader reader; private final ArrayList lines; private final PrintWriter out; @@ -142,26 +140,11 @@ public IInputHistory history() { } @Override - public void visitResult(ISpoofaxResult result) { - visitMessage(result.styled()); - } - - @Override - public void visitMessage(StyledText message) { - out.println(ansi(message)); + public void displayStyledText(StyledText text) { + out.println(ansi(text)); out.flush(); } - @Override - public void visitFailure(FailResult errorResult) { - visitMessage(errorResult.getCause().styled()); - } - - @Override - public void visitException(Throwable thrown) { - visitMessage(new StyledText(Color.RED, thrown.getMessage())); - } - private void optional(T t, Function check, Consumer accept) { if (check.apply(t)) { accept.accept(t); diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java new file mode 100644 index 00000000..46a7e506 --- /dev/null +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java @@ -0,0 +1,79 @@ +package org.metaborg.spoofax.shell.client; + +import java.awt.Color; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.metaborg.core.messages.IMessage; +import org.metaborg.core.source.ISourceRegion; +import org.metaborg.core.source.SourceRegion; +import org.metaborg.core.style.IStyle; +import org.metaborg.core.style.Style; +import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.ISpoofaxResult; +import org.metaborg.spoofax.shell.output.StyledText; + +/** + * Adapter {@link IResultVisitor} interface for displaying results and errors. An implementation of + * {@link IDisplay} knows how to interpret the style information of a {@link StyledText} and display + * it appropriately. + */ +public interface IDisplay extends IResultVisitor { + + /** + * Display the given {@link StyledText}. How the style information is interpreted depends on the + * client. + * + * @param text + * The {@link StyledText} to display. + */ + void displayStyledText(StyledText text); + + @Override + default void visitMessage(StyledText message) { + displayStyledText(message); + } + + @Override + default void visitResult(ISpoofaxResult result) { + visitMessage(result.styled()); + } + + @Override + default void visitFailure(FailResult errorResult) { + ISpoofaxResult cause = errorResult.getCause(); + String sourceText = cause.sourceText(); + List messages = cause.messages(); + StyledText styled = highlightMessagesInSource(sourceText, messages); + + String concat = + messages.stream().map(message -> message.message()).collect(Collectors.joining("\n")); + visitMessage(styled.append("\n").append(Color.RED, concat)); + } + + /** + * Highlights the {@link SourceRegion}s of the given {@link IMessage}s in the given source text + * with a red color and bold style. + * + * @param sourceText + * The source text that caused the failure. + * @param messages + * The error messages. + * @return The highlighted {@link StyledText} + */ + default StyledText highlightMessagesInSource(String sourceText, List messages) { + List regions = messages.stream().map(message -> message.region()) + .filter(Objects::nonNull).collect(Collectors.toList()); + StyledText styled = new StyledText(); + IStyle style = new Style(Color.RED, null, true, false, false); + styled.append(regions, style, sourceText); + return styled; + } + + @Override + default void visitException(Throwable thrown) { + visitMessage(new StyledText(Color.RED, thrown.getMessage())); + } + +} diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/StyledText.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/StyledText.java index ed279a08..39259347 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/StyledText.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/StyledText.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; +import java.util.stream.StreamSupport; import org.metaborg.core.source.ISourceRegion; import org.metaborg.core.source.SourceRegion; @@ -13,6 +14,9 @@ import org.metaborg.core.style.Style; import com.google.common.collect.Lists; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; +import com.google.common.collect.TreeRangeSet; /** * Represents a styled text containing several styled strings, each represented by an @@ -67,6 +71,13 @@ public StyledText(Iterable> sourceRegions) { this.source = Lists.newArrayList(sourceRegions); } + /** + * Create an empty {@link StyledText}. + */ + public StyledText() { + this.source = Lists.newArrayList(); + } + /** * Return all the styled strings in this text. * @@ -114,6 +125,38 @@ public StyledText append(IStyle style, String text) { return this.append(new SourceRegion(start, start + text.length() - 1), style, text); } + /** + * Append a string with multiple regions and a style to this styled text. All of the regions in + * the given text will be styled with the given style, the rest of the text will have no style. + * Internally, the given regions will be sorted. + * + * @param regions + * The regions to style. + * @param style + * The style to apply. + * @param text + * The unstyled text. + * @return The styled text. + */ + public StyledText append(Iterable regions, IStyle style, String text) { + RangeSet rangeSet = TreeRangeSet.create(); + StreamSupport.stream(regions.spliterator(), false) + .map(r -> Range.closed(r.startOffset(), r.endOffset())).forEach(rangeSet::add); + List> sortedRanges = rangeSet.asRanges().stream() + .sorted((a, b) -> a.lowerEndpoint() - b.lowerEndpoint()).collect(Collectors.toList()); + int curOffset = 0; + for (Range r : sortedRanges) { + String sub = text.substring(curOffset, r.lowerEndpoint()); + this.append(sub); + String errorRegion = text.substring(r.lowerEndpoint(), r.upperEndpoint() + 1); + this.append(style, errorRegion); + curOffset = r.upperEndpoint() + 1; + } + // Add the rest. + this.append(text.substring(curOffset)); + return this; + } + /** * Append a string with a region and a style to this styled text. * @@ -125,7 +168,7 @@ public StyledText append(IStyle style, String text) { * The unstyled text. * @return The styled text. */ - private StyledText append(ISourceRegion region, IStyle style, String text) { + public StyledText append(ISourceRegion region, IStyle style, String text) { this.source.add(new RegionStyle<>(region, style, text)); return this; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/output/StyledTextTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/output/StyledTextTest.java index 8ba71b4f..90581b75 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/output/StyledTextTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/output/StyledTextTest.java @@ -5,9 +5,12 @@ import static org.junit.Assert.assertNull; import java.awt.Color; +import java.util.Arrays; import java.util.List; import org.junit.Test; +import org.metaborg.core.source.ISourceRegion; +import org.metaborg.core.source.SourceRegion; import org.metaborg.core.style.IRegionStyle; import org.metaborg.core.style.RegionStyle; import org.metaborg.core.style.Style; @@ -17,6 +20,18 @@ */ public class StyledTextTest { + /** + * Test an empty {@link StyledText}. + */ + @Test + public void testEmpty() { + StyledText styledText = new StyledText(); + List> source = styledText.getSource(); + + assertEquals("", styledText.toString()); + assertEquals(0, source.size()); + } + /** * Test a string with no style. */ @@ -74,4 +89,49 @@ public void testStyledString() { assertEquals(style1, styledText.getSource().get(0).style()); assertEquals(style2, styledText.getSource().get(1).style()); } + + /** + * Test a string that was styled with multiple regions that don't overlap. + */ + @Test + public void testMultipleRegionsStyledNonOverlapping() { + final int numRegions = 5; + final int start1 = 2; + final int end1 = 5; + final int start2 = 7; + final int end2 = 9; + List regions = + Arrays.asList(new SourceRegion(start1, end1), new SourceRegion(start2, end2)); + Style style = new Style(Color.BLUE, Color.CYAN, false, false, false); + + StyledText styledText = new StyledText().append(regions, style, "Hello, world"); + + List> source = styledText.getSource(); + assertEquals(numRegions, source.size()); + assertEquals("llo,", source.get(1).fragment()); + assertEquals("wor", source.get(numRegions - 2).fragment()); + assertEquals("Hello, world", styledText.toString()); + } + + /** + * Test a string that was styled with multiple regions that overlap. + */ + @Test + public void testMultipleRegionsStyledOverlapping() { + final int numRegions = 3; + final int start1 = 2; + final int end1 = 5; + final int start2 = 4; + final int end2 = 9; + List regions = + Arrays.asList(new SourceRegion(start1, end1), new SourceRegion(start2, end2)); + Style style = new Style(Color.BLUE, Color.CYAN, false, false, false); + + StyledText styledText = new StyledText().append(regions, style, "Hello, world"); + + List> source = styledText.getSource(); + assertEquals(numRegions, source.size()); + assertEquals("llo, wor", source.get(1).fragment()); + assertEquals("Hello, world", styledText.toString()); + } } diff --git a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java index 6ff78d40..af09c405 100644 --- a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java +++ b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java @@ -13,10 +13,9 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.metaborg.core.style.IStyle; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.client.eclipse.ColorManager; -import org.metaborg.spoofax.shell.output.FailResult; -import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.StyledText; import com.google.inject.assistedinject.Assisted; @@ -28,7 +27,7 @@ * * Note that this class should always be run in and accessed from the UI thread! */ -public class EclipseDisplay implements IResultVisitor { +public class EclipseDisplay implements IDisplay { private final ITextViewer output; private final ColorManager colorManager; @@ -103,26 +102,10 @@ private RGB awtToRGB(Color awt) { } @Override - public void visitResult(ISpoofaxResult result) { - // TODO: use the information in the result to print better error messages. + public void displayStyledText(StyledText text) { IDocument doc = getDocument(); - result.styled().getSource().forEach(e -> { - int offset = doc.getLength(); - - append(doc, offset, e.fragment()); - style(e.style(), offset, e.region().length()); - }); - - append(doc, doc.getLength(), "\n"); - scrollText(); - } - - @Override - public void visitMessage(StyledText message) { - IDocument doc = getDocument(); - - message.getSource().forEach(e -> { + text.getSource().forEach(e -> { int offset = doc.getLength(); append(doc, offset, e.fragment()); @@ -134,14 +117,4 @@ public void visitMessage(StyledText message) { append(doc, doc.getLength(), "\n"); scrollText(); } - - @Override - public void visitFailure(FailResult errorResult) { - visitMessage(errorResult.getCause().styled()); - } - - @Override - public void visitException(Throwable thrown) { - visitMessage(new StyledText(Color.RED, thrown.getMessage())); - } } From f16389a773e703c22f5236eb2817ab068c869098 Mon Sep 17 00:00:00 2001 From: Balletie Date: Tue, 14 Jun 2016 23:40:09 +0200 Subject: [PATCH 2/4] Use IDisplay instead of IResultVisitor where appropriate --- .../shell/client/ConsoleReplModule.java | 2 +- .../spoofax/shell/client/console/Main.java | 6 ++-- .../client/console/impl/ConsoleRepl.java | 19 ++++++------- .../shell/client/console/impl/MockModule.java | 28 +++++++++---------- .../metaborg/spoofax/shell/ReplModule.java | 3 +- .../client/eclipse/impl/EclipseDisplay.java | 3 +- .../client/eclipse/impl/EclipseRepl.java | 17 ++++++----- .../client/eclipse/impl/IWidgetFactory.java | 8 +++--- 8 files changed, 42 insertions(+), 44 deletions(-) diff --git a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/ConsoleReplModule.java b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/ConsoleReplModule.java index 996c2e0c..68729e4d 100644 --- a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/ConsoleReplModule.java +++ b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/ConsoleReplModule.java @@ -39,7 +39,7 @@ protected void bindUserInterface() { bind(JLine2InputHistory.class).to(JLine2PersistentInputHistory.class); bind(TerminalUserInterface.class).in(Singleton.class); - bind(IResultVisitor.class).to(TerminalUserInterface.class); + bind(IDisplay.class).to(TerminalUserInterface.class); bind(InputStream.class).annotatedWith(Names.named("in")).toInstance(System.in); bind(OutputStream.class).annotatedWith(Names.named("out")).toInstance(System.out); diff --git a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/Main.java b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/Main.java index a4a9a532..5c066f2a 100644 --- a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/Main.java +++ b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/Main.java @@ -4,7 +4,7 @@ import org.metaborg.core.style.Style; import org.metaborg.spoofax.shell.client.ConsoleReplModule; -import org.metaborg.spoofax.shell.client.IResultVisitor; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.client.console.impl.ConsoleRepl; import org.metaborg.spoofax.shell.output.StyledText; @@ -29,12 +29,12 @@ private Main() { // TODO: make the argument work again. public static void main(String[] args) { Injector injector = Guice.createInjector(new ConsoleReplModule()); - IResultVisitor visitor = injector.getInstance(IResultVisitor.class); + IDisplay display = injector.getInstance(IDisplay.class); StyledText message = new StyledText(Color.BLUE, "Welcome to the ") .append(new Style(Color.GREEN, Color.BLUE, true, true, true), "Spoofax") .append(Color.BLUE, " REPL"); - visitor.visitMessage(message); + display.displayStyledText(message); ConsoleRepl repl = injector.getInstance(ConsoleRepl.class); repl.run(); diff --git a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/ConsoleRepl.java b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/ConsoleRepl.java index f38c49a1..57ef8c97 100644 --- a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/ConsoleRepl.java +++ b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/impl/ConsoleRepl.java @@ -3,8 +3,8 @@ import java.awt.Color; import java.io.IOException; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.client.IRepl; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.StyledText; @@ -20,7 +20,7 @@ public class ConsoleRepl implements IRepl { private final ICommandInvoker invoker; private final TerminalUserInterface iface; - private final IResultVisitor visitor; + private final IDisplay display; private boolean running; /** @@ -28,17 +28,16 @@ public class ConsoleRepl implements IRepl { * * @param iface * The {@link TerminalUserInterface} to retrieve user input from. - * @param visitor - * The {@link IResultVisitor} for visiting the results. + * @param display + * The {@link IDisplay} for displaying the results. * @param invoker * The {@link ICommandInvoker} for executing user input. */ @Inject - public ConsoleRepl(TerminalUserInterface iface, IResultVisitor visitor, - ICommandInvoker invoker) { + public ConsoleRepl(TerminalUserInterface iface, IDisplay display, ICommandInvoker invoker) { this.invoker = invoker; this.iface = iface; - this.visitor = visitor; + this.display = display; } /** @@ -67,15 +66,15 @@ public void run() { setRunning(true); while (running && (input = this.iface.getInput()) != null) { try { - eval(input).accept(visitor); + eval(input).accept(display); } catch (CommandNotFoundException e) { - this.visitor.visitMessage(new StyledText(Color.RED, e.getMessage())); + this.display.displayStyledText(new StyledText(Color.RED, e.getMessage())); } } this.iface.history().persistToDisk(); } catch (IOException e) { - this.visitor.visitMessage(new StyledText(Color.RED, e.getMessage())); + this.display.displayStyledText(new StyledText(Color.RED, e.getMessage())); } } diff --git a/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/impl/MockModule.java b/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/impl/MockModule.java index 811c10fa..eca429a3 100644 --- a/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/impl/MockModule.java +++ b/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/impl/MockModule.java @@ -1,6 +1,6 @@ package org.metaborg.spoofax.shell.client.console.impl; -import org.metaborg.spoofax.shell.client.IResultVisitor; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import com.google.inject.AbstractModule; @@ -11,11 +11,11 @@ public class MockModule extends AbstractModule { private final ICommandInvoker invokerMock; private final TerminalUserInterface ifaceMock; - private final IResultVisitor visitorMock; + private final IDisplay displayMock; /** * Instantiates a new MockModule with a {@code null} @{link TerminalUserInterface} and a - * {@code null} {@link IResultVisitor}. + * {@code null} {@link IDisplay}. * * @param invokerMock * The mock {@link ICommandInvoker}. @@ -25,7 +25,7 @@ public MockModule(ICommandInvoker invokerMock) { } /** - * Instantiates a new MockModule with a {@code null} {@link IResultVisitor}. + * Instantiates a new MockModule with a {@code null} {@link IDisplay}. * * @param invokerMock * The mock {@link ICommandInvoker}. @@ -41,11 +41,11 @@ public MockModule(ICommandInvoker invokerMock, TerminalUserInterface ifaceMock) * * @param ifaceMock * The mock {@link TerminalUserInterface}. - * @param visitorMock - * The mock {@link IResultVisitor}. + * @param displayMock + * The mock {@link IDisplay}. */ - public MockModule(TerminalUserInterface ifaceMock, IResultVisitor visitorMock) { - this(null, ifaceMock, visitorMock); + public MockModule(TerminalUserInterface ifaceMock, IDisplay displayMock) { + this(null, ifaceMock, displayMock); } /** @@ -55,14 +55,14 @@ public MockModule(TerminalUserInterface ifaceMock, IResultVisitor visitorMock) { * The mock {@link ICommandInvoker}. * @param ifaceMock * The mock {@link TerminalUserInterface}. - * @param visitorMock - * The mock {@link IResultVisitor}. + * @param displayMock + * The mock {@link IDisplay}. */ public MockModule(ICommandInvoker invokerMock, TerminalUserInterface ifaceMock, - IResultVisitor visitorMock) { + IDisplay displayMock) { this.invokerMock = invokerMock; this.ifaceMock = ifaceMock; - this.visitorMock = visitorMock; + this.displayMock = displayMock; } @Override @@ -73,8 +73,8 @@ protected void configure() { if (ifaceMock != null) { bind(TerminalUserInterface.class).toInstance(ifaceMock); } - if (visitorMock != null) { - bind(IResultVisitor.class).toInstance(visitorMock); + if (displayMock != null) { + bind(IDisplay.class).toInstance(displayMock); } } } diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java index 46db9c94..28562eec 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java @@ -47,7 +47,8 @@ /** * This class binds the core classes. It is intended to be subclassed by client implementations. - * These subclasses should bind their implementations of {@link IRepl} and {@link IResultVisitor}. + * These subclasses should bind their implementations of {@link IRepl} and either + * {@link IResultVisitor} or {@link IDisplay} (which is also an {@link IResultVisitor}). */ public abstract class ReplModule extends SpoofaxModule { diff --git a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java index af09c405..b3c82d0b 100644 --- a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java +++ b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseDisplay.java @@ -14,7 +14,6 @@ import org.eclipse.swt.widgets.Composite; import org.metaborg.core.style.IStyle; import org.metaborg.spoofax.shell.client.IDisplay; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.client.eclipse.ColorManager; import org.metaborg.spoofax.shell.output.StyledText; @@ -22,7 +21,7 @@ import com.google.inject.assistedinject.AssistedInject; /** - * An Eclipse-based {@link IResultVisitor}, which uses a {@link TextViewer} to display results and + * An Eclipse-based {@link IDisplay}, which uses a {@link TextViewer} to display results and * error messages. * * Note that this class should always be run in and accessed from the UI thread! diff --git a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java index 922ee4ce..8cec0ef9 100644 --- a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java +++ b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java @@ -10,7 +10,7 @@ import org.metaborg.core.style.Style; import org.metaborg.spoofax.shell.client.IRepl; import org.metaborg.spoofax.shell.client.IResult; -import org.metaborg.spoofax.shell.client.IResultVisitor; +import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.StyledText; @@ -32,7 +32,7 @@ public class EclipseRepl implements IRepl, Observer { private static final int INPUT_RED = 232; private static final int INPUT_GREEN = 242; private static final int INPUT_BLUE = 254; - private final IResultVisitor visitor; + private final IDisplay display; private final ICommandInvoker invoker; /** @@ -40,12 +40,12 @@ public class EclipseRepl implements IRepl, Observer { * * @param invoker * The {@link ICommandInvoker} for executing user input. - * @param visitor - * The {@link EclipseDisplay} to send results to. + * @param display + * The {@link IDisplay} to send results to. */ @AssistedInject - public EclipseRepl(ICommandInvoker invoker, @Assisted IResultVisitor visitor) { - this.visitor = visitor; + public EclipseRepl(ICommandInvoker invoker, @Assisted IDisplay display) { + this.display = display; this.invoker = invoker; } @@ -81,8 +81,7 @@ private void appendInputToDisplay(String input) { // highlighted. Color inputBackgroundColor = new Color(INPUT_RED, INPUT_GREEN, INPUT_BLUE); Style style = new Style(null, inputBackgroundColor, false, false, false); - // FIXME: Input is not really a "message"... - this.visitor.visitMessage(new StyledText(style, input)); + this.display.displayStyledText(new StyledText(style, input)); } private void runAsJob(final String input) { @@ -107,7 +106,7 @@ private void runAsUIJob(IResult result) { Job job = new UIJob("Spoofax REPL display job") { @Override public IStatus runInUIThread(IProgressMonitor arg0) { - result.accept(visitor); + result.accept(display); return Status.OK_STATUS; } }; diff --git a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/IWidgetFactory.java b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/IWidgetFactory.java index 1c676b6b..e11b3eea 100644 --- a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/IWidgetFactory.java +++ b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/IWidgetFactory.java @@ -1,7 +1,7 @@ package org.metaborg.spoofax.shell.client.eclipse.impl; import org.eclipse.swt.widgets.Composite; -import org.metaborg.spoofax.shell.client.IResultVisitor; +import org.metaborg.spoofax.shell.client.IDisplay; /** * An interface for Guice's {@link com.google.inject.assistedinject.FactoryModuleBuilder}. @@ -31,10 +31,10 @@ public interface IWidgetFactory { /** * Instantiate a new {@link EclipseRepl}. * - * @param visitor - * The {@link IResultVisitor} to visit results with. + * @param display + * The {@link IDisplay} for displaying results. * @return The created {@link EclipseRepl}. */ - EclipseRepl createRepl(IResultVisitor visitor); + EclipseRepl createRepl(IDisplay display); } From 5f291e3e7574f14ecd2cb899a6ffe46e82a808b6 Mon Sep 17 00:00:00 2001 From: Gerlof Fokkema Date: Fri, 17 Jun 2016 19:56:24 +0200 Subject: [PATCH 3/4] Move result class from client to output package. --- .../spoofax/shell/client/console/commands/ExitCommand.java | 2 +- .../src/main/java/org/metaborg/spoofax/shell/ReplModule.java | 2 +- .../src/main/java/org/metaborg/spoofax/shell/client/IRepl.java | 1 + .../org/metaborg/spoofax/shell/commands/CommandBuilder.java | 2 +- .../java/org/metaborg/spoofax/shell/commands/HelpCommand.java | 2 +- .../java/org/metaborg/spoofax/shell/commands/IReplCommand.java | 2 +- .../org/metaborg/spoofax/shell/commands/LanguageCommand.java | 2 +- .../org/metaborg/spoofax/shell/functions/AEvalFunction.java | 2 +- .../metaborg/spoofax/shell/functions/ATransformFunction.java | 2 +- .../spoofax/shell/functions/AbstractSpoofaxFunction.java | 2 +- .../org/metaborg/spoofax/shell/functions/AnalyzeFunction.java | 2 +- .../spoofax/shell/functions/ContextualSpoofaxFunction.java | 2 +- .../org/metaborg/spoofax/shell/functions/FailableFunction.java | 2 +- .../org/metaborg/spoofax/shell/functions/IFunctionFactory.java | 2 +- .../org/metaborg/spoofax/shell/functions/InputFunction.java | 2 +- .../org/metaborg/spoofax/shell/functions/PEvalFunction.java | 2 +- .../metaborg/spoofax/shell/functions/PTransformFunction.java | 2 +- .../org/metaborg/spoofax/shell/functions/ParseFunction.java | 2 +- .../org/metaborg/spoofax/shell/invoker/ICommandInvoker.java | 2 +- .../org/metaborg/spoofax/shell/output/ExceptionResult.java | 1 - .../org/metaborg/spoofax/shell/output/FailOrSuccessResult.java | 1 - .../java/org/metaborg/spoofax/shell/output/FailResult.java | 1 - .../org/metaborg/spoofax/shell/{client => output}/IResult.java | 3 ++- .../java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java | 1 - .../metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java | 2 +- .../metaborg/spoofax/shell/functions/EvaluateFunctionTest.java | 2 +- .../metaborg/spoofax/shell/functions/InputFunctionTest.java | 2 +- .../metaborg/spoofax/shell/functions/ParseFunctionTest.java | 2 +- .../spoofax/shell/functions/TransformFunctionTest.java | 2 +- .../spoofax/shell/client/eclipse/impl/EclipseRepl.java | 2 +- 30 files changed, 27 insertions(+), 29 deletions(-) rename org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/{client => output}/IResult.java (83%) diff --git a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommand.java b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommand.java index 9591525c..d04e4b31 100644 --- a/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommand.java +++ b/org.metaborg.spoofax.shell.console/src/main/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommand.java @@ -1,8 +1,8 @@ package org.metaborg.spoofax.shell.client.console.commands; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.console.impl.ConsoleRepl; import org.metaborg.spoofax.shell.commands.IReplCommand; +import org.metaborg.spoofax.shell.output.IResult; import com.google.inject.Inject; import com.google.inject.Provider; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java index 28562eec..59350cce 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java @@ -10,7 +10,6 @@ import org.metaborg.core.resource.ResourceService; import org.metaborg.spoofax.core.SpoofaxModule; import org.metaborg.spoofax.shell.client.IRepl; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.HelpCommand; import org.metaborg.spoofax.shell.commands.IReplCommand; @@ -32,6 +31,7 @@ import org.metaborg.spoofax.shell.invoker.SpoofaxCommandInvoker; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.EvaluateResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java index e57a076c..bc201c7a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java @@ -3,6 +3,7 @@ import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; +import org.metaborg.spoofax.shell.output.IResult; /** * This interface defines the evaluation part of a REPL (Read-Eval-Print-Loop). The reason for only diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/CommandBuilder.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/CommandBuilder.java index 82467ba2..d1683378 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/CommandBuilder.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/CommandBuilder.java @@ -7,12 +7,12 @@ import org.metaborg.core.action.ITransformAction; import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.functions.FailableFunction; import org.metaborg.spoofax.shell.functions.IFunctionFactory; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.EvaluateResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/HelpCommand.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/HelpCommand.java index 57ae717e..9ad66bd0 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/HelpCommand.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/HelpCommand.java @@ -5,10 +5,10 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.ExceptionResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.StyledText; import com.google.inject.Inject; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java index e338c2ce..a16fd979 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java @@ -1,8 +1,8 @@ package org.metaborg.spoofax.shell.commands; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; +import org.metaborg.spoofax.shell.output.IResult; /** * Interface for REPL commands. Used together with {@link ICommandInvoker}, instances of diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/LanguageCommand.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/LanguageCommand.java index 74b38607..9104e405 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/LanguageCommand.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/LanguageCommand.java @@ -15,11 +15,11 @@ import org.metaborg.core.menu.IMenuService; import org.metaborg.core.project.IProject; import org.metaborg.core.resource.IResourceService; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.functions.IFunctionFactory; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.ExceptionResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.StyledText; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AEvalFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AEvalFunction.java index 5aa2fee5..841c2eb2 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AEvalFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AEvalFunction.java @@ -7,11 +7,11 @@ import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; import org.metaborg.spoofax.core.shell.ShellFacet; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.core.IEvaluationStrategy; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.EvaluateResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.spoofax.interpreter.terms.IStrategoTerm; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ATransformFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ATransformFunction.java index 542a7da5..69f3a51a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ATransformFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ATransformFunction.java @@ -10,9 +10,9 @@ import org.metaborg.spoofax.core.transform.ISpoofaxTransformService; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; import org.metaborg.spoofax.core.unit.ISpoofaxTransformUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AbstractSpoofaxFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AbstractSpoofaxFunction.java index ba9a5fda..7b8c9f20 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AbstractSpoofaxFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AbstractSpoofaxFunction.java @@ -2,9 +2,9 @@ import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.ExceptionResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AnalyzeFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AnalyzeFunction.java index d2bcbd07..da8bc35f 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AnalyzeFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/AnalyzeFunction.java @@ -7,9 +7,9 @@ import org.metaborg.core.project.IProject; import org.metaborg.spoofax.core.analysis.ISpoofaxAnalysisService; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ParseResult; import org.metaborg.util.concurrent.IClosableLock; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ContextualSpoofaxFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ContextualSpoofaxFunction.java index e28395bc..43cade6a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ContextualSpoofaxFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ContextualSpoofaxFunction.java @@ -6,8 +6,8 @@ import org.metaborg.core.context.IContextService; import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/FailableFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/FailableFunction.java index 0b6e2b87..455f8fd9 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/FailableFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/FailableFunction.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.function.Function; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; /** * A {@link java.util.Function} that may result in a failure. This is our domain-specific equivalent diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/IFunctionFactory.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/IFunctionFactory.java index e35c43a7..cddcada0 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/IFunctionFactory.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/IFunctionFactory.java @@ -3,11 +3,11 @@ import org.metaborg.core.action.ITransformAction; import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.EvaluateResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/InputFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/InputFunction.java index 20181777..96c8342a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/InputFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/InputFunction.java @@ -6,8 +6,8 @@ import org.metaborg.core.project.IProject; import org.metaborg.spoofax.core.shell.ShellFacet; import org.metaborg.spoofax.core.syntax.JSGLRParserConfiguration; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PEvalFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PEvalFunction.java index 784c30f1..ce1cceb1 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PEvalFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PEvalFunction.java @@ -7,10 +7,10 @@ import org.metaborg.core.language.ILanguageImpl; import org.metaborg.core.project.IProject; import org.metaborg.spoofax.core.shell.ShellFacet; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.core.IEvaluationStrategy; import org.metaborg.spoofax.shell.output.EvaluateResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ParseResult; import org.spoofax.interpreter.terms.IStrategoTerm; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PTransformFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PTransformFunction.java index b1d06b76..c6e406d5 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PTransformFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PTransformFunction.java @@ -10,8 +10,8 @@ import org.metaborg.spoofax.core.transform.ISpoofaxTransformService; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxTransformUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ParseResult; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ParseFunction.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ParseFunction.java index db612fab..506800c6 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ParseFunction.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/ParseFunction.java @@ -8,8 +8,8 @@ import org.metaborg.spoofax.core.unit.ISpoofaxInputUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxUnitService; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java index 5115d121..456a9e7c 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java @@ -3,9 +3,9 @@ import java.util.Arrays; import java.util.Map; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.IReplCommand; +import org.metaborg.spoofax.shell.output.IResult; /** * An interface for binding and executing {@link IReplCommand}s. diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java index ec26cb34..9bfcbb30 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java @@ -1,6 +1,5 @@ package org.metaborg.spoofax.shell.output; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; /** diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java index b8c4598b..5c04e658 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java @@ -2,7 +2,6 @@ import java.util.Objects; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.functions.FailableFunction; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java index 93f12915..4a5a7a94 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java @@ -1,6 +1,5 @@ package org.metaborg.spoofax.shell.output; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; /** diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java similarity index 83% rename from org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResult.java rename to org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java index a9188cdb..e425ad15 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java @@ -1,7 +1,8 @@ -package org.metaborg.spoofax.shell.client; +package org.metaborg.spoofax.shell.output; import java.util.function.Consumer; +import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.IReplCommand; /** diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java index 8f4d93be..e3712428 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java @@ -7,7 +7,6 @@ import org.metaborg.core.context.IContext; import org.metaborg.core.messages.IMessage; import org.metaborg.core.unit.IUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.spoofax.interpreter.terms.IStrategoTerm; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java index 649c2858..e08c912b 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java @@ -24,7 +24,6 @@ import org.metaborg.spoofax.core.analysis.ISpoofaxAnalysisService; import org.metaborg.spoofax.core.analysis.ISpoofaxAnalyzeResult; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; @@ -33,6 +32,7 @@ import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java index 09a6936c..1f376ebd 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java @@ -32,7 +32,6 @@ import org.metaborg.spoofax.core.shell.ShellFacet; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; @@ -41,6 +40,7 @@ import org.metaborg.spoofax.shell.output.EvaluateResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java index 5205e894..5a19cbe5 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java @@ -20,11 +20,11 @@ import org.metaborg.spoofax.core.unit.ISpoofaxInputUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxUnitService; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java index 84d9ac0a..6d6f30ce 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java @@ -21,12 +21,12 @@ import org.metaborg.spoofax.core.unit.ISpoofaxInputUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxUnitService; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java index 6f3c5f58..2774188d 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java @@ -35,13 +35,13 @@ import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxTransformUnit; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.AnalyzeResult; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; diff --git a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java index 8cec0ef9..c559a650 100644 --- a/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java +++ b/org.metaborg.spoofax.shell.eclipse/src/main/java/org/metaborg/spoofax/shell/client/eclipse/impl/EclipseRepl.java @@ -9,10 +9,10 @@ import org.eclipse.ui.progress.UIJob; import org.metaborg.core.style.Style; import org.metaborg.spoofax.shell.client.IRepl; -import org.metaborg.spoofax.shell.client.IResult; import org.metaborg.spoofax.shell.client.IDisplay; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; +import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.StyledText; import com.google.inject.assistedinject.Assisted; From 415a224b30753bee81dc805839ec50ca1fbe4976 Mon Sep 17 00:00:00 2001 From: Balletie Date: Fri, 17 Jun 2016 20:50:06 +0200 Subject: [PATCH 4/4] Also move IResultVisitor to output package IDisplay is now the preferred interface to be implemented by clients --- .../shell/client/console/commands/ExitCommandTest.java | 2 +- .../main/java/org/metaborg/spoofax/shell/ReplModule.java | 2 +- .../java/org/metaborg/spoofax/shell/client/IDisplay.java | 1 + .../main/java/org/metaborg/spoofax/shell/client/IRepl.java | 1 + .../org/metaborg/spoofax/shell/commands/IReplCommand.java | 2 +- .../org/metaborg/spoofax/shell/invoker/ICommandInvoker.java | 2 +- .../org/metaborg/spoofax/shell/output/ExceptionResult.java | 2 -- .../metaborg/spoofax/shell/output/FailOrSuccessResult.java | 1 - .../java/org/metaborg/spoofax/shell/output/FailResult.java | 2 -- .../java/org/metaborg/spoofax/shell/output/IResult.java | 1 - .../spoofax/shell/{client => output}/IResultVisitor.java | 6 +----- .../org/metaborg/spoofax/shell/output/ISpoofaxResult.java | 1 - .../metaborg/spoofax/shell/commands/HelpCommandTest.java | 2 +- .../spoofax/shell/commands/LanguageCommandTest.java | 2 +- .../spoofax/shell/functions/AnalyzeFunctionTest.java | 2 +- .../spoofax/shell/functions/EvaluateFunctionTest.java | 2 +- .../metaborg/spoofax/shell/functions/InputFunctionTest.java | 2 +- .../metaborg/spoofax/shell/functions/ParseFunctionTest.java | 2 +- .../spoofax/shell/functions/TransformFunctionTest.java | 2 +- 19 files changed, 14 insertions(+), 23 deletions(-) rename org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/{client => output}/IResultVisitor.java (82%) diff --git a/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommandTest.java b/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommandTest.java index b67708ee..76c561cb 100644 --- a/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommandTest.java +++ b/org.metaborg.spoofax.shell.console/src/test/java/org/metaborg/spoofax/shell/client/console/commands/ExitCommandTest.java @@ -11,8 +11,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.client.console.impl.ConsoleRepl; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java index 59350cce..7400f11a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/ReplModule.java @@ -10,7 +10,6 @@ import org.metaborg.core.resource.ResourceService; import org.metaborg.spoofax.core.SpoofaxModule; import org.metaborg.spoofax.shell.client.IRepl; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.HelpCommand; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.commands.LanguageCommand; @@ -33,6 +32,7 @@ import org.metaborg.spoofax.shell.output.EvaluateResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; import org.metaborg.spoofax.shell.output.TransformResult; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java index 46a7e506..2fd3374c 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IDisplay.java @@ -11,6 +11,7 @@ import org.metaborg.core.style.IStyle; import org.metaborg.core.style.Style; import org.metaborg.spoofax.shell.output.FailResult; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.StyledText; diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java index bc201c7a..a3f7d72a 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IRepl.java @@ -4,6 +4,7 @@ import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.IResult; +import org.metaborg.spoofax.shell.output.IResultVisitor; /** * This interface defines the evaluation part of a REPL (Read-Eval-Print-Loop). The reason for only diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java index a16fd979..0e330aa3 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/IReplCommand.java @@ -1,8 +1,8 @@ package org.metaborg.spoofax.shell.commands; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; import org.metaborg.spoofax.shell.output.IResult; +import org.metaborg.spoofax.shell.output.IResultVisitor; /** * Interface for REPL commands. Used together with {@link ICommandInvoker}, instances of diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java index 456a9e7c..288a1d7b 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/invoker/ICommandInvoker.java @@ -3,9 +3,9 @@ import java.util.Arrays; import java.util.Map; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.IResult; +import org.metaborg.spoofax.shell.output.IResultVisitor; /** * An interface for binding and executing {@link IReplCommand}s. diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java index 9bfcbb30..6f27a766 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ExceptionResult.java @@ -1,7 +1,5 @@ package org.metaborg.spoofax.shell.output; -import org.metaborg.spoofax.shell.client.IResultVisitor; - /** * Represents a command that has resulted in a {@link Throwable}. */ diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java index 5c04e658..512267e7 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailOrSuccessResult.java @@ -2,7 +2,6 @@ import java.util.Objects; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.functions.FailableFunction; /** diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java index 4a5a7a94..196d1f5f 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/FailResult.java @@ -1,7 +1,5 @@ package org.metaborg.spoofax.shell.output; -import org.metaborg.spoofax.shell.client.IResultVisitor; - /** * An {@link IResult} that represents a failure in execution, along with the cause of the failure. */ diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java index e425ad15..22a36b2e 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResult.java @@ -2,7 +2,6 @@ import java.util.function.Consumer; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.IReplCommand; /** diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResultVisitor.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResultVisitor.java similarity index 82% rename from org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResultVisitor.java rename to org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResultVisitor.java index bbcd41f9..519f56f4 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/client/IResultVisitor.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/IResultVisitor.java @@ -1,8 +1,4 @@ -package org.metaborg.spoofax.shell.client; - -import org.metaborg.spoofax.shell.output.FailResult; -import org.metaborg.spoofax.shell.output.ISpoofaxResult; -import org.metaborg.spoofax.shell.output.StyledText; +package org.metaborg.spoofax.shell.output; /** * An {@link IResultVisitor} is for visiting the results of a command or expression that was diff --git a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java index e3712428..003ddc31 100644 --- a/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java +++ b/org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/output/ISpoofaxResult.java @@ -7,7 +7,6 @@ import org.metaborg.core.context.IContext; import org.metaborg.core.messages.IMessage; import org.metaborg.core.unit.IUnit; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.spoofax.interpreter.terms.IStrategoTerm; /** diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/HelpCommandTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/HelpCommandTest.java index d1f06fea..ad2a6ca9 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/HelpCommandTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/HelpCommandTest.java @@ -14,9 +14,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.metaborg.core.MetaborgException; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.invoker.CommandNotFoundException; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.StyledText; import org.mockito.ArgumentCaptor; import org.mockito.Captor; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/LanguageCommandTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/LanguageCommandTest.java index 9ff5285c..1b5bedf3 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/LanguageCommandTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/LanguageCommandTest.java @@ -29,9 +29,9 @@ import org.metaborg.core.resource.IResourceService; import org.metaborg.core.syntax.ParseException; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.functions.IFunctionFactory; import org.metaborg.spoofax.shell.invoker.ICommandInvoker; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.StyledText; import org.mockito.ArgumentCaptor; import org.mockito.Captor; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java index e08c912b..d5a90ee6 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/AnalyzeFunctionTest.java @@ -24,7 +24,6 @@ import org.metaborg.spoofax.core.analysis.ISpoofaxAnalysisService; import org.metaborg.spoofax.core.analysis.ISpoofaxAnalyzeResult; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.functions.AnalyzeFunction; @@ -34,6 +33,7 @@ import org.metaborg.spoofax.shell.output.FailResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java index 1f376ebd..ffdbf74b 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/EvaluateFunctionTest.java @@ -32,7 +32,6 @@ import org.metaborg.spoofax.core.shell.ShellFacet; import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.core.IEvaluationStrategy; @@ -42,6 +41,7 @@ import org.metaborg.spoofax.shell.output.FailResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java index 5a19cbe5..a2880846 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/InputFunctionTest.java @@ -20,12 +20,12 @@ import org.metaborg.spoofax.core.unit.ISpoofaxInputUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxUnitService; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.FailResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; import org.mockito.ArgumentCaptor; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java index 6d6f30ce..a9bc085c 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/ParseFunctionTest.java @@ -21,13 +21,13 @@ import org.metaborg.spoofax.core.unit.ISpoofaxInputUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxUnitService; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.FailOrSuccessResult; import org.metaborg.spoofax.shell.output.FailResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult; diff --git a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java index 2774188d..1f20d452 100644 --- a/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java +++ b/org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/functions/TransformFunctionTest.java @@ -35,7 +35,6 @@ import org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit; import org.metaborg.spoofax.core.unit.ISpoofaxParseUnit; import org.metaborg.spoofax.core.unit.ISpoofaxTransformUnit; -import org.metaborg.spoofax.shell.client.IResultVisitor; import org.metaborg.spoofax.shell.commands.CommandBuilder; import org.metaborg.spoofax.shell.commands.IReplCommand; import org.metaborg.spoofax.shell.output.AnalyzeResult; @@ -43,6 +42,7 @@ import org.metaborg.spoofax.shell.output.FailResult; import org.metaborg.spoofax.shell.output.IResult; import org.metaborg.spoofax.shell.output.IResultFactory; +import org.metaborg.spoofax.shell.output.IResultVisitor; import org.metaborg.spoofax.shell.output.ISpoofaxResult; import org.metaborg.spoofax.shell.output.InputResult; import org.metaborg.spoofax.shell.output.ParseResult;