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 @@ -86,7 +86,7 @@ public void run() {
} while (astFile == null || (System.currentTimeMillis() - start) > 10_000);

Assert.assertNotNull("No AST file has been generated", astFile);
IFile adapter = (IFile) astFile.getAdapter(IFile.class);
IFile adapter = astFile.getAdapter(IFile.class);
try (InputStream in = adapter.getContents()) {
String content = IOUtils.toString(in, adapter.getCharset());
Assert.assertTrue(content.startsWith("<?xml version='1.0' encoding='UTF-8' ?>"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static String messageFor(IMarker marker, String defaultValue) {
public static Long createdOn(IMarker marker, long onErrorValue) {

try {
return (Long) marker.getCreationTime();
return marker.getCreationTime();
} catch (CoreException ce) {
return onErrorValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ protected final void reviewResource(IResource resource) {
return;
}

IFile file = (IFile) resource.getAdapter(IFile.class);
IFile file = resource.getAdapter(IFile.class);
if (file == null || file.getFileExtension() == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public void processCommand(final AbstractDefaultCommand aCommand) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
if (aCommand instanceof AbstractDefaultCommand) {
((AbstractDefaultCommand) aCommand).setMonitor(monitor);
}
aCommand.setMonitor(monitor);
long start = System.currentTimeMillis();
aCommand.execute();
long duration = System.currentTimeMillis() - start;
Expand All @@ -75,9 +73,7 @@ protected IStatus run(IProgressMonitor monitor) {
}
};

if (aCommand instanceof AbstractDefaultCommand) {
job.setUser(((AbstractDefaultCommand) aCommand).isUserInitiated());
}
job.setUser(aCommand.isUserInitiated());

synchronized (outstanding) {
if (count.incrementAndGet() > 10) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void run() {
LOG.info("Review code command finished. {} rules were executed against {} files.\n"
+ "Actual PMD duration is about {}ms, that is about {}ms/file, {}ms/rule, {}ms/filerule",
ruleCount, fileCount, pmdDuration, (float) pmdDuration / fileCount,
(float) pmdDuration / ruleCount, (float) pmdDuration / ((long) fileCount * (long) ruleCount));
(float) pmdDuration / ruleCount, (float) pmdDuration / (fileCount * ruleCount));
} else {
LOG.info("Review code command finished. {} rules were executed against {} files. "
+ "PMD has not been executed.", ruleCount, fileCount);
Expand Down Expand Up @@ -466,7 +466,7 @@ private ISchedulingRule getSchedulingRule() {
} else {
ISchedulingRule[] rules = new ISchedulingRule[resources.size()];
for (int i = 0; i < rules.length; i++) {
rules[i] = ruleFactory.markerRule((IResource) resources.get(i));
rules[i] = ruleFactory.markerRule(resources.get(i));
}
rule = new MultiRule(resources.toArray(rules));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void reset() {

@Override
public void execute() {
IFile file = (IFile) resource.getAdapter(IFile.class);
IFile file = resource.getAdapter(IFile.class);
beginTask("PMD checking for rule: " + rule.getName(), 1);

if (file != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void run(final IAction action) {
final Object obj = i.next();
if (obj instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) obj;
final IProject project = (IProject) adaptable.getAdapter(IProject.class);
final IProject project = adaptable.getAdapter(IProject.class);

if (project == null) {
LOG.warn("The selected object cannot adapt to a project");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected void clearReviews() {
resource = ((IMarker) object).getResource();
} else if (object instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) object;
resource = (IResource) adaptable.getAdapter(IResource.class);
resource = adaptable.getAdapter(IResource.class);
} else {
LOG.warn("The selected object is not adaptable");
LOG.debug(" -> selected object = " + object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public final void run(final IAction action) {
private static IProject getProject(IStructuredSelection selection) {
Object object = selection.getFirstElement();
if (object instanceof IAdaptable) {
final IResource resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
final IAdaptable adaptable = (IAdaptable) object;
final IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null) {
return resource.getProject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void reviewSelectedResources(IStructuredSelection selection) {
}

private void addAdaptable(ReviewCodeCmd cmd, IAdaptable adaptable) {
IResource resource = (IResource) adaptable.getAdapter(IResource.class);
IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null) {
cmd.addResource(resource);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte
Object element = i.next();
if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
IResource resource = (IResource) adaptable.getAdapter(IResource.class);
IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null) {
monitor.subTask(resource.getName());
generateAST((IFile) resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void processElement(Object element) throws CoreException {
LOG.debug("Remove markers on resource " + resource.getName());
} else if (element instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) element;
final IResource resource = (IResource) adaptable.getAdapter(IResource.class);
final IResource resource = adaptable.getAdapter(IResource.class);
if (resource == null) {
LOG.warn("The selected object cannot adapt to a resource");
LOG.debug(" -> selected object : " + element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected final void computeSelectedResources() {
}

if (!resources.isEmpty()) {
fResources = (IResource[]) resources.toArray(new IResource[0]);
fResources = resources.toArray(new IResource[0]);
}

} else if (selection instanceof ITextSelection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public int getLOC() {
*/
protected String resourceToString(IResource resource) {
final StringBuilder fileContents = new StringBuilder();
IFile file = (IFile) resource.getAdapter(IFile.class);
IFile file = resource.getAdapter(IFile.class);
try (BufferedReader bReader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()))) {
// ... and read the File line by line
while (bReader.ready()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public AbstractPMDRecord[] getChildren() {

@Override
public IResource getResource() {
return (IResource) folder;
return folder;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ protected int headerHeightFor(Control control) {

@Override
protected void setMenu(Control control, Menu menu) {
((Tree) control).setMenu(menu);
control.setMenu(menu);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected int headerHeightFor(Control control) {

@Override
protected void setMenu(Control control, Menu menu) {
((Table) control).setMenu(menu);
control.setMenu(menu);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Image imageFor(IMarker marker) {
Util.COMP_INT) {
@Override
public Integer valueFor(IMarker marker) {
return (Integer) marker.getAttribute(IMarker.LINE_NUMBER, 0);
return marker.getAttribute(IMarker.LINE_NUMBER, 0);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void handleEvent(Event event) {
return;
}

Object value = ((TreeItem) event.item).getData();
Object value = event.item.getData();
if (value == null || value instanceof RuleCollection) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class PMDProjectPropertyPage extends PropertyPage {
protected Control createContents(final Composite parent) {
LOG.info("PMD properties editing requested");
controller = new PMDPropertyPageController(getShell());
final IProject project = (IProject) getElement().getAdapter(IProject.class);
final IProject project = getElement().getAdapter(IProject.class);
controller.setProject(project);
model = controller.getPropertyPageBean();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public MarkerMenuFiller(ITextEditor thEditor) {
}

private IVerticalRulerInfo getRulerInfo() {
return (IVerticalRulerInfo) editor.getAdapter(IVerticalRulerInfo.class);
return editor.getAdapter(IVerticalRulerInfo.class);
}

private List<IMarker> getMarkers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void handleEvent(Event event) {
return;
}

Object item = ((TreeItem) event.item).getData();
Object item = event.item.getData();
if (item == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public void handleEvent(Event event) {
GC gc = event.gc;
Rectangle area = tree.getClientArea();

Rule rule = (Rule) ((TreeItem) event.item).getData();
Rule rule = (Rule) event.item.getData();
String text = getter.valueFor(rule).toString();

int columnCount = tree.getColumnCount();
Expand Down