Author: vrubezhny
Date: 2012-01-30 14:25:22 -0500 (Mon, 30 Jan 2012)
New Revision: 38295
Removed:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
Log:
JBIDE-10621
Redesign HyperlinkDetector so that partitioning and hyperlinks not do twice the same job.
Hyperlinks and Hyperlink Partitioners are redesigned due to exclude duplication work on
regions calculation.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2011-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -31,15 +31,11 @@
import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
-import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.text.ext.JSTExtensionsPlugin;
import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.css.CSSMediaRule;
import org.w3c.dom.css.CSSRule;
@@ -133,7 +129,6 @@
}
return PageContextFactory.getFileFromProject(filePath, getFile());
-
}
/**
@@ -217,87 +212,14 @@
}
return null;
}
-
- protected IRegion fLastRegion = null;
-
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- /**
- *
- * @param offset
- * @return
- */
- protected IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null)
- return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr))
- return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start > offset)
- return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- // find start of css class
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart))
- && sb.charAt(bStart) != '_' && sb.charAt(bStart) !=
'-'
- && sb.charAt(bStart) != '.') {
- bStart++;
- break;
- }
-
- if (bStart == 0)
- break;
- bStart--;
- }
- // find end of css class
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd))
- && sb.charAt(bEnd) != '_' && sb.charAt(bEnd) !=
'-'
- && sb.charAt(bEnd) != '.')
- break;
- bEnd++;
- }
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset)
- return null;
- return new Region(propStart, propLength);
- } catch (BadLocationException x) {
- // ignore
- return null;
- } finally {
- smw.dispose();
- }
- }
-
+
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String styleName = getStyleName(fLastRegion);
+ String styleName = getStyleName(getHyperlinkRegion());
if (styleName == null)
return MessageFormat.format(Messages.OpenA, Messages.CSSStyle);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
@@ -30,16 +33,14 @@
AbstractHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
public static final String CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.CSS_CLASS"; //$NON-NLS-1$
-
private static final String CSS_CLASS_TOKEN = "/class/"; //$NON-NLS-1$
private static final String EXCLUSION_TOKEN = "jsp:usebean/class/";
//$NON-NLS-1$
-
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
* com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document,
+ protected IHyperlinkRegion parse(IDocument document, int offset,
IHyperlinkRegion superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
@@ -48,24 +49,19 @@
if (xmlDocument == null)
return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion
- .getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr))
return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = getPartitionType(axis);
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || end < start)
+
+ IRegion r = getRegion(document, offset);
+ if (r == null)
return null;
- int length = end - start;
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis,
- contentType, type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -75,7 +71,7 @@
return CSS_CLASS_PARTITION;
}
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if (region.getAxis() != null
&& region.getAxis().toLowerCase().endsWith(CSS_CLASS_TOKEN)
&& !region.getAxis().toLowerCase().endsWith(EXCLUSION_TOKEN)) // Fix for
JBIDE-5056
@@ -83,4 +79,66 @@
return false;
}
+ /**
+ *
+ * @param offset
+ * @return
+ */
+ protected IRegion getRegion(IDocument document, int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null)
+ return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Attr))
+ return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if (start > offset)
+ return null;
+
+ String attrText = document.get(start, end - start);
+
+ StringBuffer sb = new StringBuffer(attrText);
+ // find start of css class
+ int bStart = offset - start;
+ while (bStart >= 0) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bStart))
+ && sb.charAt(bStart) != '_' && sb.charAt(bStart) !=
'-'
+ && sb.charAt(bStart) != '.') {
+ bStart++;
+ break;
+ }
+
+ if (bStart == 0)
+ break;
+ bStart--;
+ }
+ // find end of css class
+ int bEnd = offset - start;
+ while (bEnd < sb.length()) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bEnd))
+ && sb.charAt(bEnd) != '_' && sb.charAt(bEnd) !=
'-'
+ && sb.charAt(bEnd) != '.')
+ break;
+ bEnd++;
+ }
+
+ final int propStart = bStart + start;
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset)
+ return null;
+ return new Region(propStart, propLength);
+ } catch (BadLocationException x) {
+ // ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ELHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2011-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -25,6 +25,7 @@
import org.jboss.tools.common.el.core.resolver.MessagePropertyELSegment;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
import org.jboss.tools.common.util.StringUtil;
@@ -40,17 +41,16 @@
setDocument(document);
}
+ /**
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
@Override
protected IRegion doGetHyperlinkRegion(int offset) {
-
- return new IRegion(){
- public int getLength() {
- return segment.getSourceReference().getLength();
- }
-
- public int getOffset() {
- return reference.getStartPosition()+segment.getSourceReference().getStartPosition();
- }};
+ IRegion region = super.doGetHyperlinkRegion(offset);
+ return (region != null ? region : new HyperlinkRegion(
+ reference.getStartPosition()+segment.getSourceReference().getStartPosition(),
+ segment.getSourceReference().getLength()));
}
@Override
@@ -81,11 +81,6 @@
}
}
-// private String getRequestMethod(Properties prop) {
-// return prop != null && prop.getProperty(WebPromptingProvider.KEY) == null ?
-// WebPromptingProvider.JSF_OPEN_BUNDLE : WebPromptingProvider.JSF_OPEN_KEY;
-// }
-
@Override
public String getHyperlinkText() {
IOpenableReference[] openables = segment.getOpenable();
@@ -122,5 +117,4 @@
}
return file;
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,110 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
import org.jboss.tools.common.text.ext.hyperlink.RelativeLinkHyperlink;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
/**
* @author Jeremy
*
*/
public class JSPStylesheetRelLinkHyperlink extends RelativeLinkHyperlink {
-
- private static final String HREF_ATTRNAME = "href"; //$NON-NLS-1$
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Text || n instanceof Attr)) return null;
-
- String text = null;
- int bStart = 0;
- int bEnd = 0;
-
- if (n instanceof Text) {
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- text = getDocument().get(start, end - start);
- bStart = offset - start;
- bEnd = offset - start;
- } else if (n instanceof Attr) {
- Attr attr = (Attr)n;
- if (!HREF_ATTRNAME.equalsIgnoreCase(attr.getName())) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if(start < 0) return null;
-
- text = getDocument().get(start, end - start);
- bStart = offset - start;
- bEnd = offset - start;
- }
- StringBuffer sb = new StringBuffer(text);
- //find start of bean property
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/'
&&
- sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-'
&&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_'
&&
- sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?'
&&
- sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=')
{
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- while (bEnd >= 0 && bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/'
&&
- sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-'
&&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_'
&&
- sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?'
&&
- sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
- break;
- }
- bEnd++;
- }
-
- final int propStart = bStart + Utils.getValueStart(n);
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- return new Region(propStart,propLength);
- } catch (BadLocationException x) {
- //ignore
- return null;
- } finally {
- smw.dispose();
- }
- }
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -27,21 +27,19 @@
public class TaglibDefinitionFilesHyperlinkPartitioner extends
XMLTextHyperlinkPartitioner {
public static final String TAGLIB_XML_PARTITION =
"org.jboss.tools.common.text.ext.xml.TAGLIB_XML"; //$NON-NLS-1$
- /* (non-Javadoc)
- * @see
org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion)
- */
+
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
@Override
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
return (n instanceof Text);
} finally {
smw.dispose();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -127,27 +127,27 @@
for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
if(!(list.item(i) instanceof Element)) continue;
- Element element = (Element)list.item(i);
- int start = Utils.getValueStart(element);
- if (start < 0 || start >= endOffset) continue;
+
+ Element element = (Element)list.item(i);
+ int start = Utils.getValueStart(element);
+ if (start < 0 || start >= endOffset) continue;
+
+ String elementName = element.getNodeName();
+ if (tagName.equals(elementName)) {
- String elementName = element.getNodeName();
- if (tagName.equals(elementName)) {
-
- Attr idAttr = element.getAttributeNode(ID_ATTRNAME);
- if (idAttr != null) {
- String val = Utils.trimQuotes(idAttr.getNodeValue());
- if (id.equals(val)) {
- return element;
- }
+ Attr idAttr = element.getAttributeNode(ID_ATTRNAME);
+ if (idAttr != null) {
+ String val = Utils.trimQuotes(idAttr.getNodeValue());
+ if (id.equals(val)) {
+ return element;
}
}
-
- if (element.hasChildNodes()) {
- Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
- if (child != null) return child;
- }
-
+ }
+
+ if (element.hasChildNodes()) {
+ Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
+ if (child != null) return child;
+ }
}
} finally {
smw.dispose();
@@ -189,11 +189,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getPropertyName(fLastRegion);
+ String propertyName = getPropertyName(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Getter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Getter,
propertyName);
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,27 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.IDocument;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -32,14 +30,14 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return null;
int start = Utils.getValueStart(n);
int end = Utils.getValueEnd(n);
@@ -48,11 +46,8 @@
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_BEAN_GET_PROPERTY_PARTITION;
- int length = end - start - (superRegion.getOffset() - start);
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(start, end - start, axis, contentType, type);
} finally {
smw.dispose();
}
@@ -68,19 +63,19 @@
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr)) return false;
int start = Utils.getValueStart(n);
int end = Utils.getValueEnd(n);
- if (start < 0 || start > region.getOffset() || end < region.getOffset())
+ if (start < 0 || start > offset || end < offset)
return false;
return true;
@@ -88,5 +83,4 @@
smw.dispose();
}
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -32,11 +32,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getPropertyName(fLastRegion);
+ String propertyName = getPropertyName(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Setter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter,
propertyName);
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -31,14 +30,14 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return null;
int start = Utils.getValueStart(n);
int end = Utils.getValueEnd(n);
@@ -46,11 +45,8 @@
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_BEAN_SET_PROPERTY_PARTITION;
- int length = end - start - (superRegion.getOffset() - start);
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(start, end - start, axis, contentType, type);
} finally {
smw.dispose();
}
@@ -66,19 +62,19 @@
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr)) return false;
int start = Utils.getValueStart(n);
int end = Utils.getValueEnd(n);
- if (start < 0 || start > region.getOffset() || end < region.getOffset())
+ if (start < 0 || start > offset|| end < offset)
return false;
return true;
@@ -86,5 +82,4 @@
smw.dispose();
}
}
-
}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.text.ext.hyperlink.jsp;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
-import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
-import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-
-/**
- * * @deprecated see
org.jboss.tools.jst.text.ext.hyperlink.CSSClassHyperlinkPartitioner
- * @author Jeremy
- */
-public class JSPCSSClassHyperlinkPartitioner extends AbstractHyperlinkPartitioner
/*implements IHyperlinkPartitionRecognizer */{
- public static final String JSP_CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_CSS_CLASS"; //$NON-NLS-1$
-
- /**
- * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
- */
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(document);
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-// if (!recognize(document, superRegion)) return null;
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
- if (r == null) return null;
-
- String axis = getAxis(document, superRegion);
- String contentType = superRegion.getContentType();
- String type = JSP_CSS_CLASS_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
-
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
- } finally {
- smw.dispose();
- }
- }
-
- protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
- if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
- return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
- }
- return superRegion.getAxis();
- }
-
- public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(document);
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset) return null;
-
- String attrText = document.get(start, end - start);
- StringBuffer sb = new StringBuffer(attrText);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = attrText.length() - 1;
-
- while (bStart < bEnd &&
- (sb.charAt(bStart) == '\'' || sb.charAt(bStart) == '\"' ||
- Character.isWhitespace(sb.charAt(bStart)))) {
- bStart++;
- }
- while (bEnd > bStart &&
- (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
- Character.isWhitespace(sb.charAt(bEnd)))) {
- bEnd--;
- }
- bEnd++;
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
- return region;
- } catch (BadLocationException x) {
- //ignore
- return null;
- } finally {
- smw.dispose();
- }
-
- }
-
-}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -16,17 +16,22 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.FindObjectHelper;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLElementNameHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.tld.ITaglibMapping;
import org.jboss.tools.jst.web.tld.IWebProject;
import org.jboss.tools.jst.web.tld.WebProjectFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -73,12 +78,17 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- String nodePrefix = getTagPrefix(region);
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (n == null || !(n instanceof IDOMElement)) return null;
+ IHyperlinkRegion r = XMLElementNameHyperlinkPartitioner.getRegion(getDocument(),
region.getOffset());
+ if (r == null) return null;
+
+ String nodePrefix = getTagPrefix(r);
if (nodePrefix == null)
return null;
TaglibManagerWrapper tmw = new TaglibManagerWrapper();
- tmw.init(getDocument(), region.getOffset());
+ tmw.init(getDocument(), r.getOffset());
if(!tmw.exists()) return null;
String uri = tmw.getUri(nodePrefix);
@@ -115,26 +125,16 @@
return null;
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = JSPElementNameHyperlinkPartitioner.getRegion(getDocument(), offset);
- return fLastRegion;
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagPrefix = getTagPrefix(fLastRegion);
+ String tagPrefix = getTagPrefix(getHyperlinkRegion());
if (tagPrefix == null)
return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
return MessageFormat.format(Messages.OpenTagLibraryForPrefix, tagPrefix);
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,26 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import java.util.Map;
+
import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLElementNameHyperlinkPartitioner;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.common.text.ext.hyperlink.xml.XMLElementNameHyperlinkPartitioner;
-
/**
* @author Jeremy
*/
@@ -35,8 +35,8 @@
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
- if (!super.recognize(document, region)) return false;
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region)) return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
@@ -44,10 +44,10 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
Element elem = (Element)n;
- IHyperlinkRegion r = getRegion(document, region.getOffset());
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return false;
String nodeName = elem.getNodeName();
@@ -55,12 +55,10 @@
String nodePrefix = nodeName.substring(0, nodeName.indexOf(":"));
//$NON-NLS-1$
if (nodePrefix == null || nodePrefix.length() == 0) return false;
- Map trackers = JSPRootHyperlinkPartitioner.getTrackersMap(document,
region.getOffset());
+ Map trackers = JSPRootHyperlinkPartitioner.getTrackersMap(document, offset);
return (trackers != null && trackers.containsKey(nodePrefix));
} finally {
smw.dispose();
}
}
-
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -26,7 +26,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -112,7 +111,6 @@
return null;
}
-
String getForId(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
@@ -122,75 +120,16 @@
}
}
- IRegion fLastRegion = null;
/*
* (non-Javadoc)
*
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- return new Region (propStart,propLength);
- } catch (BadLocationException x) {
- //ignore
- return null;
- } finally {
- smw.dispose();
- }
- }
-
- /*
- * (non-Javadoc)
- *
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forId = getForId(fLastRegion);
+ String forId = getForId(getHyperlinkRegion());
if (forId == null)
return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
return MessageFormat.format(Messages.BrowseForBeanId, forId);
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -31,26 +30,21 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-// if (!recognize(document, superRegion)) return null;
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_FOR_BEAN_ID_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -111,7 +105,5 @@
} finally {
smw.dispose();
}
-
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -31,7 +31,7 @@
/* (non-Javadoc)
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
return true;
}
@@ -46,7 +46,7 @@
return JSPStylesheetRelLinkHyperlinkPartitioner.JSP_STYLESHEET_REL_LINK_PARTITION;
}
- public boolean excludes(String partitionType, IDocument document,
+ public boolean excludes(String partitionType, IDocument document, int offset,
IHyperlinkRegion superRegion) {
return false;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,17 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.IDocument;
-
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.xml.XMLLinkHyperlinkPartitioner;
@@ -31,7 +30,7 @@
/* (non-Javadoc)
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
return true;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -44,17 +44,16 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
- if (!recognize(document, superRegion)) return null;
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
+ if (!recognize(document, offset, superRegion)) return null;
String axis = computeAxis(document, superRegion.getOffset()) + "/";
//$NON-NLS-1$
String contentType = superRegion.getContentType();
String type = JSP_ROOT_PARTITION;
- int length = superRegion.getLength();
- int offset = superRegion.getOffset();
+ int superLength = superRegion.getLength();
+ int superOffset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(superOffset, superLength, axis, contentType, type);
}
public static String computeAxis(IDocument document, int offset) {
@@ -209,14 +208,14 @@
/* (non-Javadoc)
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null) return false;
@@ -225,5 +224,4 @@
smw.dispose();
}
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -46,7 +46,7 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
if(superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -54,19 +54,14 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-// if (!recognize(document, superRegion)) return null;
- IRegion r = getRegion(document, superRegion.getOffset());
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_STYLESHEET_REL_LINK_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -75,7 +70,7 @@
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if(region == null) return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -83,7 +78,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
Attr attr = null;
Node tag = null;
@@ -116,7 +111,7 @@
// do recognize style text
int start = Utils.getValueStart(styleText);
- int current = region.getOffset();
+ int current = offset;
String text = styleText.getData();
if (text == null || text.length() == 0) return false;
@@ -238,9 +233,8 @@
return null;
}
- public boolean excludes(String partitionType, IDocument document,
+ public boolean excludes(String partitionType, IDocument document, int offset,
IHyperlinkRegion superRegion) {
- return (JSP_STYLESHEET_REL_LINK_PARTITION.equals(partitionType) &&
recognize(document, superRegion));
+ return (JSP_STYLESHEET_REL_LINK_PARTITION.equals(partitionType) &&
recognize(document, offset, superRegion));
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,47 +1,45 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
*/
public class JSPTagAttributeHyperlinkPartitioner extends
JSPElementAttributeValueHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
public static final String JSP_TAG_ATTRIBUTE_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_TAG_ATTRIBUTE"; //$NON-NLS-1$
-
private static final String JSP_ATTRIBUTE_TAGNAME = "jsp:attribute";
//$NON-NLS-1$
private static final String JSP_ELEMENT_TAGNAME = "jsp:element";
//$NON-NLS-1$
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
if (!(n instanceof Element)) return null;
@@ -52,11 +50,8 @@
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_TAG_ATTRIBUTE_PARTITION;
- int length = end - start - (superRegion.getOffset() - start);
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(start, end - start, axis, contentType, type);
} finally {
smw.dispose();
}
@@ -65,7 +60,7 @@
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if(region == null) return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -73,7 +68,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
if (!(n instanceof Element)) return false;
return (JSP_ATTRIBUTE_TAGNAME.equals(n.getNodeName()) &&
@@ -90,5 +85,4 @@
}
return superRegion.getAxis();
}
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
@@ -27,13 +26,10 @@
import org.jboss.tools.common.model.util.FindObjectHelper;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.tld.ITaglibMapping;
import org.jboss.tools.jst.web.tld.IWebProject;
import org.jboss.tools.jst.web.tld.WebProjectFactory;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
@@ -51,7 +47,6 @@
else {
openFileFailed();
}
-
}
protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
@@ -109,52 +104,17 @@
if (model != null) model.releaseFromRead();
}
}
-
- IRegion fLastRegion = null;
- /*
- * (non-Javadoc)
- *
- * @seecom.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
- if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if (!(n instanceof IDOMElement)) return null;
- if (!"jsp:directive.taglib".equals(n.getNodeName())) return null;
//$NON-NLS-1$
-
- IDOMElement taglib = (IDOMElement)n;
-
- final int taglibLength = taglib.getEndOffset() - taglib.getStartOffset();
- final int taglibOffset = taglib.getStartOffset();
-
- return new Region(taglibOffset,taglibLength);
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String uri = getTaglibUri(fLastRegion);
+ String uri = getTaglibUri(getHyperlinkRegion());
if (uri == null)
return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
return MessageFormat.format(Messages.OpenTagLibraryForUri, uri);
}
-
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -31,7 +30,7 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -39,7 +38,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
if (!(n instanceof Element)) return null;
if (!"jsp:directive.taglib".equals(n.getNodeName())) return null;
//$NON-NLS-1$
@@ -51,21 +50,17 @@
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_TAGLIB_PARTITION;
- int length = end - start - (superRegion.getOffset() - start);
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(start, end - start, axis, contentType, type);
} finally {
smw.dispose();
}
}
-
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if(document == null || region == null) return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -73,7 +68,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
if (!(n instanceof Element)) return false;
return ("jsp:directive.taglib".equals(n.getNodeName())); //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
@@ -55,14 +54,14 @@
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
*/
protected void openFileInEditor(String fileString) {
- if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
- fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
- IEditorInput jarEditorInput = createEditorInput(fileString);
- IEditorPart part = openFileInEditor(jarEditorInput, fileString);
- if (part == null) openFileFailed();
- } else {
- super.openFileInEditor(fileString);
- }
+ if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
+ fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
+ IEditorInput jarEditorInput = createEditorInput(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
+ } else {
+ super.openFileInEditor(fileString);
+ }
}
private XModelObject getFilename(IRegion region) {
@@ -124,48 +123,13 @@
}
}
-
- IRegion fLastRegion = null;
- /**
- * @seecom.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
- if (!(n instanceof IDOMAttr)) return null;
- IDOMAttr xmlnsAttr = (IDOMAttr)n;
- if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
- Element rootElem = xmlnsAttr.getOwnerElement();
- if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return null; //$NON-NLS-1$
//$NON-NLS-2$
-
- final int taglibLength = xmlnsAttr.getValueRegionText().length();
- final int taglibOffset = xmlnsAttr.getValueRegionStartOffset();
-
- return new Region(taglibOffset,taglibLength);
- } finally {
- smw.dispose();
- }
-
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String uri = getUri(fLastRegion);
+ String uri = getUri(getHyperlinkRegion());
if (uri == null)
return MessageFormat.format(Messages.NotFound, "URI"); //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java 2012-01-30
19:24:13 UTC (rev 38294)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java 2012-01-30
19:25:22 UTC (rev 38295)
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
@@ -32,14 +33,14 @@
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof IDOMAttr)) return null;
IDOMAttr xmlnsAttr = (IDOMAttr)n;
if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
@@ -49,28 +50,50 @@
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_XMLNS_PARTITION;
- int length = xmlns.length() - (superRegion.getOffset() -
xmlnsAttr.getValueRegionStartOffset());
- int offset = superRegion.getOffset();
+ int start = Utils.getValueStart(xmlnsAttr);
+ int end = Utils.getValueEnd(xmlnsAttr);
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ String text = document.get(start, end - start);
+ StringBuffer sb = new StringBuffer(text);
+
+ //find start and end of property value
+ int bStart = 0;
+ int bEnd = text.length() - 1;
+
+ while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
+ || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
+ bStart++;
+ }
+ while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
+ || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
+ bEnd--;
+ }
+ bEnd++;
+
+ final int propStart = bStart + start;
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+
+ return new HyperlinkRegion(propStart, propLength, axis, contentType, type);
+ } catch (BadLocationException e) {
+ return null;
} finally {
smw.dispose();
}
}
-
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
- public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr)) return false;
Attr xmlnsAttr = (Attr)n;
if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return false; //$NON-NLS-1$
@@ -81,7 +104,6 @@
smw.dispose();
}
}
-
protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {