Author: dazarov
Date: 2010-05-07 07:11:55 -0400 (Fri, 07 May 2010)
New Revision: 21951
Modified:
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ExpressionHyperlink.java
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/numberguess/web/giveup.jspx
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6179
Modified:
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ExpressionHyperlink.java
===================================================================
---
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ExpressionHyperlink.java 2010-05-07
11:09:41 UTC (rev 21950)
+++
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/ExpressionHyperlink.java 2010-05-07
11:11:55 UTC (rev 21951)
@@ -40,7 +40,10 @@
ELInvocationExpression invocationExpression =
JSPExprHyperlinkPartitioner.getInvocationExpression(eStructure.reference,
eStructure.expression, offset);
if(invocationExpression != null){
for(ELResolver resolver : context.getElResolvers()){
- ELResolution resolution = resolver.resolve(context, invocationExpression,
invocationExpression.getStartPosition());
+ ELResolution resolution = resolver.resolve(context, invocationExpression, offset);
+ if(resolution==null) {
+ return null;
+ }
ELSegment segment =
resolution.findSegmentByOffset(offset-eStructure.reference.getStartPosition());
if(segment != null){
if(segment instanceof JavaMemberELSegment){
Modified:
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
===================================================================
---
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2010-05-07
11:09:41 UTC (rev 21950)
+++
branches/jbosstools-3.1.x/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2010-05-07
11:11:55 UTC (rev 21951)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.text.ext.hyperlink;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.el.core.model.ELExpression;
@@ -26,6 +27,7 @@
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.jsf.text.ext.JSFExtensionsPlugin;
import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jst.web.kb.PageContextFactory;
@@ -36,10 +38,18 @@
public class JSPExprHyperlinkPartitioner extends AbstractHyperlinkPartitioner implements
IHyperlinkPartitionRecognizer, IExclusiblePartitionerRecognition {
public static final String JSP_EXPRESSION_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION"; //$NON-NLS-1$
public static final String EXPRESSION_PARTITION =
"org.jboss.tools.common.text.ext.jsp.EXPRESSION"; //$NON-NLS-1$
+ public static final String DOT_EXPRESSION_PARTITION =
"org.jboss.tools.common.text.ext.jsp.DOT_EXPRESSION"; //$NON-NLS-1$
+ private static final String DOT = ".";
+
private boolean jspExpression = false;
+
+ private boolean dotExpression = false;
protected String getPartitionType() {
+ if(dotExpression)
+ return DOT_EXPRESSION_PARTITION;
+
if(jspExpression)
return EXPRESSION_PARTITION;
else
@@ -72,18 +82,21 @@
private IHyperlinkRegion getRegion(IDocument document, final int offset) {
jspExpression = false;
+ dotExpression = false;
ELContext context = getELContext(document);
if(context != null){
ExpressionStructure eStructure = getExpression(context, offset);
if(eStructure != null){
ELInvocationExpression invocationExpression =
getInvocationExpression(eStructure.reference, eStructure.expression, offset);
if(invocationExpression != null){
- jspExpression = decide(context, eStructure.expression, invocationExpression,
offset-eStructure.reference.getStartPosition());
+ jspExpression = decide(context, eStructure.expression, invocationExpression,
offset-eStructure.reference.getStartPosition(), offset);
if(jspExpression){
IHyperlinkRegion region = new
HyperlinkRegion(invocationExpression.getStartPosition(), invocationExpression.getLength(),
null, null, null);
return region;
}
}
+ dotExpression = checkDot(document, offset, context, eStructure.expression,
invocationExpression, offset-eStructure.reference.getStartPosition());
+
IHyperlinkRegion region = new
HyperlinkRegion(eStructure.expression.getStartPosition(),
eStructure.expression.getLength(), null, null, null);
return region;
}
@@ -127,11 +140,14 @@
return null;
}
- public boolean decide(ELContext context, ELExpression expression, ELInvocationExpression
invocationExpression, int offset){
+ public boolean decide(ELContext context, ELExpression expression, ELInvocationExpression
invocationExpression, int offset, int globalOffset){
for(ELResolver resolver : context.getElResolvers()){
- ELResolution resolution = resolver.resolve(context, invocationExpression,
invocationExpression.getStartPosition());
+ ELResolution resolution = resolver.resolve(context, invocationExpression,
globalOffset);
+ if(resolution==null) {
+ return false;
+ }
ELSegment segment = resolution.findSegmentByOffset(offset);
- if(segment != null){
+ if(segment != null && segment.isResolved()){
if(segment instanceof JavaMemberELSegment){
JavaMemberELSegment javaSegment = (JavaMemberELSegment)segment;
if(javaSegment.getJavaElement() != null){
@@ -143,6 +159,21 @@
return false;
}
+ public boolean checkDot(IDocument document, int superOffset, ELContext context,
ELExpression expression, ELInvocationExpression invocationExpression, int offset){
+ try{
+ String text = document.get(superOffset, 1);
+ if(DOT.equals(text)){
+ if(decide(context, expression, invocationExpression, offset+1, superOffset+1))
+ return true;
+ else if(decide(context, expression, invocationExpression, offset-1, superOffset-1))
+ return true;
+ }
+ }catch(BadLocationException ex){
+ JSFExtensionsPlugin.log(ex);
+ }
+ return false;
+ }
+
/**
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
Modified:
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/numberguess/web/giveup.jspx
===================================================================
---
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/numberguess/web/giveup.jspx 2010-05-07
11:09:41 UTC (rev 21950)
+++
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/numberguess/web/giveup.jspx 2010-05-07
11:11:55 UTC (rev 21951)
@@ -2,6 +2,7 @@
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:rich="http://richfaces.org/rich"
xmlns="http://www.w3.org/1999/xhtml"
version="2.0">
<jsp:output doctype-root-element="html"
@@ -20,6 +21,9 @@
<h:outputText value="#{Message.info_start}" /><h:outputText
value="#{numberGuess.remainingGuesses}"/><h:outputText
value="#{Message.info_finish}" />
<h:commandButton value="#{Message.button_yes}"
action="yes"/>
<h:commandButton value="#{Message.button_no}"
action="no"/>
+ <rich:dataTable value="#{numberGuess.possibilities}"
var="_localVariable">
+ <h:outputText value="#{_localVariable.intValue}" />
+ </rich:dataTable>
</h:form>
</f:view>
</body>
Modified:
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java
===================================================================
---
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java 2010-05-07
11:09:41 UTC (rev 21950)
+++
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java 2010-05-07
11:11:55 UTC (rev 21951)
@@ -32,11 +32,11 @@
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.ui.internal.editor.EditorModelUtil;
-import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.AxisUtil;
import org.jboss.tools.jsf.text.ext.hyperlink.JSPExprHyperlinkPartitioner;
import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.TestProjectProvider;
public class ELExprPartitionerTest extends TestCase {
TestProjectProvider provider = null;
@@ -118,38 +118,30 @@
HashMap<Object, ArrayList<Region>> recognitionTest = new HashMap<Object,
ArrayList<Region>>();
ArrayList<Region> regionList = new ArrayList<Region>();
- regionList.add(new Region(623, 16));
- regionList.add(new Region(706, 16));
- regionList.add(new Region(813, 18));
- regionList.add(new Region(914, 19));
- regionList.add(new Region(972, 18));
- regionList.add(new Region(1041, 17));
+ regionList.add(new Region(673, 7));
+ regionList.add(new Region(680, 9));
+ regionList.add(new Region(756, 7));
+ regionList.add(new Region(763, 9));
+ regionList.add(new Region(863, 7));
+ regionList.add(new Region(870, 11));
+ regionList.add(new Region(964, 19));
+ regionList.add(new Region(1022, 18));
+ regionList.add(new Region(1091, 17));
recognitionTest.put("org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE",
regionList);
regionList = new ArrayList<Region>();
- regionList.add(new Region(859, 11));
- regionList.add(new Region(871, 16));
- recognitionTest.put("org.jboss.tools.common.text.ext.jsp.JSP_BEAN",
regionList);
+ regionList.add(new Region(920, 1));
+ regionList.add(new Region(1168, 1));
+ regionList.add(new Region(1251, 1));
+ recognitionTest.put("org.jboss.tools.common.text.ext.jsp.DOT_EXPRESSION",
regionList);
regionList = new ArrayList<Region>();
- regionList.add(new Region(859, 11));
- regionList.add(new Region(871, 16));
- recognitionTest.put("org.jboss.tools.seam.text.ext.SEAM_BEAN", regionList);
-
- regionList = new ArrayList<Region>();
- regionList.add(new Region(859, 11));
- regionList.add(new Region(870, 16));
- regionList.add(new Region(886, 1));
-
- recognitionTest.put("org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION",
regionList);
-
-// regionList = new ArrayList<Region>();
-// regionList.add(new Region(870, 16));
-// recognitionTest.put("org.eclipse.jst.jsp.SCRIPT.JSP_EL2", regionList);
-
- regionList = new ArrayList<Region>();
- regionList.add(new Region(859, 11));
- regionList.add(new Region(871, 16));
+ regionList.add(new Region(909, 11));
+ regionList.add(new Region(921, 16));
+ regionList.add(new Region(1157, 11));
+ regionList.add(new Region(1169, 13));
+ regionList.add(new Region(1237, 14));
+ regionList.add(new Region(1252, 8));
recognitionTest.put("org.jboss.tools.common.text.ext.jsp.EXPRESSION",
regionList);
int counter = 0;
@@ -216,7 +208,7 @@
}
}
- assertEquals("Wrong recognized region count: ", 132, counter);
+ assertEquals("Wrong recognized region count: ", 180, counter);
model.releaseFromEdit();
Modified:
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
===================================================================
---
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2010-05-07
11:09:41 UTC (rev 21950)
+++
branches/jbosstools-3.1.x/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2010-05-07
11:11:55 UTC (rev 21951)
@@ -17,7 +17,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(JsfTextExtAllTests.class.getName());
- //suite.addTest(ELExprPartitionerTest.suite());
+ suite.addTest(ELExprPartitionerTest.suite());
return suite;
}
}
\ No newline at end of file