summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMatthew Piggott2011-02-22 10:41:46 (EST)
committer Pascal Rapicault2011-02-22 21:22:33 (EST)
commit37025615d813ce7d0d7fd6e4333b8691696ebefe (patch)
treee54418b456505b50bee3d3dee366ad0b500d6719
parent904e9d5bdbb77db7a686ac8d6b36d10219f7aa3c (diff)
downloadm2e-core-37025615d813ce7d0d7fd6e4333b8691696ebefe.zip
m2e-core-37025615d813ce7d0d7fd6e4333b8691696ebefe.tar.gz
m2e-core-37025615d813ce7d0d7fd6e4333b8691696ebefe.tar.bz2
Bug 336580 - Removed exception thrown by operations, added null check to refactoring
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/AddExclusionOperation.java18
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/RemoveDependencyOperation.java14
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/AbstractPomHeirarchyRefactoring.java12
3 files changed, 21 insertions, 23 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/AddExclusionOperation.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/AddExclusionOperation.java
index ea74cb1..9b5301c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/AddExclusionOperation.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/AddExclusionOperation.java
@@ -31,17 +31,15 @@ public class AddExclusionOperation implements Operation {
public void process(Document document) {
Element depElement = PomHelper.findDependency(document, dependency);
- if(depElement == null) {
- //TODO we shall not throw exceptions from operations..
- throw new IllegalArgumentException("Dependency does not exist in this pom");
- }
- Element exclusionsElement = getChild(depElement, EXCLUSIONS);
+ if(depElement != null) {
+ Element exclusionsElement = getChild(depElement, EXCLUSIONS);
- Element exclusionElement = createElement(exclusionsElement, EXCLUSION);
+ Element exclusionElement = createElement(exclusionsElement, EXCLUSION);
- createElementWithText(exclusionElement, ARTIFACT_ID, exclusion.getArtifactId());
- createElementWithText(exclusionElement, GROUP_ID, exclusion.getGroupId());
- //TODO mkleint: are there really exclusion versions??
- createElementWithText(exclusionElement, VERSION, exclusion.getVersion());
+ createElementWithText(exclusionElement, ARTIFACT_ID, exclusion.getArtifactId());
+ createElementWithText(exclusionElement, GROUP_ID, exclusion.getGroupId());
+ //TODO mkleint: are there really exclusion versions??
+ createElementWithText(exclusionElement, VERSION, exclusion.getVersion());
+ }
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/RemoveDependencyOperation.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/RemoveDependencyOperation.java
index 4831caf..93fb88a 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/RemoveDependencyOperation.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/editing/RemoveDependencyOperation.java
@@ -26,14 +26,12 @@ public class RemoveDependencyOperation implements Operation {
*/
public void process(Document document) {
Element dependencyElement = PomHelper.findDependency(document, dependency);
- if(dependencyElement == null) {
- //TODO we shall not throw exceptions from operations..
- throw new IllegalArgumentException("Dependency does not exist in pom");
- }
- Element dependencies = findChild(document.getDocumentElement(), DEPENDENCIES);
- removeChild(dependencies, dependencyElement);
- // Remove dependencies element if it is empty
+ if(dependencyElement != null) {
+ Element dependencies = findChild(document.getDocumentElement(), DEPENDENCIES);
+ removeChild(dependencies, dependencyElement);
+ // Remove dependencies element if it is empty
- removeIfNoChildElement(dependencies);
+ removeIfNoChildElement(dependencies);
+ }
}
}
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/AbstractPomHeirarchyRefactoring.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/AbstractPomHeirarchyRefactoring.java
index 4afbb7c..ff6e712 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/AbstractPomHeirarchyRefactoring.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/AbstractPomHeirarchyRefactoring.java
@@ -186,11 +186,13 @@ public abstract class AbstractPomHeirarchyRefactoring extends Refactoring {
MavenProject project = MavenPlugin.getDefault().getMaven()
.resolveParentProject(request, projectFacade.getMavenProject(pm), pm);
pm.worked(1);
- IMavenProjectFacade parentFacade = getMavenProjectFacade(project);
- if(parentFacade != null) {
- hierarchy.add(parentFacade.getPom());
- gatherDescendants(parentFacade, projectManager, pm);
- gatherAncestors(parentFacade, projectManager, pm);
+ if(project != null) {
+ IMavenProjectFacade parentFacade = getMavenProjectFacade(project);
+ if(parentFacade != null) {
+ hierarchy.add(parentFacade.getPom());
+ gatherDescendants(parentFacade, projectManager, pm);
+ gatherAncestors(parentFacade, projectManager, pm);
+ }
}
}