Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-01-21 09:44:51 +0000
committerMilos Kleint2011-01-21 09:48:08 +0000
commitc2029d2980f300d25d0ee8e3907a621649c0cd9c (patch)
tree99ee4e5482e771a72dfcf1672f3625c45ae323a8 /org.eclipse.m2e.editor.xml
parentcd08514736c6d3c42501223a3fc346c42cb491c8 (diff)
downloadm2e-core-c2029d2980f300d25d0ee8e3907a621649c0cd9c.tar.gz
m2e-core-c2029d2980f300d25d0ee8e3907a621649c0cd9c.tar.xz
m2e-core-c2029d2980f300d25d0ee8e3907a621649c0cd9c.zip
MNGECLIPSE-2730 unknown packaging now also located in pom.
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java60
1 files changed, 42 insertions, 18 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
index fe29d141..5d99f4a7 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
@@ -39,6 +39,11 @@ import org.eclipse.m2e.core.project.IMavenMarkerManager;
import static org.eclipse.m2e.editor.xml.internal.PomEdits.*;
+/**
+ * a service impl used by the core module to improve marker locations and addition of our own markers
+ * @author mkleint
+ *
+ */
public class MarkerLocationService implements IMarkerLocationService, IEditorMarkerService {
private static final String XSI_SCHEMA_LOCATION = "xsi:schemaLocation"; //$NON-NLS-1$
@@ -48,6 +53,19 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
public void findLocationForMarker(final IMarker marker) {
String hint = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
+ if (IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(hint)) {
+ IDocument document = XmlUtils.getDocument(marker);
+ XmlUtils.performOnRootElement(document, new NodeOperation<Element>() {
+ public void process(Element root, IStructuredDocument structuredDocument) {
+ Element markEl = findChild(root, "packaging");
+ if (markEl == null) {
+ markEl = root;
+ }
+ annotateMarker(marker, structuredDocument, markEl);
+ }
+ });
+ }
+
if (IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(hint)) {
IDocument document = XmlUtils.getDocument(marker);
XmlUtils.performOnRootElement(document, new NodeOperation<Element>() {
@@ -96,26 +114,10 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
// we could.. search pluginManagement, but it's unlikely to be there..
ourMarkerPlacement = build != null ? build : root;
}
- if (ourMarkerPlacement instanceof IndexedRegion) {
- IndexedRegion region = (IndexedRegion) ourMarkerPlacement;
- try {
- marker.setAttribute(IMarker.CHAR_START, region.getStartOffset());
- //as end, mark just the end of line where the region starts to prevent marking the entire <build> section.
- IRegion line;
- try {
- line = structuredDocument.getLineInformationOfOffset(region.getStartOffset());
- int end = Math.min(region.getEndOffset(), line.getOffset() + line.getLength());
- marker.setAttribute(IMarker.CHAR_END, end);
- } catch(BadLocationException e) {
- marker.setAttribute(IMarker.CHAR_END, region.getStartOffset() + region.getLength());
- }
- marker.setAttribute(IMarker.LINE_NUMBER, structuredDocument.getLineOfOffset(region.getStartOffset()) + 1);
- } catch(CoreException e) {
- MavenLogger.log(e);
- }
- }
+ annotateMarker(marker, structuredDocument, ourMarkerPlacement);
}
+
private Element findPlugin(Element build, String groupId, String artifactId) {
return findChild(findChild(build, "plugins"), "plugin", childEquals("groupId", groupId), childEquals("artifactId", artifactId));
}
@@ -123,6 +125,28 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
}
}
+ private void annotateMarker(final IMarker marker, IStructuredDocument structuredDocument, Element ourMarkerPlacement) {
+ if (ourMarkerPlacement instanceof IndexedRegion) {
+ IndexedRegion region = (IndexedRegion) ourMarkerPlacement;
+ try {
+ marker.setAttribute(IMarker.CHAR_START, region.getStartOffset());
+ //as end, mark just the end of line where the region starts to prevent marking the entire <build> section.
+ IRegion line;
+ try {
+ line = structuredDocument.getLineInformationOfOffset(region.getStartOffset());
+ int end = Math.min(region.getEndOffset(), line.getOffset() + line.getLength());
+ marker.setAttribute(IMarker.CHAR_END, end);
+ } catch(BadLocationException e) {
+ marker.setAttribute(IMarker.CHAR_END, region.getStartOffset() + region.getLength());
+ }
+ marker.setAttribute(IMarker.LINE_NUMBER, structuredDocument.getLineOfOffset(region.getStartOffset()) + 1);
+ } catch(CoreException e) {
+ MavenLogger.log(e);
+ }
+ }
+ }
+
+
public void addEditorHintMarkers(IMavenMarkerManager markerManager, IFile pom, MavenProject mavenProject, String type) {
checkForSchema(markerManager, pom, type);
checkVarious(markerManager, pom, mavenProject, type);

Back to the top