Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2019-10-27 16:42:54 +0000
committerAlexander Kurtakov2019-10-27 16:42:54 +0000
commit079c0b8f775a413ed9869be985d64dc9fdd232ac (patch)
treeb7a2520ba2d524270d3e29300c8fc637953d9c47 /org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude
parent643f2bb7ec80231751b7a653f38975b0a2938020 (diff)
downloadm2e-core-079c0b8f775a413ed9869be985d64dc9fdd232ac.tar.gz
m2e-core-079c0b8f775a413ed9869be985d64dc9fdd232ac.tar.xz
m2e-core-079c0b8f775a413ed9869be985d64dc9fdd232ac.zip
Enable more warnings in m2e.refactorings and fix them.
Change-Id: Id913cab0a21da74a94c380c105d02ddb09825d7e Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude')
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/DependencyExcludeAction.java4
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java38
2 files changed, 20 insertions, 22 deletions
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/DependencyExcludeAction.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/DependencyExcludeAction.java
index 980ad1ff..d97b055f 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/DependencyExcludeAction.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/DependencyExcludeAction.java
@@ -50,6 +50,7 @@ public class DependencyExcludeAction implements IActionDelegate {
private ArtifactKey[] keys;
+ @Override
public void run(IAction action) {
if(keys == null || file == null) {
return;
@@ -72,6 +73,7 @@ public class DependencyExcludeAction implements IActionDelegate {
}
}
+ @Override
public void selectionChanged(IAction action, ISelection selection) {
file = null;
keys = null;
@@ -80,7 +82,7 @@ public class DependencyExcludeAction implements IActionDelegate {
if(selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- List<ArtifactKey> keys = new ArrayList<ArtifactKey>(structuredSelection.size());
+ List<ArtifactKey> keys = new ArrayList<>(structuredSelection.size());
for(Object selected : structuredSelection.toArray()) {
if(selected instanceof Artifact) {
file = getFileFromEditor();
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
index 33d11345..5fc3344b 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
@@ -44,8 +44,6 @@ import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.core.embedder.ICallable;
-import org.eclipse.m2e.core.embedder.IMavenExecutionContext;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.editing.AddDependencyOperation;
import org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation;
@@ -107,11 +105,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- return MavenPlugin.getMaven().execute(new ICallable<RefactoringStatus>() {
- public RefactoringStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
- return checkFinalConditions0(monitor);
- }
- }, pm);
+ return MavenPlugin.getMaven().execute((context, monitor) -> checkFinalConditions0(monitor), pm);
}
RefactoringStatus checkFinalConditions0(IProgressMonitor pm) throws CoreException, OperationCanceledException {
@@ -119,12 +113,12 @@ public class ExcludeArtifactRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.ExcludeArtifactRefactoring_unableToLocateProject);
}
- changes = new ArrayList<Change>();
- Set<ArtifactKey> locatedKeys = new HashSet<ArtifactKey>();
- List<IStatus> statuses = new ArrayList<IStatus>();
+ changes = new ArrayList<>();
+ Set<ArtifactKey> locatedKeys = new HashSet<>();
+ List<IStatus> statuses = new ArrayList<>();
SubMonitor monitor = SubMonitor.convert(pm, 3);
- List<Operation> exclusionOp = new ArrayList<Operation>();
+ List<Operation> exclusionOp = new ArrayList<>();
// Exclusion point
for(Entry<Dependency, Set<ArtifactKey>> entry : getDependencyExcludes(exclusionPoint, monitor.newChild(1))
.entrySet()) {
@@ -143,7 +137,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
// Below exclusion point - pull up dependency to exclusion point
for(ParentHierarchyEntry project : getWorkspaceDescendants()) {
- List<Operation> operations = new ArrayList<Operation>();
+ List<Operation> operations = new ArrayList<>();
for(Entry<Dependency, Set<ArtifactKey>> entry : getDependencyExcludes(project, monitor.newChild(1)).entrySet()) {
locatedKeys.addAll(entry.getValue());
Dependency dependency = entry.getKey();
@@ -209,8 +203,8 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
}
sb.deleteCharAt(sb.length() - 1);
- return RefactoringStatus.createErrorStatus(NLS.bind(Messages.ExcludeArtifactRefactoring_failedToLocateArtifact,
- sb.toString()));
+ return RefactoringStatus
+ .createErrorStatus(NLS.bind(Messages.ExcludeArtifactRefactoring_failedToLocateArtifact, sb.toString()));
}
return new RefactoringStatus();
}
@@ -259,7 +253,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
private Collection<ParentHierarchyEntry> getWorkspaceDescendants() {
- List<ParentHierarchyEntry> descendants = new ArrayList<ParentHierarchyEntry>();
+ List<ParentHierarchyEntry> descendants = new ArrayList<>();
for(ParentHierarchyEntry project : getHierarchy()) {
if(project == exclusionPoint) {
break;
@@ -272,7 +266,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
private Collection<ParentHierarchyEntry> getWorkspaceAncestors() {
- List<ParentHierarchyEntry> ancestors = new ArrayList<ParentHierarchyEntry>();
+ List<ParentHierarchyEntry> ancestors = new ArrayList<>();
boolean add = false;
for(ParentHierarchyEntry project : getHierarchy()) {
if(project == exclusionPoint) {
@@ -287,8 +281,8 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
private static String toString(Dependency dependency) {
- return NLS.bind(
- "{0}:{1}:{2}", new String[] {dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()}); //$NON-NLS-1$
+ return NLS.bind("{0}:{1}:{2}", //$NON-NLS-1$
+ new String[] {dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()});
}
private boolean hasDependency(ParentHierarchyEntry project, Dependency dependency) {
@@ -332,10 +326,10 @@ public class ExcludeArtifactRefactoring extends Refactoring {
private class Visitor implements DependencyVisitor {
private List<Dependency> dependencies;
- private Map<Dependency, Set<ArtifactKey>> sourceMap = new HashMap<Dependency, Set<ArtifactKey>>();
+ private Map<Dependency, Set<ArtifactKey>> sourceMap = new HashMap<>();
Visitor(ParentHierarchyEntry project) {
- dependencies = new ArrayList<Dependency>();
+ dependencies = new ArrayList<>();
dependencies.addAll(project.getProject().getOriginalModel().getDependencies());
// for(Profile profile : project.getActiveProfiles()) {
// dependencies.addAll(profile.getDependencies());
@@ -350,11 +344,13 @@ public class ExcludeArtifactRefactoring extends Refactoring {
private DependencyNode topLevel;
+ @Override
public boolean visitLeave(DependencyNode node) {
depth-- ;
return true;
}
+ @Override
public boolean visitEnter(DependencyNode node) {
if(depth == 1) {
topLevel = node;
@@ -382,7 +378,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
private void put(Dependency dep, ArtifactKey key) {
Set<ArtifactKey> keys = sourceMap.get(dep);
if(keys == null) {
- keys = new HashSet<ArtifactKey>();
+ keys = new HashSet<>();
sourceMap.put(dep, keys);
}
keys.add(key);

Back to the top