use of dyvil.annotation.internal.NonNull in project Dyvil by Dyvil.
the class FileUtils method readLines.
@DyvilModifiers(Modifiers.INFIX)
@NonNull
public static List<@NonNull String> readLines(@NonNull File file) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(file.toPath())) {
final List<String> result = new ArrayList<>();
for (; ; ) {
String line = reader.readLine();
if (line == null) {
break;
}
result.add(line);
}
return result;
}
}
use of dyvil.annotation.internal.NonNull in project Dyvil by Dyvil.
the class LambdaExpr method makeType.
@NonNull
private LambdaType makeType() {
final int count = this.parameters.size();
final LambdaType lambdaType = new LambdaType();
final TypeList arguments = lambdaType.getArguments();
for (int i = 0; i < count; i++) {
arguments.add(this.parameters.get(i).getType());
}
arguments.add(this.returnType != null ? this.returnType : Types.UNKNOWN);
this.flags |= LAMBDA_TYPE_INFERRED;
return lambdaType;
}
use of dyvil.annotation.internal.NonNull in project Dyvil by Dyvil.
the class ClassFormat method readReferenceType.
@NonNull
private static IType readReferenceType(String desc, int start, int end) {
int index = desc.indexOf('<', start);
if (index >= 0 && index < end) {
final GenericType type = new InternalGenericType(desc.substring(start, index));
final TypeList arguments = type.getArguments();
index++;
while (desc.charAt(index) != '>') {
index = readTyped(desc, index, arguments, true);
}
return type;
}
return new InternalType(desc.substring(start, end));
}
use of dyvil.annotation.internal.NonNull in project Dyvil by Dyvil.
the class ForEachStatement method toIteratorLoop.
@NonNull
public IValue toIteratorLoop(MarkerList markers, IContext context, IType varType, IValue value, IType valueType) {
final IType iteratorType = Types.resolveTypeSafely(valueType, IterableForStatement.LazyFields.ITERATOR_TYPE);
if (varType == Types.UNKNOWN) {
this.inferVariableType(markers, iteratorType);
} else if (!Types.isAssignable(varType, iteratorType)) {
final Marker marker = Markers.semanticError(value.getPosition(), "for.iterator.type");
marker.addInfo(Markers.getSemantic("iterator.type", iteratorType));
marker.addInfo(Markers.getSemantic("variable.type", varType));
markers.add(marker);
}
this.variable.setValue(TypeChecker.convertValue(value, IterableForStatement.LazyFields.ITERATOR, null, markers, context, null));
final IterableForStatement iterableForStatement = new IterableForStatement(this.position, this.variable, true);
iterableForStatement.resolveAction(this.action, markers, context);
return iterableForStatement;
}
use of dyvil.annotation.internal.NonNull in project Dyvil by Dyvil.
the class ForEachStatement method toIterable.
@NonNull
public IValue toIterable(MarkerList markers, IContext context, IType varType, IValue value, IType valueType) {
final IType iterableType = Types.resolveTypeSafely(valueType, IterableForStatement.LazyFields.ITERABLE_TYPE);
if (varType == Types.UNKNOWN) {
this.inferVariableType(markers, iterableType);
} else if (!Types.isAssignable(varType, iterableType)) {
final Marker marker = Markers.semanticError(value.getPosition(), "for.iterable.type");
marker.addInfo(Markers.getSemantic("iterable.type", iterableType));
marker.addInfo(Markers.getSemantic("variable.type", varType));
markers.add(marker);
}
this.variable.setValue(TypeChecker.convertValue(value, IterableForStatement.LazyFields.ITERABLE, null, markers, context, null));
final IterableForStatement iterableForStatement = new IterableForStatement(this.position, this.variable, false);
iterableForStatement.resolveAction(this.action, markers, context);
return iterableForStatement;
}
Aggregations