Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import liquidjava.diagnostics.Diagnostics;
import liquidjava.diagnostics.errors.CustomError;
import liquidjava.diagnostics.warnings.CustomWarning;
import liquidjava.processor.RefinementProcessor;
import spoon.Launcher;
import spoon.processing.ProcessingManager;
Expand Down Expand Up @@ -54,7 +55,11 @@ public static void launch(String... paths) {
}
launcher.getEnvironment().setNoClasspath(true);
launcher.getEnvironment().setComplianceLevel(8);
launcher.run();

boolean buildSuccess = launcher.getModelBuilder().build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always feels like magic trying to find the right words haha

if (!buildSuccess) {
diagnostics.add(new CustomWarning("Java compilation error detected. Verification might be affected."));
}

final Factory factory = launcher.getFactory();
final ProcessingManager processingManager = new QueueProcessingManager(factory);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package liquidjava.diagnostics.warnings;

import spoon.reflect.cu.SourcePosition;

/**
* Custom warning with a message
*
* @see LJWarning
*/
public class CustomWarning extends LJWarning {

public CustomWarning(SourcePosition position, String message) {
super(message, position);
}

public CustomWarning(String message) {
super(message, null);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package liquidjava.diagnostics.warnings;

import spoon.reflect.declaration.CtElement;
import spoon.reflect.cu.SourcePosition;

/**
* Warning indicating that a class referenced in an external refinement was not found
Expand All @@ -11,8 +11,8 @@ public class ExternalClassNotFoundWarning extends LJWarning {

private final String className;

public ExternalClassNotFoundWarning(CtElement element, String message, String className) {
super(message, element.getPosition());
public ExternalClassNotFoundWarning(SourcePosition position, String message, String className) {
super(message, position);
this.className = className;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package liquidjava.diagnostics.warnings;

import spoon.reflect.declaration.CtElement;
import spoon.reflect.cu.SourcePosition;

/**
* Warning indicating that a method referenced in an external refinement was not found
Expand All @@ -13,9 +13,9 @@ public class ExternalMethodNotFoundWarning extends LJWarning {
private final String className;
private final String[] overloads;

public ExternalMethodNotFoundWarning(CtElement element, String message, String methodName, String className,
public ExternalMethodNotFoundWarning(SourcePosition position, String message, String methodName, String className,
String[] overloads) {
super(message, element.getPosition());
super(message, position);
this.methodName = methodName;
this.className = className;
this.overloads = overloads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public <T> void visitCtInterface(CtInterface<T> intrface) {
this.prefix = externalRefinements.get();
if (!classExists(prefix)) {
String message = String.format("Could not find class '%s'", prefix);
diagnostics.add(new ExternalClassNotFoundWarning(intrface, message, prefix));
diagnostics.add(new ExternalClassNotFoundWarning(intrface.getPosition(), message, prefix));
return;
}
getRefinementFromAnnotation(intrface);
Expand Down Expand Up @@ -72,15 +72,15 @@ public <R> void visitCtMethod(CtMethod<R> method) {
prefix);
String[] overloads = getOverloads(targetType, method);
diagnostics.add(
new ExternalMethodNotFoundWarning(method, message, method.getSignature(), prefix, overloads));
new ExternalMethodNotFoundWarning(method.getPosition(), message, method.getSignature(), prefix, overloads));
}
} else {
if (!methodExists(targetType, method)) {
String message = String.format("Could not find method '%s %s' for '%s'",
method.getType().getSimpleName(), method.getSignature(), prefix);
String[] overloads = getOverloads(targetType, method);
diagnostics.add(
new ExternalMethodNotFoundWarning(method, message, method.getSignature(), prefix, overloads));
new ExternalMethodNotFoundWarning(method.getPosition(), message, method.getSignature(), prefix, overloads));
return;
}
}
Expand Down