Author: vrubezhny
Date: 2012-06-28 12:02:04 -0400 (Thu, 28 Jun 2012)
New Revision: 42288
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForwardHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
Log:
JBIDE-11140
OpenOn does not work for files referenced with EL variable
Issue is fixed
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java 2012-06-28
15:33:04 UTC (rev 42287)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java 2012-06-28
16:02:04 UTC (rev 42288)
@@ -28,6 +28,10 @@
* @author Jeremy
*/
public abstract class XMLLinkHyperlinkPartitioner extends AbstractHyperlinkPartitioner
implements IHyperlinkPartitionRecognizer {
+ protected static final String EL_DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+ protected static final String EL_SUFFIX = "}"; //$NON-NLS-1$
+ protected static final String EL_SHARP_PREFIX = "#{"; //$NON-NLS-1$
+
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
@@ -87,6 +91,12 @@
}
if (start + bStart > offset || start + bEnd - 1 < offset) return null;
+ int elStart = sb.indexOf(EL_SHARP_PREFIX) == -1 ? sb.indexOf(EL_DOLLAR_PREFIX) :
sb.indexOf(EL_SHARP_PREFIX);
+ if (elStart != -1 && elStart >= bStart && elStart < bEnd) {
+ int elEnd = sb.indexOf(EL_SUFFIX, elStart);
+ bStart = (elEnd == -1 || elEnd > bEnd) ? bEnd : elEnd + 1;
+ }
+
//find start and end of path property
while (bStart >= 0) {
if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForwardHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForwardHyperlinkPartitioner.java 2012-06-28
15:33:04 UTC (rev 42287)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForwardHyperlinkPartitioner.java 2012-06-28
16:02:04 UTC (rev 42288)
@@ -24,6 +24,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -31,6 +32,10 @@
public class JSPForwardHyperlinkPartitioner extends AbstractHyperlinkPartitioner
/*implements IHyperlinkPartitionRecognizer */{
public static final String JSP_FORWARD_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_FORWARD"; //$NON-NLS-1$
+ private static final String EL_DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+ private static final String EL_SUFFIX = "}"; //$NON-NLS-1$
+ private static final String EL_SHARP_PREFIX = "#{"; //$NON-NLS-1$
+
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
@@ -57,8 +62,8 @@
protected String getAxis(IDocument document, int offset) {
return JSPRootHyperlinkPartitioner.computeAxis(document, offset) + "/";
//$NON-NLS-1$
}
-
- public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
+
+ public IHyperlinkRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -67,39 +72,71 @@
Node n = Utils.findNodeForOffset(xmlDocument, offset);
- if (n == null || !(n instanceof Attr)) return null;
+ if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
int start = Utils.getValueStart(n);
int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
+ String text = document.get(start, end - start);
+ StringBuffer sb = new StringBuffer(text);
- 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)))) {
+ int bStart = 0;
+ int bEnd = sb.length();
+
+ // In case of attribute value we need to skip leading and ending quotes &&
whitespaces
+ while (bStart < bEnd && (sb.charAt(bStart) == '"' ||
sb.charAt(bStart) == '\'' ||
+ sb.charAt(bStart) == 0x09 || sb.charAt(bStart) == 0x0A ||
+ sb.charAt(bStart) == 0x0D || sb.charAt(bStart) == 0x20)) {
bStart++;
}
- while (bEnd > bStart &&
- (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
- Character.isWhitespace(sb.charAt(bEnd)))) {
+
+ while (bEnd - 1 > bStart && (sb.charAt(bEnd - 1) == '"' ||
sb.charAt(bEnd - 1) == '\'' ||
+ sb.charAt(bEnd - 1) == 0x09 || sb.charAt(bEnd - 1) == 0x0A ||
+ sb.charAt(bEnd - 1) == 0x0D || sb.charAt(bEnd - 1) == 0x20)) {
bEnd--;
}
- bEnd++;
+ if (start + bStart > offset || start + bEnd - 1 < offset) return null;
+ int elStart = sb.indexOf(EL_SHARP_PREFIX) == -1 ? sb.indexOf(EL_DOLLAR_PREFIX) :
sb.indexOf(EL_SHARP_PREFIX);
+ if (elStart != -1 && elStart >= bStart && elStart < bEnd) {
+ int elEnd = sb.indexOf(EL_SUFFIX, elStart);
+ bStart = (elEnd == -1 || elEnd > bEnd) ? bEnd : elEnd + 1;
+ }
+
+ //find start and end of path 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
+ bEnd = bStart;
+ while (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++;
+ }
+
int propStart = bStart + start;
int propLength = bEnd - bStart;
+ if (propStart > offset + 1 || propStart + propLength < offset) return null;
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
- return region;
+ return new HyperlinkRegion(propStart, propLength);
} catch (BadLocationException x) {
JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
return null;
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-06-28
15:33:04 UTC (rev 42287)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java 2012-06-28
16:02:04 UTC (rev 42288)
@@ -42,6 +42,9 @@
private static final String URL_METHODSTART = "url("; //$NON-NLS-1$
private static final String URL_METHODEND = ")"; //$NON-NLS-1$
private static final String URL_METHODEND_2 = ";"; //$NON-NLS-1$
+ private static final String EL_DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+ private static final String EL_SUFFIX = "}"; //$NON-NLS-1$
+ private static final String EL_SHARP_PREFIX = "#{"; //$NON-NLS-1$
/**
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
@@ -151,7 +154,6 @@
protected IRegion getRegion (IDocument document, int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
- smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -161,30 +163,53 @@
if (n == null || !(n instanceof Text || n instanceof Attr)) return null;
String text = null;
- int bStart = 0;
- int bEnd = 0;
-
+ int start = 0;
+ int end = 0;
if (n instanceof Text) {
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
+ start = Utils.getValueStart(n);
+ end = Utils.getValueEnd(n);
if (start < 0 || start > offset) return null;
text = document.get(start, end - start);
- bStart = offset - start;
- bEnd = offset - 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);
+ start = Utils.getValueStart(n);
+ end = Utils.getValueEnd(n);
if(start < 0) return null;
text = document.get(start, end - start);
- bStart = offset - start;
- bEnd = offset - start;
+// bStart = offset - start;
+// bEnd = offset - start;
}
+
StringBuffer sb = new StringBuffer(text);
+ int bStart = 0;
+ int bEnd = sb.length();
+
+ // In case of attribute value we need to skip leading and ending quotes &&
whitespaces
+ while (bStart < bEnd && (sb.charAt(bStart) == '"' ||
sb.charAt(bStart) == '\'' ||
+ sb.charAt(bStart) == 0x09 || sb.charAt(bStart) == 0x0A ||
+ sb.charAt(bStart) == 0x0D || sb.charAt(bStart) == 0x20)) {
+ bStart++;
+ }
+
+ while (bEnd - 1 > bStart && (sb.charAt(bEnd - 1) == '"' ||
sb.charAt(bEnd - 1) == '\'' ||
+ sb.charAt(bEnd - 1) == 0x09 || sb.charAt(bEnd - 1) == 0x0A ||
+ sb.charAt(bEnd - 1) == 0x0D || sb.charAt(bEnd - 1) == 0x20)) {
+ bEnd--;
+ }
+ if (start + bStart > offset || start + bEnd - 1 < offset) return null;
+
+ int elStart = sb.indexOf(EL_SHARP_PREFIX) == -1 ? sb.indexOf(EL_DOLLAR_PREFIX) :
sb.indexOf(EL_SHARP_PREFIX);
+ if (elStart != -1 && elStart >= bStart && elStart < bEnd) {
+ int elEnd = sb.indexOf(EL_SUFFIX, elStart);
+ bStart = (elEnd == -1 || elEnd > bEnd) ? bEnd : elEnd + 1;
+ }
+
//find start of bean property
while (bStart >= 0) {
if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
Show replies by date