summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-06-19 15:08:44 (EDT)
committer Curtis Windatt2013-06-19 15:08:44 (EDT)
commit8111b8f438c5e43eda95e5b5324fe3e70f586a54 (patch)
tree986e6428499527c3f8229cd64384237e34168556
parent9d8beec2cb4ff378bd13235c9f9cc1c5e0e1cd8f (diff)
downloadeclipse.pde.ui-8111b8f438c5e43eda95e5b5324fe3e70f586a54.zip
eclipse.pde.ui-8111b8f438c5e43eda95e5b5324fe3e70f586a54.tar.gz
eclipse.pde.ui-8111b8f438c5e43eda95e5b5324fe3e70f586a54.tar.bz2
Bug 410983 - Unexpected "is not externalized" problem reportedI20130625-0800cwindatt/4_4_master
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
index d6bfe77..68a7ef0 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,9 +11,6 @@
*******************************************************************************/
package org.eclipse.pde.internal.core.builders;
-import org.eclipse.jface.text.Position;
-import org.w3c.dom.Element;
-
import java.io.StringReader;
import java.util.*;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -350,13 +347,26 @@ public class XMLErrorReporter extends DefaultHandler {
return buf.toString();
}
+ /**
+ * Returns the text content of the xml element or <code>null</code> if there
+ * is a problem determining the content. If the element has any children
+ * nodes, <code>null</code> will be returned.
+ *
+ * @param element the xml element to parse
+ * @return the text content of the xml node or <code>null</code>
+ */
protected String getTextContent(Element element) {
ElementData data = fOffsetTable.get(element);
try {
- IRegion nameRegion = fFindReplaceAdapter.find(data.offset, "</" + element.getNodeName() + ">", true, true, false, false); //$NON-NLS-1$ //$NON-NLS-2$
- int offset = data.offset + element.getNodeName().length() + 2;
- if (nameRegion != null)
- return fTextDocument.get(offset, nameRegion.getOffset() - offset).trim();
+ if (element.hasChildNodes()) {
+ return null;
+ }
+ IRegion openElement = fFindReplaceAdapter.find(data.offset, ">", true, true, false, false); //$NON-NLS-1$
+ IRegion closeElement = fFindReplaceAdapter.find(data.offset, "</" + element.getNodeName() + ">", true, true, false, false); //$NON-NLS-1$ //$NON-NLS-2$
+ if (openElement != null && closeElement != null) {
+ int endOfOpenElement = openElement.getOffset() + openElement.getLength();
+ return fTextDocument.get(endOfOpenElement, closeElement.getOffset() - endOfOpenElement).trim();
+ }
} catch (BadLocationException e) {
}
return null;