use of ch.acanda.eclipse.pmd.marker.WrappingPMDMarker in project eclipse-pmd by acanda.
the class ASTQuickFixTestCase method getQuickFix.
@SuppressWarnings("unchecked")
private ASTQuickFix<ASTNode> getQuickFix() {
try {
final Type typeArgument = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
final Class<T> quickFixClass = (Class<T>) typeArgument;
final IMarker marker = mock(IMarker.class);
when(marker.getAttribute(eq("ruleName"), isA(String.class))).thenReturn(params.rulename.orNull());
final String markerText = params.source.substring(params.offset, params.offset + params.length);
if (!markerText.contains("\n")) {
when(marker.getAttribute(eq("markerText"), isA(String.class))).thenReturn(markerText);
}
return (ASTQuickFix<ASTNode>) quickFixClass.getConstructor(PMDMarker.class).newInstance(new WrappingPMDMarker(marker));
} catch (SecurityException | ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
}
use of ch.acanda.eclipse.pmd.marker.WrappingPMDMarker in project eclipse-pmd by acanda.
the class TextEditQuickFixTestCase method getQuickFix.
@SuppressWarnings("unchecked")
private ASTRewriteQuickFix<ASTNode> getQuickFix() {
try {
final Type typeArgument = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
final Class<T> quickFixClass = (Class<T>) typeArgument;
final IMarker marker = mock(IMarker.class);
when(marker.getAttribute(eq("ruleName"), isA(String.class))).thenReturn(params.rulename.orNull());
final String markerText = params.source.substring(params.offset, params.offset + params.length);
when(marker.getAttribute(eq("markerText"), isA(String.class))).thenReturn(markerText);
return (ASTRewriteQuickFix<ASTNode>) quickFixClass.getConstructor(PMDMarker.class).newInstance(new WrappingPMDMarker(marker));
} catch (SecurityException | ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
}
use of ch.acanda.eclipse.pmd.marker.WrappingPMDMarker in project eclipse-pmd by acanda.
the class PMDMarkerResolutionGenerator method getResolutions.
@Override
public IMarkerResolution[] getResolutions(final IMarker marker) {
final JavaQuickFixContext context = new JavaQuickFixContext(getCompilerCompliance(marker));
final ImmutableList<IMarkerResolution> quickFixes = quickFixGenerator.getQuickFixes(new WrappingPMDMarker(marker), context);
return quickFixes.toArray(new IMarkerResolution[quickFixes.size()]);
}
Aggregations