Author: vrubezhny
Date: 2012-01-11 12:01:44 -0500 (Wed, 11 Jan 2012)
New Revision: 37772
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java
Log:
JBIDE-10572
NullPointerException in ClassHyperlink
Issue is fixed.
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java 2012-01-11
15:11:22 UTC (rev 37771)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java 2012-01-11
17:01:44 UTC (rev 37772)
@@ -95,6 +95,38 @@
if (propStart > offset || propStart + propLength < offset) return null;
+ // Check that text is a 'class name'
+ text = document.get(bStart + start, bEnd - bStart);
+ int positionInText = offset - start - bStart;
+ int classNameStart = positionInText;
+ while (classNameStart > 0 &&
!Character.isWhitespace(text.charAt(classNameStart))) {
+ classNameStart--;
+ }
+ boolean firstOrAfterDot = true;
+ int classNameEnd = classNameStart;
+ for (; classNameEnd < text.length(); classNameEnd++) {
+ if (Character.isWhitespace(text.charAt(classNameEnd)))
+ break; // End of class name
+ if ('.' == text.charAt(classNameEnd)) {
+ if (firstOrAfterDot) return null; // Double DOT or first char is DOT
+ firstOrAfterDot = true;
+ continue;
+ }
+
+ if (firstOrAfterDot) {
+ if (!Character.isJavaIdentifierStart(text.charAt(classNameEnd))) return null; // Not
Java Id-r start
+ firstOrAfterDot = false;
+ } else {
+ if (!Character.isJavaIdentifierPart(text.charAt(classNameEnd))) return null; // Not
Java Id-r part
+ }
+ }
+
+ String className = text.substring(classNameStart, classNameEnd).trim();
+ if (className.length() == 0 ||
+ className.startsWith(".") || //$NON-NLS-1$
+ className.endsWith(".")) { //$NON-NLS-1$
+ return null;
+ }
IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
return region;
} catch (BadLocationException x) {
Show replies by date