[jbosstools-commits] JBoss Tools SVN: r31060 - trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue May 3 22:26:16 EDT 2011


Author: scabanovich
Date: 2011-05-03 22:26:16 -0400 (Tue, 03 May 2011)
New Revision: 31060

Modified:
   trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java
Log:
JBIDE-8845
https://issues.jboss.org/browse/JBIDE-8845

Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java	2011-05-04 02:25:58 UTC (rev 31059)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java	2011-05-04 02:26:16 UTC (rev 31060)
@@ -18,6 +18,7 @@
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.Region;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
 import org.jboss.tools.common.model.XModel;
 import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
 import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -91,13 +92,14 @@
 
 			Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
 
+			Node node = null;
 			if (n instanceof Attr) {
-				n = ((Attr)n).getOwnerElement();
+				node = ((Attr)n).getOwnerElement();
+			} else {
+				node = n.getParentNode();
 			}
-			if (!(n instanceof Element)) return null;
+			if (!(node instanceof Element)) return null;
 			
-			Node node = n.getParentNode();
-
 			String nodeName = node.getNodeName();
 			if (nodeName.indexOf(':') == -1) return null;
 
@@ -125,13 +127,14 @@
 			
 			Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
 
+			Node node = null;
 			if (n instanceof Attr) {
-				n = ((Attr)n).getOwnerElement();
+				node = ((Attr)n).getOwnerElement();
+			} else {
+				node = n.getParentNode();
 			}
-			if (!(n instanceof Element)) return null;
+			if (!(node instanceof Element)) return null;
 			
-			Node node = n.getParentNode();
-
 			String tagName = node.getNodeName();
 			if (tagName.indexOf(':') == -1) return null;
 			
@@ -151,12 +154,22 @@
 	}
 	
 	private String getTagAttributeName(IRegion region) {
-		if(region == null || getDocument() == null) return null;
+		if(region == null) return null;
+		StructuredModelWrapper smw = new StructuredModelWrapper();
+		smw.init(getDocument());
 		try {
-			return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
-		} catch (BadLocationException x) {
-			JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
+			Document xmlDocument = smw.getDocument();
+			if (xmlDocument == null) return null;
+			
+			Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+
+			Node node = null;
+			if (n instanceof Attr) {
+				return ((Attr)n).getName();
+			}
 			return null;
+		} finally {
+			smw.dispose();
 		}
 	}
 	
@@ -171,10 +184,10 @@
 			Node n = Utils.findNodeForOffset(xmlDocument, offset);
 
 			if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
+			IDOMNode node = (IDOMNode)n;
+			int start =node.getStartOffset();
+			int end = node.getEndOffset();
 
-			int start = Utils.getValueStart(n);
-			int end = Utils.getValueEnd(n);
-
 			if (start > offset || end < offset) return null;
 
 			String text = getDocument().get(start, end - start);



More information about the jbosstools-commits mailing list