forked from metaborg/spoofax-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from spoofax-shell/refactor-inputresult
[RDY] Refactor InputResult out of AbstractSpoofaxResult hierarchy
- Loading branch information
Showing
24 changed files
with
527 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
....spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/functions/PEvalFunction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...shell.core/src/main/java/org/metaborg/spoofax/shell/output/AbstractSpoofaxTermResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.metaborg.spoofax.shell.output; | ||
|
||
import org.metaborg.core.unit.IUnit; | ||
import org.metaborg.spoofax.core.stratego.IStrategoCommon; | ||
import org.spoofax.interpreter.terms.IStrategoTerm; | ||
|
||
/** | ||
* Represents an {@link AbstractResult} as returned by the {@link SpoofaxCommand}. | ||
* Wraps Spoofax {@link IUnit} of various types. Additionally, stores an AST. | ||
* @param <T> the wrapped subtype of {@link IUnit} | ||
*/ | ||
//@formatter:off | ||
public abstract class AbstractSpoofaxTermResult<T extends IUnit> | ||
extends AbstractSpoofaxResult<T> implements ISpoofaxTermResult<T> { | ||
//@formatter:on | ||
private final IStrategoCommon common; | ||
|
||
/** | ||
* Constructor for an {@link AbstractResult}. | ||
* @param common the {@link IStrategoCommon} service. | ||
* @param unit the wrapped {@link IUnit}. | ||
*/ | ||
public AbstractSpoofaxTermResult(IStrategoCommon common, T unit) { | ||
super(unit); | ||
this.common = common; | ||
} | ||
|
||
/** | ||
* Returns a textual representation of a term. | ||
* @param term the term | ||
* @return a string | ||
*/ | ||
public StyledText toString(IStrategoTerm term) { | ||
return new StyledText(common.toString(term)); | ||
} | ||
|
||
@Override | ||
public StyledText styled() { | ||
if (!valid() || !ast().isPresent()) { | ||
return new StyledText(messages().toString()); | ||
} | ||
return toString(ast().get()); | ||
} | ||
|
||
} |
Oops, something went wrong.