added first deps implementation
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
package p.studio.compiler.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import p.studio.utilities.structures.ReadOnlySet;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class FrontendSpec {
|
||||
private final String languageId;
|
||||
private final ReadOnlySet<String> allowedExtensions;
|
||||
private final ReadOnlySet<String> sourceRoots;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package p.studio.compiler.source;
|
||||
|
||||
import lombok.Getter;
|
||||
import p.studio.compiler.source.identifiers.FileId;
|
||||
|
||||
@Getter
|
||||
public class Span {
|
||||
private final FileId fileId;
|
||||
private final long start;
|
||||
private final long end; // exclusive
|
||||
|
||||
public Span(FileId fileId, long start, long end) {
|
||||
this.fileId = fileId;
|
||||
this.start = Math.min(start, end);
|
||||
this.end = Math.max(start, end);
|
||||
}
|
||||
|
||||
public static Span none() {
|
||||
return new Span(FileId.none(), 0, 0);
|
||||
}
|
||||
|
||||
public boolean isNone() {
|
||||
return fileId.isNone();
|
||||
}
|
||||
|
||||
public long length() {
|
||||
return end - start;
|
||||
}
|
||||
|
||||
public boolean contains(long pos) {
|
||||
if (pos < 0L) return false;
|
||||
return start <= pos && end > pos;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package p.studio.compiler.source.diagnostics;
|
||||
|
||||
import lombok.Getter;
|
||||
import p.studio.compiler.source.Span;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class Diagnostic {
|
||||
private final Severity severity;
|
||||
private final String code;
|
||||
private final String message;
|
||||
private final Span span;
|
||||
private final ReadOnlyList<RelatedSpan> related;
|
||||
|
||||
public Diagnostic(
|
||||
final Severity severity,
|
||||
final String code,
|
||||
final String message,
|
||||
final Span span,
|
||||
final List<RelatedSpan> related) {
|
||||
this.severity = severity;
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.span = span;
|
||||
this.related = ReadOnlyList.wrap(related);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package p.studio.compiler.source.diagnostics;
|
||||
|
||||
public class DiagnosticBundle {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package p.studio.compiler.source.diagnostics;
|
||||
|
||||
import lombok.Getter;
|
||||
import p.studio.compiler.source.Span;
|
||||
|
||||
@Getter
|
||||
public class RelatedSpan {
|
||||
private final String message;
|
||||
private final Span span;
|
||||
|
||||
public RelatedSpan(String message, Span span) {
|
||||
this.message = message;
|
||||
this.span = span;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package p.studio.compiler.source.diagnostics;
|
||||
|
||||
public enum Severity {
|
||||
Error,
|
||||
Warning,
|
||||
;
|
||||
|
||||
public boolean isError() {
|
||||
return this == Error;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
abstract class AbstractSourceIdentifier {
|
||||
@EqualsAndHashCode.Include
|
||||
private final long id;
|
||||
|
||||
AbstractSourceIdentifier(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return (int) id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%d)", getClass().getSimpleName(), id);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class FileId extends AbstractSourceIdentifier {
|
||||
public static final FileId NONE = new FileId(-1L);
|
||||
|
||||
public FileId(long id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public static FileId none() {
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public boolean isNone() {
|
||||
return this == NONE;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class ModuleId extends AbstractSourceIdentifier {
|
||||
public ModuleId(long id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class NameId extends AbstractSourceIdentifier {
|
||||
public NameId(long id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class NodeId extends AbstractSourceIdentifier {
|
||||
public NodeId(long id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class ProjectId extends AbstractSourceIdentifier {
|
||||
public ProjectId(int id) {
|
||||
super(Integer.toUnsignedLong(id));
|
||||
}
|
||||
|
||||
public ProjectId(long id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class SymbolId extends AbstractSourceIdentifier {
|
||||
public SymbolId(int id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.studio.compiler.source.identifiers;
|
||||
|
||||
public class TypeId extends AbstractSourceIdentifier {
|
||||
public TypeId(long id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user