-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schemacode compiler messages overhaul
- Loading branch information
Showing
114 changed files
with
1,170 additions
and
1,033 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package info.teksol.mindcode; | ||
|
||
public interface AstElement { | ||
|
||
InputPosition inputPosition(); | ||
|
||
} |
57 changes: 55 additions & 2 deletions
57
compiler/src/main/java/info/teksol/mindcode/CompilerMessage.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 |
---|---|---|
@@ -1,7 +1,60 @@ | ||
package info.teksol.mindcode; | ||
|
||
public interface CompilerMessage extends MindcodeMessage { | ||
import org.intellij.lang.annotations.PrintFormat; | ||
|
||
InputPosition inputPosition(); | ||
import java.util.Locale; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
public record CompilerMessage(MessageLevel level, InputPosition inputPosition, String message) implements MindcodeMessage { | ||
|
||
public CompilerMessage { | ||
Objects.requireNonNull(level); | ||
Objects.requireNonNull(inputPosition); | ||
Objects.requireNonNull(message); | ||
} | ||
|
||
@Override | ||
public MindcodeMessage translatePosition(InputPositionTranslator translator) { | ||
if (!inputPosition.isEmpty()) { | ||
InputPosition translated = translator.apply(inputPosition); | ||
if (translated != inputPosition) { | ||
return new CompilerMessage(level, translated, message); | ||
} | ||
} | ||
return this; | ||
} | ||
|
||
public static CompilerMessage error(InputPosition inputPosition, @PrintFormat String format, Object... args) { | ||
Objects.requireNonNull(inputPosition); | ||
return new CompilerMessage(MessageLevel.ERROR, inputPosition, String.format(Locale.US, format, args)); | ||
} | ||
|
||
public static CompilerMessage warn(InputPosition inputPosition, @PrintFormat String format, Object... args) { | ||
Objects.requireNonNull(inputPosition); | ||
return new CompilerMessage(MessageLevel.WARNING, inputPosition, String.format(Locale.US, format, args)); | ||
} | ||
|
||
public static CompilerMessage info(InputPosition inputPosition, @PrintFormat String format, Object... args) { | ||
Objects.requireNonNull(inputPosition); | ||
return new CompilerMessage(MessageLevel.INFO, inputPosition, String.format(Locale.US, format, args)); | ||
} | ||
|
||
public static CompilerMessage debug(InputPosition inputPosition, @PrintFormat String format, Object... args) { | ||
Objects.requireNonNull(inputPosition); | ||
return new CompilerMessage(MessageLevel.DEBUG, inputPosition, String.format(Locale.US, format, args)); | ||
} | ||
|
||
public String formatMessage(Function<InputPosition, String> positionFormatter) { | ||
return positionFormatter.apply(inputPosition()) + " " + (isErrorOrWarning() ? level().getTitle() + ": " : "") + formatMessage(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MindcodeCompilerMessage{" + | ||
"level=" + level + | ||
", inputPosition=" + inputPosition + | ||
", message='" + message + '\'' + | ||
'}'; | ||
} | ||
} |
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
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
64 changes: 0 additions & 64 deletions
64
compiler/src/main/java/info/teksol/mindcode/compiler/MindcodeCompilerMessage.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
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
Oops, something went wrong.