Author: vrubezhny
Date: 2012-01-30 14:23:43 -0500 (Mon, 30 Jan 2012)
New Revision: 38293
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPCSSClassHyperlinkPartitioner.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleBasenameHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ConverterHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForIDHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForwardHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFContextParamLinkHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFJSPLinkHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLContextParamLinkHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLLinkHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPConverterHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForIDHyperlinkPartitioner.java
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/JSPLoadBundleHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPNavigationCaseHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPValidatorHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/LoadBundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/NavigationCaseHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/PropertyHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/RenderKitHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/TLDTagHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ValidatorHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLBundleBasenameHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLConverterHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLPropertyHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLRenderKitHyperlinkPartitioner.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/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleBasenameHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleBasenameHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleBasenameHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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,
@@ -114,8 +114,7 @@
}
return (resourceBundles.size() == 0 ?
- null : resourceBundles.toArray(new XModelObject[0]));
-
+ null : resourceBundles.toArray(new XModelObject[0]));
}
private String[] getBundles() {
@@ -248,11 +247,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundleBasename(fLastRegion);
+ String baseName = getBundleBasename(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
return MessageFormat.format(Messages.OpenBundle, baseName);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ConverterHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ConverterHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ConverterHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -16,20 +16,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.jboss.tools.common.model.XModel;
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.jsf.JSFModelPlugin;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jsf.text.ext.JSFTextExtMessages;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -58,7 +50,6 @@
}
private String getConverterID (IRegion region) {
- getRegion(region.getOffset());
String converterID = null;
if(getDocument() != null && region != null) {
try {
@@ -70,73 +61,16 @@
return converterID;
}
- IRegion fLastRegion = null;
- /**
- * @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();
- smw.init(getDocument());
- try {
- 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String converterId = getConverterID(fLastRegion);
+ String converterId = getConverterID(getHyperlinkRegion());
if (converterId == null)
return MessageFormat.format(Messages.OpenA, JSFTextExtMessages.Converter);
return MessageFormat.format(JSFTextExtMessages.OpenConverterForId, converterId);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForIDHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForIDHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForIDHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -21,13 +21,11 @@
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.jsf.text.ext.JSFExtensionsPlugin;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -123,121 +121,16 @@
return sb.substring(bStart, bEnd);
}
- IRegion fLastRegion = null;
- /**
- * @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;
-
- // Find an ID (suppose that there may be a list of commas-separated IDs)
- int bIdStart = offset;
- int bIdEnd = offset;
-
- //find start of bean property
- while (bIdStart >= propStart) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bIdStart - start)) &&
- sb.charAt(bIdStart - start) != ' ') {
- bIdStart++;
- break;
- }
-
- if (bIdStart == 0) break;
- bIdStart--;
- }
- // find end of bean property
- while (bIdEnd < propStart + propLength) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bIdEnd - start)) &&
- sb.charAt(bIdEnd - start) != ' ')
- break;
- bIdEnd++;
- }
-
- // Skip leading spaces
- while (bIdStart < bIdEnd) {
- if (Character.isJavaIdentifierPart(sb.charAt(bIdStart - start))) {
- break;
- }
-
- bIdStart++;
- }
-
- // Skip trailing spaces
- while (bIdEnd > bIdStart) {
- if (Character.isJavaIdentifierPart(sb.charAt(bIdEnd - 1 - start))) {
- break;
- }
-
- bIdEnd--;
- }
-
- int idStart = bIdStart;
- int idLength = bIdEnd - bIdStart;
-
- if (idStart > offset || idStart + idLength < offset) return null;
-
-
-
- return new Region(idStart,idLength);
- } catch (BadLocationException x) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- 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.Id);
return MessageFormat.format(Messages.BrowseForId, forId);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForwardHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForwardHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ForwardHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -75,26 +75,16 @@
return super.getFileFromProject(fileName);
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = JSPForwardHyperlinkPartitioner.getRegion(getDocument(), offset);
- return fLastRegion;
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String filePath = getFilePath(fLastRegion);
+ String filePath = getFilePath(getHyperlinkRegion());
if (filePath == null)
return MessageFormat.format(Messages.OpenA, Messages.File);
return MessageFormat.format(Messages.OpenFile, filePath);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFContextParamLinkHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFContextParamLinkHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFContextParamLinkHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,92 +1,19 @@
/*******************************************************************************
- * 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.jsf.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.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
-
/**
* @author Jeremy
*
*/
public class JSFContextParamLinkHyperlink extends JSFLinkHyperlink {
- 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)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- 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
- int bEnd = offset - start;
- 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++;
- }
-
- 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFJSPLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFJSPLinkHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFJSPLinkHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -14,12 +14,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
-
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
-import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
public class JSFJSPLinkHyperlinkPartitioner extends JSPLinkHyperlinkPartitioner {
public static final String JSF_JSP_LINK_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSF_JSP_LINK"; //$NON-NLS-1$
@@ -64,8 +63,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) {
- return recognizeNature(document) ? super.recognize(document, region) : false;
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ return recognizeNature(document) ? super.recognize(document, offset, region) : false;
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLContextParamLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLContextParamLinkHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLContextParamLinkHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -15,20 +15,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import
org.jboss.tools.common.text.ext.hyperlink.xml.XMLContextParamLinkHyperlinkPartitioner;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jsf.project.JSFNature;
+import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-import org.jboss.tools.jsf.project.JSFNature;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
-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.XMLContextParamLinkHyperlinkPartitioner;
-
/**
* @author Jeremy
*/
@@ -82,7 +80,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 (!recognizeNature(document))
return false;
@@ -92,7 +90,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 Text)) return false;
@@ -142,5 +140,4 @@
smw.dispose();
}
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLLinkHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSFXMLLinkHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -14,12 +14,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
-
-import org.jboss.tools.jsf.project.JSFNature;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.xml.XMLLinkHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.jsf.project.JSFNature;
+import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
/**
* @author Jeremy
@@ -30,7 +29,6 @@
private String[] JSF_PROJECT_NATURES = {
JSFNature.NATURE_ID
};
-
/**
* @see
org.jboss.tools.common.text.ext.hyperlink.XMLLinkHyperlinkPartitioner#getPartitionType()
@@ -42,7 +40,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) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -64,5 +62,4 @@
smw.dispose();
}
}
-
}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPCSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPCSSClassHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPCSSClassHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,121 +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.jsf.text.ext.hyperlink;
-
-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.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
-
-/**
- *
- * @deprecated see
org.jboss.tools.common.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) {
- if(document == null || superRegion == null) return null;
-
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(document);
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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 > offset) return null;
-
- String attrText = document.get(start, end - start);
- StringBuffer sb = new StringBuffer(attrText);
-
- 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
-
- }
-
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPConverterHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPConverterHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPConverterHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,28 +1,27 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -33,7 +32,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();
@@ -42,18 +41,15 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ Utils.findNodeForOffset(xmlDocument, offset);
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_CONVERTER_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();
}
@@ -113,7 +109,5 @@
} finally {
smw.dispose();
}
-
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForIDHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForIDHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForIDHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,29 +1,27 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -34,25 +32,22 @@
/**
* @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;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ Utils.findNodeForOffset(xmlDocument, offset);
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSP_FOR_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();
}
@@ -147,24 +142,17 @@
bIdEnd--;
}
-
int idStart = bIdStart;
int idLength = bIdEnd - bIdStart;
-
if (idStart > offset || idStart + idLength < offset) return null;
-
-
- IHyperlinkRegion region = new HyperlinkRegion(idStart, idLength, null, null, null);
- return region;
+ return new HyperlinkRegion(idStart, idLength, null, null, null);
} catch (BadLocationException x) {
JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
return null;
} finally {
smw.dispose();
}
-
}
-
}
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-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPForwardHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,31 +1,29 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.Element;
-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.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -36,25 +34,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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_FORWARD_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();
}
@@ -115,7 +109,6 @@
} finally {
smw.dispose();
}
-
}
/**
@@ -164,5 +157,4 @@
smw.dispose();
}
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPLoadBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPLoadBundleHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPLoadBundleHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,31 +1,30 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.Element;
-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.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -40,27 +39,22 @@
/**
* @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;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-
- if (!recognize(document, superRegion)) return null;
- IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ if (!recognize(document, offset, superRegion)) return null;
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = getPartitionType();
- 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();
}
@@ -124,23 +118,22 @@
} 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();
smw.init(document);
try {
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;
- IHyperlinkRegion r = getRegion(document, region.getOffset());
+ IHyperlinkRegion r = getRegion(document, offset);
if (r == null) return false;
Attr attr = (Attr)n;
@@ -154,7 +147,7 @@
String usedPrefix = name.substring(0, column);
if (usedPrefix == null || usedPrefix.trim().length() == 0) return false;
- String[] prefixes = getLoadBundleTagPrefixes(document, region.getOffset());
+ String[] prefixes = getLoadBundleTagPrefixes(document, offset);
if (prefixes == null) return true; //xhtml
boolean prefixIsAbleToBeUsed = false;
@@ -188,5 +181,4 @@
return new String[] {tmw.getCorePrefix()};
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPNavigationCaseHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPNavigationCaseHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPNavigationCaseHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,29 +1,27 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -34,25 +32,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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_NAVIGATION_CASE_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();
}
@@ -73,7 +67,6 @@
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
if (n == null || !(n instanceof Attr)) return null;
int start = Utils.getValueStart(n);
@@ -102,18 +95,14 @@
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;
+ return new HyperlinkRegion(propStart, propLength, null, null, null);
} catch (BadLocationException x) {
JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
return null;
} finally {
smw.dispose();
}
-
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPValidatorHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPValidatorHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPValidatorHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -14,17 +14,16 @@
import org.eclipse.jface.text.IDocument;
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.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.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -35,25 +34,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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_VALIDATOR_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();
}
@@ -102,8 +97,7 @@
bEnd++;
final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
+ final int propLength = bEnd - bStart;
if (propStart > offset || propStart + propLength < offset) return null;
return new Region(propStart,propLength);
@@ -113,6 +107,5 @@
} finally {
smw.dispose();
}
-
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -15,29 +15,23 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jsf.text.ext.JSFTextExtMessages;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
*/
public class JsfJSPTagAttributeHyperlink extends AbstractHyperlink {
-
/**
* @see AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
@@ -63,7 +57,6 @@
}
}
-
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
@@ -144,15 +137,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
private String getTagAttributeName(IRegion region) {
if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
@@ -172,66 +156,17 @@
}
}
-
- 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 Attr || n instanceof Text)) return null;
- IDOMNode node = (IDOMNode)n;
- int start =node.getStartOffset();
- int end = node.getEndOffset();
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
- String attrName = getTagAttributeName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
+ String attrName = getTagAttributeName(getHyperlinkRegion());
if (tagName == null || attrName == null)
return JSFTextExtMessages.OpenTagLibraryForAnAttribute;
return MessageFormat.format(JSFTextExtMessages.OpenTagLibraryForAttributeName,
attrName, tagName);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagAttributeHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -22,11 +22,11 @@
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.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -45,25 +45,22 @@
/**
* @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;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IRegion r = getRegion(document, superRegion.getOffset());
+ Utils.findNodeForOffset(xmlDocument, offset);
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSF_JSP_TAG_ATTRIBUTE_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();
}
@@ -72,7 +69,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) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
@@ -153,5 +150,4 @@
}
return superRegion.getAxis();
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -41,11 +41,10 @@
* @author Jeremy
*/
public class JsfJSPTagNameHyperlink extends AbstractHyperlink {
- private IRegion fLastRegion = null;
-
public JsfJSPTagNameHyperlink(IRegion region){
- fLastRegion = region;
+ setRegion(region);
}
+
/**
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
@@ -118,7 +117,6 @@
error = "Component " + tagName + " not found in library " +
p.getProperty("prefix");
}
return error;
-
}
protected Properties getRequestProperties(IRegion region) {
@@ -186,24 +184,16 @@
}
}
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- return fLastRegion;
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
if (tagName == null)
return JSFTextExtMessages.OpenTagLibraryForATag;
return MessageFormat.format(JSFTextExtMessages.OpenTagLibraryForTagName, tagName);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPTagNameHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -17,11 +17,6 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.jsf.project.JSFNature;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
@@ -29,7 +24,11 @@
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.jsf.project.JSFNature;
+import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -44,25 +43,22 @@
/**
* @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;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IRegion r = getRegion(document, superRegion.getOffset());
+ Utils.findNodeForOffset(xmlDocument, offset);
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = JSF_JSP_TAG_NAME_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();
}
@@ -71,7 +67,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) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -122,7 +118,6 @@
} finally {
smw.dispose();
}
-
}
protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
@@ -131,5 +126,4 @@
}
return superRegion.getAxis();
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -15,8 +15,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
@@ -27,7 +25,6 @@
import org.jboss.tools.jst.web.tld.TaglibMapping;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class JsfJSPXmlNsHyperlink extends XModelBasedHyperlink {
@@ -83,38 +80,13 @@
return p;
}
- protected IRegion getRegion(final 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 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")) return null; //$NON-NLS-1$
-
- 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/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPXmlNsHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,34 +1,35 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+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.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class JsfJSPXmlNsHyperlinkPartitioner extends
JSPTagAttributeValueHyperlinkPartitioner {
-
public static final String JSF_JSP_XMLNS_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSF_JSP_XMLNS"; //$NON-NLS-1$
private String[] JSF_PROJECT_NATURES = {
@@ -45,7 +46,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 (!recognizeNature(document))
return false;
@@ -55,7 +56,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)) return false;
Attr xmlnsAttr = (Attr)n;
if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return false; //$NON-NLS-1$
@@ -95,27 +96,49 @@
public IRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
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")) return null; //$NON-NLS-1$
- if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if (n == null) return null;
+ final int taglibLength = xmlnsAttr.getValueRegionText().length();
+ final int taglibOffset = xmlnsAttr.getValueRegionStartOffset();
- final int propStart = Utils.getValueStart(n);
- final int propLength = Utils.getValueEnd(n) - propStart;
+ String text = document.get(taglibOffset, taglibLength);
+ 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 + taglibOffset;
+ final int propLength = bEnd - bStart;
if (propStart > offset || propStart + propLength < offset) return null;
-
+
return new Region(propStart,propLength);
+ } catch (BadLocationException e) {
+ return null;
} finally {
smw.dispose();
}
-
}
-
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -14,7 +14,6 @@
import java.util.Properties;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -69,44 +68,16 @@
return p;
}
- protected IRegion getRegion(final 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 Attr || n instanceof Node)) return null;
-
- if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if ((n == null) || !(n instanceof Node)) return null;
-
- final int propStart = Utils.getValueStart(n);
- if(propStart < 0) return null;
- final int propLength = Utils.getValueEnd(n) - propStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- return new Region(propStart,propLength);
- } 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);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfTaglibDirectiveHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -16,17 +16,15 @@
import org.eclipse.jface.text.IDocument;
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.jboss.tools.jsf.project.JSFNature;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
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.jsf.project.JSFNature;
+import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -39,7 +37,6 @@
private String[] JSF_PROJECT_NATURES = {
JSFNature.NATURE_ID
};
-
/**
* @see
org.jboss.tools.common.text.ext.hyperlink.JSPTagAttributeValueHyperlinkPartitioner#getPartitionType()
@@ -51,7 +48,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 (!recognizeNature(document))
return false;
@@ -61,7 +58,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 == null) return false;
@@ -123,7 +120,5 @@
} finally {
smw.dispose();
}
-
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/LoadBundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/LoadBundleHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/LoadBundleHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -19,9 +19,9 @@
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
@@ -129,7 +129,7 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundleBasename(fLastRegion);
+ String baseName = getBundleBasename(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
@@ -161,5 +161,4 @@
}
return null;
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/NavigationCaseHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/NavigationCaseHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/NavigationCaseHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -59,15 +59,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = JSPNavigationCaseHyperlinkPartitioner.getRegion(getDocument(), offset);
- return fLastRegion;
- }
-
/*
* (non-Javadoc)
*
@@ -76,5 +67,4 @@
public String getHyperlinkText() {
return MessageFormat.format(Messages.BrowseFor, JSFTextExtMessages.NavigationRule);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/PropertyHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/PropertyHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/PropertyHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -15,7 +15,6 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
@@ -24,7 +23,6 @@
import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jsf.text.ext.JSFTextExtMessages;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -62,15 +60,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
private String getPropertyName(IRegion region) {
if(getDocument() == null || region == null) return null;
try {
@@ -130,53 +119,6 @@
}
}
- 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 == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String trimQuotes(String word) {
String attrText = word;
int bStart = 0;
@@ -203,12 +145,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String beanClassName = getBeanClassName(fLastRegion);
- String propertyName = getPropertyName(fLastRegion);
+ String beanClassName = getBeanClassName(getHyperlinkRegion());
+ String propertyName = getPropertyName(getHyperlinkRegion());
if (beanClassName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, JSFTextExtMessages.BeanProperty);
return MessageFormat.format(JSFTextExtMessages.OpenBeanProperty, beanClassName,
propertyName);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/RenderKitHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/RenderKitHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/RenderKitHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -15,19 +15,12 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.jboss.tools.common.model.XModel;
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.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jsf.text.ext.JSFTextExtMessages;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -49,7 +42,7 @@
}
WebPromptingProvider provider = WebPromptingProvider.getInstance();
- String beanName = getBeanName(getRegion(region.getOffset()));
+ String beanName = getBeanName(getHyperlinkRegion());
Properties p = new Properties();
provider.getList(xModel, WebPromptingProvider.JSF_OPEN_RENDER_KIT, beanName, p);
@@ -69,62 +62,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @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();
- smw.init(getDocument());
- try {
- 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 class 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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String trimQuotes(String word) {
String attrText = word;
int bStart = 0;
@@ -151,11 +88,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String renderKitName = getBeanName(fLastRegion);
+ String renderKitName = getBeanName(getHyperlinkRegion());
if (renderKitName == null)
return MessageFormat.format(Messages.OpenA, JSFTextExtMessages.RenderKit);
return MessageFormat.format(JSFTextExtMessages.OpenRenderKit, renderKitName);
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/TLDTagHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/TLDTagHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/TLDTagHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2011 Exadel, Inc. and 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,
* 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.jsf.text.ext.hyperlink;
@@ -30,11 +30,10 @@
protected XModelObject xmodelObject;
protected String xmodelObjectName = null;
protected IFile file = null;
- protected IRegion region;
public TLDTagHyperlink(AbstractComponent tag, IRegion region){
this.tag = tag;
- this.region = region;
+ setRegion(region);
file = getFile(tag);
@@ -89,10 +88,6 @@
return tag;
}
- protected IRegion doGetHyperlinkRegion(int offset) {
- return region;
- }
-
@Override
protected void doHyperlink(IRegion region) {
if(xmodelObjectName != null){
@@ -119,5 +114,4 @@
else
return NLS.bind(JSFTextExtMessages.Open, "");
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ValidatorHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ValidatorHyperlink.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ValidatorHyperlink.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -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.jsf.text.ext.hyperlink;
@@ -16,19 +16,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.jboss.tools.common.model.XModel;
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.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jsf.text.ext.JSFTextExtMessages;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -52,7 +45,7 @@
WebPromptingProvider provider = WebPromptingProvider.getInstance();
- String validatorID = getValidatorId(getRegion(region.getOffset()));
+ String validatorID = getValidatorId(getHyperlinkRegion());
if (validatorID == null) {
openFileFailed();
return;
@@ -76,74 +69,16 @@
}
}
-
- IRegion fLastRegion = null;
- /**
- * @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) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String validatorId = getValidatorId(fLastRegion);
+ String validatorId = getValidatorId(getHyperlinkRegion());
if (validatorId == null)
return MessageFormat.format(Messages.OpenA, JSFTextExtMessages.Validator);
return MessageFormat.format(JSFTextExtMessages.OpenValidatorForId, validatorId);
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLBundleBasenameHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLBundleBasenameHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLBundleBasenameHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,27 +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.jsf.text.ext.hyperlink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
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.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -32,25 +31,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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 = XML_BUNDLE_BASENAME_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();
}
@@ -115,7 +110,5 @@
} finally {
smw.dispose();
}
-
}
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLConverterHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLConverterHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLConverterHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,27 +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.jsf.text.ext.hyperlink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
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.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -32,25 +31,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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 = XML_CONVERTER_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();
}
@@ -79,7 +74,6 @@
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
if (n == null || !(n instanceof Text)) return null;
int start = Utils.getValueStart(n);
@@ -113,7 +107,5 @@
} finally {
smw.dispose();
}
-
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLPropertyHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLPropertyHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,29 +1,27 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.w3c.dom.Text;
-
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.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -34,25 +32,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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 = XML_PROPERTY_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();
}
@@ -81,7 +75,6 @@
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);
@@ -120,5 +113,4 @@
smw.dispose();
}
}
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLRenderKitHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLRenderKitHyperlinkPartitioner.java 2012-01-30
19:22:30 UTC (rev 38292)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/XMLRenderKitHyperlinkPartitioner.java 2012-01-30
19:23:43 UTC (rev 38293)
@@ -1,28 +1,27 @@
/*******************************************************************************
- * 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.jsf.text.ext.hyperlink;
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.w3c.dom.Text;
-
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.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -33,25 +32,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();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- 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 = XML_RENDER_KIT_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();
}
@@ -77,7 +72,6 @@
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);
@@ -116,4 +110,4 @@
smw.dispose();
}
}
-}
+}
\ No newline at end of file