JBoss Tools SVN: r33605 - branches/jbosstools-3.2.x/ws/docs/reference/en-US/images.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-08-04 19:20:31 -0400 (Thu, 04 Aug 2011)
New Revision: 33605
Modified:
branches/jbosstools-3.2.x/ws/docs/reference/en-US/images/image-jbt-test_JAX-WS_04.png
Log:
updated for TOOLSDOC-233
Modified: branches/jbosstools-3.2.x/ws/docs/reference/en-US/images/image-jbt-test_JAX-WS_04.png
===================================================================
(Binary files differ)
14 years, 8 months
JBoss Tools SVN: r33604 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: src/org/jboss/tools/cdi/core/test/tck/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 16:47:47 -0400 (Thu, 04 Aug 2011)
New Revision: 33604
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
Log:
JBIDE-9452
https://issues.jboss.org/browse/JBIDE-9452
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java 2011-08-04 20:15:10 UTC (rev 33603)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java 2011-08-04 20:47:47 UTC (rev 33604)
@@ -6,7 +6,7 @@
public class TestNamed {
- @Inject String s; // OK//
+ @Inject String s; // Ambiguous
@Inject @Named String foo3; // OK
@Inject @Named("foo3") String s1; // OK
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 20:15:10 UTC (rev 33603)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 20:47:47 UTC (rev 33604)
@@ -12,8 +12,16 @@
package org.jboss.tools.cdi.core.test.tck.validation;
import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.core.IProducerField;
+import org.jboss.tools.cdi.core.IProducerMethod;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
@@ -50,8 +58,28 @@
}
public void testAmbiguousDependencyWithNamed() throws Exception {
- IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
+ String path = "JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java";
+ IFile file = tckProject.getFile(path);
AbstractResourceMarkerTest.assertMarkerIsCreated(file, CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 9, 25, 26);
+
+ IInjectionPointField p = getInjectionPointField(path, "s5");
+ Set<IBean> bs = cdiProject.getBeans(false, p);
+ assertEquals(4, bs.size());
+
+ Set<String> keys = new HashSet<String>();
+ for(IBean b: bs) {
+ keys.add(b.getSimpleJavaName());
+ }
+ assertTrue(keys.contains("TestNamed.foo4"));
+ assertTrue(keys.contains("TestNamed.foo4()"));
+ assertTrue(keys.contains("TestNamed.foo5()"));
+ assertTrue(keys.contains("TestNamed.foo6()"));
+
+ IInjectionPointParameter pp = getInjectionPointParameter(path, "doSmth");
+ Set<IBean> bs2 = cdiProject.getBeans(false, pp);
+ assertEquals(4, bs2.size());
+ bs2.removeAll(bs);
+ assertTrue(bs2.isEmpty());
}
/**
14 years, 8 months
JBoss Tools SVN: r33603 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: resources/tck/tests/jbt/lookup/duplicateName and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 16:15:10 -0400 (Thu, 04 Aug 2011)
New Revision: 33603
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestS.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
Log:
JBIDE-9452
https://issues.jboss.org/browse/JBIDE-9452
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java 2011-08-04 20:15:10 UTC (rev 33603)
@@ -0,0 +1,54 @@
+package org.jboss.jsr299.tck.tests.jbt.lookup.duplicateName;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class TestNamed {
+
+ @Inject String s; // OK//
+ @Inject @Named String foo3; // OK
+ @Inject @Named("foo3") String s1; // OK
+
+ @Inject @Named String xyz; // OK
+ @Inject @Named("xyz") String s2; // OK
+
+ @Inject @Named String abc; // OK
+ @Inject @Named("abc") String s3; // OK
+
+ @Inject @Named String foo; // OK
+ @Inject @Named("foo") String s4; // OK
+
+ @Inject @Named String unknownName; // Unsatisfied
+ @Inject @Named("unknownName") String unknownName1; // Unsatisfied
+
+ @Inject public void doSmth(@Named("foo4") String foo8) {} // Ambiguous: foo4, foo4(), foo5(), foo6()
+ @Inject @Named("foo4") String s5; // Ambiguous: foo4, foo4(), foo5(), foo6()
+
+ @Produces @TestS // OK
+ public String foo() {return "";}
+
+ @Produces @TestS @Named("abc") // OK
+ public String foo1;
+
+ @Produces @Named("xyz") // OK
+ public String foo2;
+
+ @Produces @Named // OK
+ public String foo3() {return "";}
+
+ @Produces @Named // Duplicate EL name
+ public String foo4() {return "";}
+
+ @Produces @Named("foo4") // Duplicate EL name
+ public String foo5() {return "";}
+
+ @Produces @TestS @Named("foo4") // Duplicate EL name
+ public String foo6() {return "";}
+
+ @Produces @TestS // Duplicate EL name
+ public String foo4;
+
+ @Produces // OK
+ public String foo7() {return "";}
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestNamed.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestS.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestS.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestS.java 2011-08-04 20:15:10 UTC (rev 33603)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.jbt.lookup.duplicateName;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+import javax.inject.Named;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@Named
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface TestS {
+
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/duplicateName/TestS.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 20:07:54 UTC (rev 33602)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 20:15:10 UTC (rev 33603)
@@ -49,6 +49,11 @@
AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 34);
}
+ public void testAmbiguousDependencyWithNamed() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 9, 25, 26);
+ }
+
/**
* 5.2.1. Unsatisfied and ambiguous dependencies
* - If an unsatisfied dependency exists, the container automatically detects the problem and treats it as a deployment problem.
@@ -62,6 +67,15 @@
AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 34);
}
+ public void testUnsatisfiedDependencyWithNamed() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 22, 23);
+ int[] lines = {10, 11, 13, 14, 16, 17};
+ for (int i: lines) {
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, i);
+ }
+ }
+
/**
* CDI validator should not complain if there ambiguous dependencies for @Inject Instance<[type]>
* See https://issues.jboss.org/browse/JBIDE-7949
14 years, 8 months
JBoss Tools SVN: r33602 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-08-04 16:07:54 -0400 (Thu, 04 Aug 2011)
New Revision: 33602
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
Log:
Added logging.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-08-04 20:02:29 UTC (rev 33601)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-08-04 20:07:54 UTC (rev 33602)
@@ -46,6 +46,7 @@
import org.jboss.tools.common.util.BeanUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
public abstract class RefactorSearcher {
protected static final String JAVA_EXT = "java"; //$NON-NLS-1$
@@ -248,7 +249,7 @@
InputStream is = file.getContents();
if(is != null) text = FileUtil.readStream(is);
} catch (CoreException e) {
- //ignore
+ WebKbPlugin.getDefault().logError(e);
}
if(text != null) {
boolean found = false;
14 years, 8 months
JBoss Tools SVN: r33601 - trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 16:02:29 -0400 (Thu, 04 Aug 2011)
New Revision: 33601
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
Log:
JBIDE-9453
https://issues.jboss.org/browse/JBIDE-9453
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 19:57:02 UTC (rev 33600)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-08-04 20:02:29 UTC (rev 33601)
@@ -207,6 +207,11 @@
AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Cod, Sole"), 21);
file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicateNameResolution/Sole.java");
AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Sole, Cod"), 21);
+
+ file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "TestNamed.foo4.*"), 40, 49);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "TestNamed.foo5.*"), 43);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "TestNamed.foo6.*"), 46);
}
/**
14 years, 8 months
JBoss Tools SVN: r33600 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-08-04 15:57:02 -0400 (Thu, 04 Aug 2011)
New Revision: 33600
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElServiceUtil.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ElPreferencesTestCase.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2594Test.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/RichFacesJBIDE1169Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-9449 : Provide possibility to change EL Service implementation
- Applied JBIDE-9449_20110804_2.patch provided by Vitali Yemialyanchyk and Maxim Areskau
- Added minor code changes to the patch
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -33,9 +33,9 @@
//we should register attributes only if we process this as custom component, but not when we open component definition page
if(!pageContext.getVisualBuilder().isCurrentMainDocument()){
String compositionCustomElementAttributeKey = Jsf2CustomComponentTemplate.JSF2_CUSTOM_COMPONENT_PARAMETR_KEY +name;
- if(pageContext.getCustomElementsAttributes().containsKey(compositionCustomElementAttributeKey)){
+ if(pageContext.containsAttributeInCustomElementsMap(compositionCustomElementAttributeKey)){
pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name,
- pageContext.getCustomElementsAttributes().get(compositionCustomElementAttributeKey));
+ pageContext.getAttributefromCustomElementsMapValue(compositionCustomElementAttributeKey));
}else if(sourceElement.hasAttribute(JSF.ATTR_DEFAULT)) {
String defaultValue = sourceElement.getAttribute(JSF.ATTR_DEFAULT);
pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name, defaultValue);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -31,6 +31,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ElServiceUtil;
import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.SourceDomUtil;
@@ -278,7 +279,7 @@
if (file == null)
return resolvedValue;
- resolvedValue = ElService.replaceEl(file, resolvedValue);
+ resolvedValue = ElServiceUtil.replaceEl(file, resolvedValue);
URI uri = null;
try {
@@ -584,7 +585,7 @@
||!(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage() instanceof IFile)) {
return;
}
- String path = ElService.replaceEl((IFile)pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage(), fileImageName);
+ String path = ElServiceUtil.replaceEl((IFile)pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage(), fileImageName);
File file = new File(inputPath.toOSString() + File.separator + path);
if (file.exists()) {
img.setAttribute(HTML.ATTR_SRC, HtmlComponentUtil.FILE_PROTOCOL + inputPath.toString() + "/" //$NON-NLS-1$
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ElPreferencesTestCase.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ElPreferencesTestCase.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ElPreferencesTestCase.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -13,7 +13,7 @@
import org.eclipse.core.runtime.CoreException;
-import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ElServiceUtil;
/**
* <p>
@@ -42,7 +42,7 @@
*/
public void testReplaceAttributeValue() throws CoreException {
String string1 = "#{beanA.property1}/images/smalle.gif"; //$NON-NLS-1$
- String replacedValue = ElService.replaceEl(file, string1);
+ String replacedValue = ElServiceUtil.replaceEl(file, string1);
assertEquals("Should be equals " + elValuesMap.get(KEY_1) + "/images/smalle.gif", replacedValue, elValuesMap.get(KEY_1) //$NON-NLS-1$ //$NON-NLS-2$
+ "/images/smalle.gif"); //$NON-NLS-1$
@@ -57,7 +57,7 @@
public void testReplaceAttributeValue2() throws CoreException {
String string1 = "#{beanA.property1}/images/#{beanA.property2}/path2/#{facesContext.requestPath}/smalle.gif"; //$NON-NLS-1$
- final String replacedValue = ElService.replaceEl(file, string1);
+ final String replacedValue = ElServiceUtil.replaceEl(file, string1);
final String check = elValuesMap.get(KEY_1) + "/images/" + elValuesMap.get(KEY_2) + "/path2/" + elValuesMap.get(KEY_3) //$NON-NLS-1$ //$NON-NLS-2$
+ "/smalle.gif"; //$NON-NLS-1$
assertEquals("Should be equals " + check, check, replacedValue); //$NON-NLS-1$
@@ -70,6 +70,6 @@
public void testReplaceNotInSet() {
String string1 = "#{requestScope}/smalle.gif"; //$NON-NLS-1$
- assertEquals("Should be equals", string1, ElService.replaceEl(file, string1)); //$NON-NLS-1$
+ assertEquals("Should be equals", string1, ElServiceUtil.replaceEl(file, string1)); //$NON-NLS-1$
}
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2594Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2594Test.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2594Test.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -21,7 +21,7 @@
import org.jboss.tools.common.el.core.GlobalELReferenceList;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.jsf.vpe.jsf.test.CommonJBIDE2010Test;
-import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ElServiceUtil;
/**
* Test case for testing global El expression substitution
@@ -67,7 +67,7 @@
public void testReplaceGlobalElVariable(){
String replaceString= "#{"+KEY_6+"}"+"images/test.gif"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- String replacedString = ElService.replaceEl(file, replaceString);
+ String replacedString = ElServiceUtil.replaceEl(file, replaceString);
assertEquals("Should be equals " + globalElMap.get(KEY_6) + "images/test.gif", replacedString, globalElMap.get(KEY_6) //$NON-NLS-1$ //$NON-NLS-2$
+ "images/test.gif"); //$NON-NLS-1$
@@ -80,7 +80,7 @@
*/
public void testOverrideLocalVariable() throws CoreException {
String string1 = "${" + KEY_1 + "}" + KEY_1_POSTFIX; //$NON-NLS-1$ //$NON-NLS-2$
- String replacedValue = ElService.replaceEl(file, string1);
+ String replacedValue = ElServiceUtil.replaceEl(file, string1);
assertEquals(elValuesMap.get(KEY_1) + KEY_1_POSTFIX, replacedValue);
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/RichFacesJBIDE1169Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/RichFacesJBIDE1169Test.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/RichFacesJBIDE1169Test.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -16,7 +16,7 @@
import org.jboss.tools.jsf.vpe.richfaces.test.RichFacesAllTests;
import org.jboss.tools.vpe.base.test.TestUtil;
import org.jboss.tools.vpe.base.test.VpeTest;
-import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ElServiceUtil;
/**
* @author mareshkau
@@ -48,7 +48,7 @@
}
public void testJBIDE1169() {
- String replacedValue = ElService.replaceEl(testFile,"#{"+RICH_FACES_SKIN_KEY+'}'); //$NON-NLS-1$
+ String replacedValue = ElServiceUtil.replaceEl(testFile,"#{"+RICH_FACES_SKIN_KEY+'}'); //$NON-NLS-1$
assertEquals("Skin value should be equals",SKIN_VALUE, replacedValue); //$NON-NLS-1$
}
/**
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -25,7 +25,6 @@
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.ElService;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.xpcom.XPCOMException;
@@ -74,7 +73,7 @@
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.isELNode(getPageContext(), sourceNode)) {
+ if (getPageContext().getElService().isELNode(sourceNode)) {
final Node sourceNodeProxy = VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
sourceNode);
try {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -56,11 +56,9 @@
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
import org.jboss.tools.vpe.editor.util.Docbook;
-import org.jboss.tools.vpe.editor.util.ElService;
import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
-import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.jboss.tools.vpe.resref.core.CSSReferenceList;
@@ -68,9 +66,6 @@
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDOMEventTarget;
-import org.mozilla.interfaces.nsIDOMNSEvent;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMText;
@@ -226,6 +221,7 @@
super.dispose();
pageContext.clearAll();
+ pageContext.resetElService();
// FIXED FOR JBIDE-3799 by sdzmitrovich, moved calling of this method to buid dom
// refreshExternalLinks();
pageContext.getBundle().refreshRegisteredBundles();
@@ -365,7 +361,7 @@
Node sourceNodeProxy = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.isELNode(getPageContext(), sourceNode)) {
+ if (getPageContext().getElService().isELNode(sourceNode)) {
sourceNodeProxy = VpeProxyUtil.createProxyForELExpressionNode(
getPageContext(), sourceNode);
try {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -12,8 +12,10 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Display;
@@ -31,6 +33,7 @@
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ElServiceUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.jboss.tools.vpe.resref.core.AbsoluteFolderReferenceList;
import org.jboss.tools.vpe.resref.core.RelativeFolderReferenceList;
@@ -48,6 +51,7 @@
public static final String CUSTOM_ELEMENTS_ATTRS = "customElementsAttributes"; //$NON-NLS-1$
public static final String CURRENT_VISUAL_NODE = "currentVisualNode"; //$NON-NLS-1$
public static final String RES_REFERENCES = "resourceReferences"; //$NON-NLS-1$
+ public static final String EL_EXPR_SERVICE = "elExprService"; //$NON-NLS-1$
private BundleMap bundle;
private VpeSourceDomBuilder sourceBuilder;
@@ -58,7 +62,13 @@
public VpePageContext(BundleMap bundle, VpeEditorPart editPart) {
this.bundle = bundle;
this.editPart = editPart;
+ resetElService();
}
+
+ public void resetElService() {
+ // set default el expression service
+ setElService(new ElService(this));
+ }
public VpeSourceDomBuilder getSourceBuilder() {
return sourceBuilder;
@@ -81,6 +91,22 @@
getCustomElementsAttributes().put(key, value);
}
+ public void removeAttributeFromCustomElementsMap(String key) {
+ getCustomElementsAttributes().remove(key);
+ }
+
+ public boolean containsAttributeInCustomElementsMap(String key) {
+ return getCustomElementsAttributes().containsKey(key);
+ }
+
+ public String getAttributefromCustomElementsMapValue(String key) {
+ return getCustomElementsAttributes().get(key);
+ }
+
+ public Set<String> getKeysCustomElementsAttributes() {
+ return new HashSet<String>(getCustomElementsAttributes().keySet());
+ }
+
/**
* Removes attribute from custom attribute map
*
@@ -112,8 +138,8 @@
final VpeIncludeInfo vii = visualBuilder.getCurrentIncludeInfo();
if (vii != null && (vii.getStorage() instanceof IFile)) {
final IFile file = (IFile)vii.getStorage();
- ResourceReference[] rr = ElService.getAllResources(file);
- rr = ElService.sortReferencesByScope2(rr);
+ ResourceReference[] rr = ElServiceUtil.getAllResources(file);
+ rr = ElServiceUtil.sortReferencesByScope2(rr);
putValue(RES_REFERENCES, rr);
}
}
@@ -254,6 +280,21 @@
}
/**
+ * @return the elService
+ */
+ public ElService getElService() {
+ return (ElService)getValue(EL_EXPR_SERVICE);
+ }
+
+ /**
+ * @param elService
+ * the elService to set
+ */
+ public void setElService(ElService elService) {
+ putValue(EL_EXPR_SERVICE, elService);
+ }
+
+ /**
* Processes display events to prevent eclipse froze
*/
public static void processDisplayEvents() {
@@ -271,7 +312,7 @@
* @return the customElementsAttributes
*/
@SuppressWarnings("unchecked")
- public Map<String, String> getCustomElementsAttributes() {
+ protected Map<String, String> getCustomElementsAttributes() {
Map<String, String> res = null;
Object obj = values.get(CUSTOM_ELEMENTS_ATTRS);
if (obj == null || !(obj instanceof HashMap)) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -13,7 +13,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.util.ElService;
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -59,7 +58,7 @@
* @return
*/
private String replaceEL(String toReplace) {
- return ElService.replaceElAndResources(pageContext, toReplace);
+ return pageContext.getElService().replaceElAndResources(toReplace);
}
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ELResolver.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -0,0 +1,201 @@
+/**
+ *
+ */
+package org.jboss.tools.vpe.editor.util;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.jst.jsp.bundle.BundleMapUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Class which for resolve EL Expressions
+ * @author mareshkau
+ *
+ */
+public class ELResolver {
+
+ protected VpePageContext pageContext;
+
+ public ELResolver(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
+
+ /**
+ * Replace el.
+ *
+ * @param pageContext
+ * @param resourceString
+ * the resource string
+ *
+ * @return the string
+ *
+ * @see IELService#replaceEl(IFile, String)
+ */
+ public String replaceEl(String resourceString) {
+ if (resourceString == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String rst = resourceString;
+ final ResourceReference[] references = getResourceReferences();
+ if (references == null || references.length == 0) {
+ return rst;
+ }
+ rst = ElServiceUtil.replace(resourceString, references);
+ return rst;
+ }
+
+ protected String replaceCustomAttributes(String value) {
+ String result = value;
+ final int nPrefLen = ElServiceUtil.getPrefLen(); // for small-simple optimization
+ for (String el : pageContext.getKeysCustomElementsAttributes()) {
+ if (el.length() + nPrefLen > result.length()) {
+ continue; // no sense for sequence contains checks...
+ }
+ final String dollarEl = ElServiceUtil.envelopeInDollarEl(el);
+ final String sharpEl = ElServiceUtil.envelopeInSharpEl(el);
+
+ if (result.contains(dollarEl)) {
+ result = result.replace(dollarEl, pageContext.getAttributefromCustomElementsMapValue(el));
+ }
+ if (result.contains(sharpEl)) {
+ result = result.replace(sharpEl, pageContext.getAttributefromCustomElementsMapValue(el));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Checks if is cloneable node.
+ *
+ * @param sourceNode
+ * the source node
+ * @param pageContext
+ * the page context
+ *
+ * @return true, if is cloneable node
+ */
+ public boolean isELNode(Node sourceNode) {
+ boolean rst = false;
+ if (isInCustomElementsAttributes(sourceNode)) {
+ return true;
+ }
+ if (isAvailableForNode(sourceNode)
+ || BundleMapUtil.isInResourcesBundle(pageContext.getBundle(), sourceNode)) {
+ rst = true;
+ } else if (Jsf2ResourceUtil.isContainJSFContextPath(sourceNode)) {
+ rst = true;
+ }
+ if (Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
+ // added by Maksim Areshkau, see JBIDE-4812
+ rst = true;
+ }
+ return rst;
+ }
+
+ /**
+ * Checks is node exist in source custom element attribute map and if so, then retrun true
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isInCustomElementsAttributes(Node sourceNode) {
+ boolean res = false;
+ String textValue = null;
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getNodeValue();
+ res = isInCustomElementsAttributes(textValue);
+ } else if (sourceNode.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attributesMap = sourceNode.getAttributes();
+ for (int i = 0; !res && i < attributesMap.getLength(); i++) {
+ Attr attr = (Attr) attributesMap.item(i);
+ textValue = attr.getValue();
+ res = isInCustomElementsAttributes(textValue);
+ }
+ }
+ return res;
+ }
+
+ protected boolean isInCustomElementsAttributes(String textValue) {
+ boolean res = false;
+ if (textValue != null) {
+ for (String key : pageContext.getKeysCustomElementsAttributes()) {
+ if (ElServiceUtil.equalsExppression(textValue, key)) {
+ res = true;
+ break;
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Checks if is available for node.
+ *
+ * @param resourceFile
+ * the resource file
+ * @param sourceNode
+ * the source node
+ *
+ * @return true, if is available for node
+ */
+ protected boolean isAvailableForNode(Node sourceNode) {
+ boolean rst = findForNode(sourceNode);
+ return rst;
+ }
+
+ /**
+ * @param sourceNode
+ * @param resourceFile
+ * @return
+ */
+ protected boolean findForNode(Node sourceNode) {
+ final ResourceReference[] references = getResourceReferences();
+ if (references == null || references.length == 0) {
+ return false;
+ }
+ String textValue = null;
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getNodeValue();
+ if (textValue != null && ElServiceUtil.isInReferenceResourcesList(references, textValue)) {
+ return true;
+ }
+ }
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+ if (nodeMap != null) {
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ if (ElServiceUtil.isInReferenceResourcesList(references, ((Attr) nodeMap.item(i)).getValue())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public ResourceReference[] getResourceReferences() {
+ final ResourceReference[] res = (ResourceReference[])pageContext.getValue(VpePageContext.RES_REFERENCES);
+ return res;
+ }
+
+ public String replaceElAndResources(String value) {
+ String rst = value;
+ rst = ResourceUtil.getBundleValue(pageContext, value);
+ // replace custom attributes
+ rst = replaceCustomAttributes(rst);
+ if (Jsf2ResourceUtil.isExternalContextPathString(value)) {
+ rst = Jsf2ResourceUtil.processExternalContextPath(value);
+ }
+ if (Jsf2ResourceUtil.isRequestContextPathString(value)) {
+ rst = Jsf2ResourceUtil.processRequestContextPath(value);
+ }
+ if (Jsf2ResourceUtil.isJSF2ResourceString(rst)) {
+ rst = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, rst);
+ }
+ rst = replaceEl(rst);
+ return rst;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -11,20 +11,8 @@
package org.jboss.tools.vpe.editor.util;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.common.el.core.ELReferenceList;
-import org.jboss.tools.common.el.core.GlobalELReferenceList;
import org.jboss.tools.common.resref.core.ResourceReference;
-import org.jboss.tools.jst.jsp.bundle.BundleMapUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
@@ -32,318 +20,44 @@
* @author Eugeny Stherbin
* @author Vitali Yemialyanchyk
*/
-public final class ElService {
+public class ElService {
- public static final String DOLLAR_PREFIX = "${"; //$NON-NLS-1$
-
- private static final String SUFFIX = "}"; //$NON-NLS-1$
-
- public static final String SHARP_PREFIX = "#{"; //$NON-NLS-1$
-
- /**
- * Replace el.
- *
- * @param resourceFile
- * the resource file
- * @param resourceString
- * the resource string
- *
- * @return the string
- *
- * @see IELService#replaceEl(IFile, String)
- */
- public static String replaceEl(IFile file, String resourceString) {
- if (resourceString == null) {
- return ""; //$NON-NLS-1$
- }
- String rst = resourceString;
- ResourceReference[] references = getAllResources(file);
- if (references == null || references.length == 0) {
- return rst;
- }
- references = sortReferencesByScope2(references);
- rst = replace(resourceString, references);
- return rst;
- }
-
- public static String replaceEl(VpePageContext pageContext, String resourceString) {
- if (resourceString == null) {
- return ""; //$NON-NLS-1$
- }
- String rst = resourceString;
- final ResourceReference[] references = getResourceReferences(pageContext);
- if (references == null || references.length == 0) {
- return rst;
- }
- rst = replace(resourceString, references);
- return rst;
- }
+ protected ELResolver elResolver;
- /**
- * Replace.
- *
- * @param resourceString
- * the resource string
- * @param references
- * the references
- *
- * @return the string
- */
- private static String replace(String resourceString, ResourceReference[] sortedReferences) {
- String result = resourceString;
- // Values with higher precedence should be replaced in the first place.
- // Expect sorted by scope references.
- final int nPrefLen = getPrefLen(); // for small-simple optimization
- for (ResourceReference rf : sortedReferences) {
- final String tmp = rf.getLocation();
- if (tmp.length() + nPrefLen > resourceString.length()) {
- continue; // no sense for sequence contains checks...
- }
- final String dollarEl = DOLLAR_PREFIX + tmp + SUFFIX;
- final String sharpEl = SHARP_PREFIX + tmp + SUFFIX;
- if (resourceString.contains(dollarEl)) {
- result = result.replace(dollarEl, rf.getProperties());
- }
- if (resourceString.contains(sharpEl)) {
- result = result.replace(sharpEl, rf.getProperties());
- }
- }
- return result;
+ public ElService(VpePageContext pageContext) {
+ elResolver = new ELResolver(pageContext);
}
- private static String replaceCustomAttributes(VpePageContext pageContext, String value) {
- String result = value;
- final int nPrefLen = getPrefLen(); // for small-simple optimization
- final Map<String, String> tmp = pageContext.getCustomElementsAttributes();
- for (String el : tmp.keySet()) {
- if (el.length() + nPrefLen > result.length()) {
- continue; // no sense for sequence contains checks...
- }
- final String dollarEl = DOLLAR_PREFIX + el + SUFFIX;
- final String sharpEl = SHARP_PREFIX + el + SUFFIX;
-
- if (result.contains(dollarEl)) {
- result = result.replace(dollarEl, tmp.get(el));
- }
- if (result.contains(sharpEl)) {
- result = result.replace(sharpEl, tmp.get(el));
- }
- }
- return result;
+ public String replaceEl(String resourceString) {
+ return getElResolver().replaceEl(resourceString);
}
- private static int getPrefLen() {
- int nPrefLen = DOLLAR_PREFIX.length();
- if (nPrefLen > SHARP_PREFIX.length()) {
- nPrefLen = SHARP_PREFIX.length();
- }
- nPrefLen += SUFFIX.length();
- return nPrefLen;
- }
-
/**
- * Creates a copy of {@code references} array and sorts its elements by scope value.
- *
- * References with the lowest scope value ({@link ResourceReference#FILE_SCOPE}) become the first in the array and
- * so on.
- *
- * @param references
- * array to be sorted
- * @return sorted copy of {@code references}
- * @author yradtsevich
- */
- public static ResourceReference[] sortReferencesByScope(ResourceReference[] references) {
- ResourceReference[] sortedReferences = references.clone();
- return sortReferencesByScope(sortedReferences);
- }
-
- public static ResourceReference[] sortReferencesByScope2(ResourceReference[] references) {
- Arrays.sort(references, new Comparator<ResourceReference>() {
- public int compare(ResourceReference r1, ResourceReference r2) {
- return r1.getScope() - r2.getScope();
- }
- });
- return references;
- }
-
- /**
* Checks if is cloneable node.
*
* @param sourceNode
* the source node
- * @param pageContext
- * the page context
*
* @return true, if is cloneable node
*/
- public static boolean isELNode(VpePageContext pageContext, Node sourceNode) {
- boolean rst = false;
- if (isInCustomElementsAttributes(pageContext, sourceNode)) {
- return true;
- }
- if (isAvailableForNode(pageContext, sourceNode)
- || BundleMapUtil.isInResourcesBundle(pageContext.getBundle(), sourceNode)) {
- rst = true;
- } else if (Jsf2ResourceUtil.isContainJSFContextPath(sourceNode)) {
- rst = true;
- }
- if (Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
- // added by Maksim Areshkau, see JBIDE-4812
- rst = true;
- }
- return rst;
+ public boolean isELNode(Node sourceNode) {
+ return getElResolver().isELNode(sourceNode);
}
- /**
- * Checks is node exist in source custom element attribute map and if so, then retrun true
- *
- * @param pageContext
- * @param sourceNode
- * @return
- */
- private static boolean isInCustomElementsAttributes(VpePageContext pageContext, Node sourceNode) {
- boolean res = false;
- String textValue = null;
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- textValue = sourceNode.getNodeValue();
- res = isInCustomElementsAttributes(pageContext, textValue);
- } else if (sourceNode.getNodeType() == Node.ELEMENT_NODE) {
- NamedNodeMap attributesMap = sourceNode.getAttributes();
- for (int i = 0; !res && i < attributesMap.getLength(); i++) {
- Attr attr = (Attr) attributesMap.item(i);
- textValue = attr.getValue();
- res = isInCustomElementsAttributes(pageContext, textValue);
- }
- }
- return res;
+ public ResourceReference[] getResourceReferences() {
+ return getElResolver().getResourceReferences();
}
- private static boolean isInCustomElementsAttributes(VpePageContext pageContext, String textValue) {
- boolean res = false;
- if (textValue != null) {
- for (String key : pageContext.getCustomElementsAttributes().keySet()) {
- if (equalsExppression(textValue, key)) {
- res = true;
- break;
- }
- }
- }
- return res;
+ public String replaceElAndResources(String value) {
+ return getElResolver().replaceElAndResources(value);
}
-
- /**
- * Checks if is available for node.
- *
- * @param resourceFile
- * the resource file
- * @param sourceNode
- * the source node
- *
- * @return true, if is available for node
- */
- private static boolean isAvailableForNode(VpePageContext pageContext, Node sourceNode) {
- boolean rst = findForNode(pageContext, sourceNode);
- return rst;
- }
-
- /**
- * @param sourceNode
- * @param resourceFile
- * @return
- */
- private static boolean findForNode(VpePageContext pageContext, Node sourceNode) {
- final ResourceReference[] references = getResourceReferences(pageContext);
- if (references == null || references.length == 0) {
- return false;
- }
- String textValue = null;
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- textValue = sourceNode.getNodeValue();
- if (textValue != null && isInReferenceResourcesList(references, textValue)) {
- return true;
- }
- }
- final NamedNodeMap nodeMap = sourceNode.getAttributes();
- if (nodeMap != null) {
- for (int i = 0; i < nodeMap.getLength(); i++) {
- if (isInReferenceResourcesList(references, ((Attr) nodeMap.item(i)).getValue())) {
- return true;
- }
- }
- }
- return false;
- }
- public static ResourceReference[] getResourceReferences(VpePageContext pageContext) {
- final ResourceReference[] res = (ResourceReference[])pageContext.getValue(VpePageContext.RES_REFERENCES);
- return res;
+ private ELResolver getElResolver() {
+ return elResolver;
}
-
- /**
- * Checks if is in reference resources list.
- *
- * @param value
- * the value
- * @param references
- * the references
- *
- * @return true, if is in reference resources list
- */
- private static boolean isInReferenceResourcesList(ResourceReference[] references, String value) {
- for (ResourceReference ref : references) {
- // FIXED FOR JBIDE-3149 by sdzmitrovich
- if (equalsExppression(value, ref.getLocation())) {
- return true;
- }
- }
- return false;
+ public void setElResolver(ELResolver elResolver) {
+ this.elResolver = elResolver;
}
- public static ResourceReference[] getAllResources(IFile resourceFile) {
- final IPath workspacePath = Platform.getLocation();
- final ResourceReference[] gResources = GlobalELReferenceList.getInstance().getAllResources(workspacePath);
- final ResourceReference[] elResources = ELReferenceList.getInstance().getAllResources(resourceFile);
-
- int size = (gResources == null ? 0 : gResources.length);
- size += (elResources == null ? 0 : elResources.length);
- ResourceReference[] rst = new ResourceReference[size];
-
- if ((gResources != null) && (gResources.length > 0)) {
- System.arraycopy(gResources, 0, rst, 0, gResources.length);
- }
- if ((elResources != null) && (elResources.length > 0)) {
- System.arraycopy(elResources, 0, rst, gResources == null ? 0 : gResources.length, elResources.length);
- }
- return rst;
-
- }
-
- public static String replaceElAndResources(VpePageContext pageContext, String value) {
- String rst = value;
- rst = ResourceUtil.getBundleValue(pageContext, value);
- // replace custom attributes
- rst = replaceCustomAttributes(pageContext, rst);
- if (Jsf2ResourceUtil.isExternalContextPathString(value)) {
- rst = Jsf2ResourceUtil.processExternalContextPath(value);
- }
- if (Jsf2ResourceUtil.isRequestContextPathString(value)) {
- rst = Jsf2ResourceUtil.processRequestContextPath(value);
- }
- if (Jsf2ResourceUtil.isJSF2ResourceString(rst)) {
- rst = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, rst);
- }
- rst = replaceEl(pageContext, rst);
- return rst;
- }
-
- private static boolean equalsExppression(String value, String expression) {
- final String dollarEl = DOLLAR_PREFIX + expression + SUFFIX;
- final String sharpEl = SHARP_PREFIX + expression + SUFFIX;
- if (value.contains(dollarEl) || value.contains(sharpEl)) {
- return true;
- }
- return false;
- }
-
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElServiceUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElServiceUtil.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElServiceUtil.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -0,0 +1,168 @@
+package org.jboss.tools.vpe.editor.util;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.el.core.ELReferenceList;
+import org.jboss.tools.common.el.core.GlobalELReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReference;
+
+public class ElServiceUtil {
+
+ public static final String DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+
+ public static final String SUFFIX = "}"; //$NON-NLS-1$
+
+ public static final String SHARP_PREFIX = "#{"; //$NON-NLS-1$
+
+ /**
+ * Replace el.
+ *
+ * @param resourceFile
+ * the resource file
+ * @param resourceString
+ * the resource string
+ *
+ * @return the string
+ *
+ * @see IELService#replaceEl(IFile, String)
+ */
+ public static String replaceEl(IFile file, String resourceString) {
+ if (resourceString == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String rst = resourceString;
+ ResourceReference[] references = getAllResources(file);
+ if (references == null || references.length == 0) {
+ return rst;
+ }
+ references = sortReferencesByScope2(references);
+ rst = replace(resourceString, references);
+ return rst;
+ }
+
+ /**
+ * Creates a copy of {@code references} array and sorts its elements by scope value.
+ *
+ * References with the lowest scope value ({@link ResourceReference#FILE_SCOPE}) become the first in the array and
+ * so on.
+ *
+ * @param references
+ * array to be sorted
+ * @return sorted copy of {@code references}
+ * @author yradtsevich
+ */
+ public static ResourceReference[] sortReferencesByScope(ResourceReference[] references) {
+ ResourceReference[] sortedReferences = references.clone();
+ return sortReferencesByScope(sortedReferences);
+ }
+
+ public static ResourceReference[] sortReferencesByScope2(ResourceReference[] references) {
+ Arrays.sort(references, new Comparator<ResourceReference>() {
+ public int compare(ResourceReference r1, ResourceReference r2) {
+ return r1.getScope() - r2.getScope();
+ }
+ });
+ return references;
+ }
+
+ public static ResourceReference[] getAllResources(IFile resourceFile) {
+ final IPath workspacePath = Platform.getLocation();
+ final ResourceReference[] gResources = GlobalELReferenceList.getInstance().getAllResources(workspacePath);
+ final ResourceReference[] elResources = ELReferenceList.getInstance().getAllResources(resourceFile);
+
+ int size = (gResources == null ? 0 : gResources.length);
+ size += (elResources == null ? 0 : elResources.length);
+ ResourceReference[] rst = new ResourceReference[size];
+
+ if ((gResources != null) && (gResources.length > 0)) {
+ System.arraycopy(gResources, 0, rst, 0, gResources.length);
+ }
+ if ((elResources != null) && (elResources.length > 0)) {
+ System.arraycopy(elResources, 0, rst, gResources == null ? 0 : gResources.length, elResources.length);
+ }
+ return rst;
+
+ }
+
+ /**
+ * Replace.
+ *
+ * @param resourceString
+ * the resource string
+ * @param references
+ * the references
+ *
+ * @return the string
+ */
+ public static String replace(String resourceString, ResourceReference[] sortedReferences) {
+ String result = resourceString;
+ // Values with higher precedence should be replaced in the first place.
+ // Expect sorted by scope references.
+ final int nPrefLen = getPrefLen(); // for small-simple optimization
+ for (ResourceReference rf : sortedReferences) {
+ final String tmp = rf.getLocation();
+ if (tmp.length() + nPrefLen > resourceString.length()) {
+ continue; // no sense for sequence contains checks...
+ }
+ final String dollarEl = envelopeInDollarEl(tmp);
+ final String sharpEl = envelopeInSharpEl(tmp);
+ if (resourceString.contains(dollarEl)) {
+ result = result.replace(dollarEl, rf.getProperties());
+ }
+ if (resourceString.contains(sharpEl)) {
+ result = result.replace(sharpEl, rf.getProperties());
+ }
+ }
+ return result;
+ }
+
+ public static int getPrefLen() {
+ int nPrefLen = DOLLAR_PREFIX.length();
+ if (nPrefLen > SHARP_PREFIX.length()) {
+ nPrefLen = SHARP_PREFIX.length();
+ }
+ nPrefLen += SUFFIX.length();
+ return nPrefLen;
+ }
+
+ public static boolean equalsExppression(String value, String expression) {
+ final String dollarEl = envelopeInDollarEl(expression);
+ final String sharpEl = envelopeInSharpEl(expression);
+ if (value.contains(dollarEl) || value.contains(sharpEl)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if is in reference resources list.
+ *
+ * @param value
+ * the value
+ * @param references
+ * the references
+ *
+ * @return true, if is in reference resources list
+ */
+ public static boolean isInReferenceResourcesList(ResourceReference[] references, String value) {
+ for (ResourceReference ref : references) {
+ // FIXED FOR JBIDE-3149 by sdzmitrovich
+ if (equalsExppression(value, ref.getLocation())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String envelopeInDollarEl(String str) {
+ return DOLLAR_PREFIX + str + SUFFIX;
+ }
+
+ public static String envelopeInSharpEl(String str) {
+ return SHARP_PREFIX + str + SUFFIX;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -80,7 +80,7 @@
final String attrName = "rendered"; //$NON-NLS-1$
Element tempElement = sourceNode;
if (sourceNode.hasAttribute(attrName)) {
- if (ElService.isELNode(pageContext, sourceNode)) {
+ if (pageContext.getElService().isELNode(sourceNode)) {
tempElement = (Element) VpeProxyUtil
.createProxyForELExpressionNode(pageContext, sourceNode);
}
@@ -117,7 +117,7 @@
if (node instanceof Element) {
String templateName = VpeTemplateManager.getInstance()
.getTemplateName(pageContext, node);
- return "f:facet".equals(templateName);
+ return "f:facet".equals(templateName); //$NON-NLS-1$
} else {
return false;
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2011-08-04 19:12:47 UTC (rev 33599)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2011-08-04 19:57:02 UTC (rev 33600)
@@ -777,7 +777,7 @@
String resolvedUrl = url.replaceFirst(
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}", Constants.EMPTY); //$NON-NLS-1$
- resolvedUrl = ElService.replaceEl(file, resolvedUrl);
+ resolvedUrl = ElServiceUtil.replaceEl(file, resolvedUrl);
URI uri = null;
try {
14 years, 8 months
JBoss Tools SVN: r33599 - trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 15:12:47 -0400 (Thu, 04 Aug 2011)
New Revision: 33599
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIBean.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java
Log:
JBIDE-9453
https://issues.jboss.org/browse/JBIDE-9453
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIBean.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIBean.java 2011-08-04 19:12:25 UTC (rev 33598)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIBean.java 2011-08-04 19:12:47 UTC (rev 33599)
@@ -105,7 +105,7 @@
}
@Override
- public ITextSourceReference getNameLocation() {
+ public ITextSourceReference getNameLocation(boolean stereotypeLocation) {
return null;
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java 2011-08-04 19:12:25 UTC (rev 33598)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIInjectionPoint.java 2011-08-04 19:12:47 UTC (rev 33599)
@@ -134,7 +134,8 @@
return null;
}
- public String getName() {
+ @Override
+ public String getBeanName() {
return null;
}
}
14 years, 8 months
JBoss Tools SVN: r33598 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 15:12:25 -0400 (Thu, 04 Aug 2011)
New Revision: 33598
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java
Log:
JBIDE-9453
https://issues.jboss.org/browse/JBIDE-9453
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java 2011-08-04 19:11:28 UTC (rev 33597)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactorContributionFactory.java 2011-08-04 19:12:25 UTC (rev 33598)
@@ -107,9 +107,12 @@
for(IBean bean : beans){
if(bean.getName() != null){
- ITextSourceReference location = bean.getNameLocation();
- if(selection.getOffset() >= location.getStartPosition() && (selection.getOffset()+selection.getLength()) <= (location.getStartPosition()+location.getLength()))
- return bean;
+ //Get @Named declared directly, or stereotype that declares @Named.
+ ITextSourceReference location = bean.getNameLocation(true);
+ if(location != null) {
+ if(selection.getOffset() >= location.getStartPosition() && (selection.getOffset()+selection.getLength()) <= (location.getStartPosition()+location.getLength()))
+ return bean;
+ }
}
}
14 years, 8 months
JBoss Tools SVN: r33597 - trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 15:11:28 -0400 (Thu, 04 Aug 2011)
New Revision: 33597
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NameDefinitionTest.java
Log:
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NameDefinitionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NameDefinitionTest.java 2011-08-04 19:11:05 UTC (rev 33596)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NameDefinitionTest.java 2011-08-04 19:11:28 UTC (rev 33597)
@@ -33,7 +33,7 @@
assertEquals("There should be the only bean with org.jboss.jsr299.tck.tests.definition.name.Moose type.", 1, beans.size());
IBean bean = beans.iterator().next();
assertEquals("Wrong EL name of org.jboss.jsr299.tck.tests.definition.name.Moose bean.", "aMoose", bean.getName());
- assertLocationEquals(bean.getNameLocation(), 918, 16);
+ assertLocationEquals(bean.getNameLocation(true), 918, 16);
}
/**
14 years, 8 months
JBoss Tools SVN: r33596 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-04 15:11:05 -0400 (Thu, 04 Aug 2011)
New Revision: 33596
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/EventBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
JBIDE-9453
https://issues.jboss.org/browse/JBIDE-9453
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -46,11 +46,13 @@
* Returns the location of a name declaration of this bean. If the bean
* doesn't have the name declaration then null will be returned. May be
* declared in a stereotype. May be a declaration of @Name annotation or
- * location of Java class name declaration.
+ * stereotype declaration if @Named is declared in that stereotype
+ * and parameter stereotypeLocation is true.
*
+ * @param stereotypeLocation
* @return the location of a name declaration of this bean.
*/
- ITextSourceReference getNameLocation();
+ ITextSourceReference getNameLocation(boolean stereotypeLocation);
/**
* Obtains the legal types of the bean class or producer method or field.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -77,5 +77,5 @@
*
* @return name declared by @Named or null if declaration is missing
*/
- public String getName();
+ public String getBeanName();
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -42,17 +42,6 @@
return (BeanMemberDefinition)definition;
}
- public String getName() {
- AnnotationDeclaration d = getDefinition().getNamedAnnotation();
- if(d != null) {
- Object n = d.getMemberValue(null);
- if(n != null) {
- return n.toString();
- }
- }
- return null;
- }
-
protected void setMember(IJavaElement member) {
try {
String returnType = null;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -357,7 +357,7 @@
}
boolean delegateInjectionPoint = injectionPoint.isDelegate();
- String injectionPointName = injectionPoint.getName();
+ String injectionPointName = injectionPoint.getBeanName();
for (IBean b: beans) {
if(b instanceof ClassBean && !(b instanceof IBuiltInBean)) {
@@ -385,7 +385,7 @@
if(delegateInjectionPoint && b == injectionPoint.getClassBean()) {
continue;
}
- if(injectionPointName != null && injectionPointName.equals(b.getName())) {
+ if(injectionPointName != null && !injectionPointName.equals(b.getName())) {
//
continue;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -351,8 +351,8 @@
return name;
}
- public ITextSourceReference getNameLocation() {
- return getDefinition().getNamedAnnotation();
+ public ITextSourceReference getNameLocation(boolean stereotypeLocation) {
+ return (stereotypeLocation) ? CDIUtil.getNamedDeclaration(this) : findNamedAnnotation();
}
public ClassBean getSpecializedBean() {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/EventBean.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/EventBean.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/EventBean.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -76,7 +76,7 @@
return null;
}
- public ITextSourceReference getNameLocation() {
+ public ITextSourceReference getNameLocation(boolean stereotypeLocation) {
return null;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -32,7 +32,8 @@
return super.getType();
}
- public String getName() {
+ @Override
+ public String getBeanName() {
AnnotationDeclaration d = getDefinition().getNamedAnnotation();
if(d != null) {
Object n = d.getMemberValue(null);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -51,4 +51,10 @@
public boolean hasDefaultQualifier() {
return CDIUtil.containsDefaultQualifier(this);
}
+
+ @Override
+ public String getBeanName() {
+ return null;
+ }
+
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -66,4 +66,16 @@
public boolean hasDefaultQualifier() {
return CDIUtil.containsDefaultQualifier(this);
}
+
+ @Override
+ public String getBeanName() {
+ AnnotationDeclaration d = getDefinition().getNamedAnnotation();
+ if(d != null) {
+ Object n = d.getMemberValue(null);
+ if(n != null && n.toString().length() > 0) {
+ return n.toString();
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IProducerField;
@@ -99,8 +100,8 @@
return getField().getElementName();
}
- public ITextSourceReference getNameLocation() {
- return findNamedAnnotation();
+ public ITextSourceReference getNameLocation(boolean stereotypeLocation) {
+ return (stereotypeLocation) ? CDIUtil.getNamedDeclaration(this) : findNamedAnnotation();
}
public IBean getSpecializedBean() {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IParameter;
import org.jboss.tools.cdi.core.IProducerMethod;
@@ -132,8 +133,8 @@
return name;
}
- public ITextSourceReference getNameLocation() {
- return findNamedAnnotation();
+ public ITextSourceReference getNameLocation(boolean stereotypeLocation) {
+ return (stereotypeLocation) ? CDIUtil.getNamedDeclaration(this) : findNamedAnnotation();
}
public void setSpecializedBean(ProducerMethod other) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -109,15 +109,22 @@
return;
}
- ITextSourceReference nameLocation = bean.getNameLocation();
+ //1. Get @Named declared directly, not in stereotype.
+ ITextSourceReference nameLocation = bean.getNameLocation(false);
+ //2. Get stereotype declaration declaring @Named, if @Named is not declared directly.
+ ITextSourceReference stereotypeLocation = nameLocation != null ? null : bean.getNameLocation(true);
- if(nameLocation == null){
+ if(nameLocation == null && stereotypeLocation == null) {
status.addFatalError(CDICoreMessages.CDI_RENAME_PROCESSOR_BEAN_HAS_NO_NAME_LOCATION);
return;
}
String newText = "@Named(\""+getNewName()+"\")"; //$NON-NLS-1$ //$NON-NLS-2$
- change(declarationFile, nameLocation.getStartPosition(), nameLocation.getLength(), newText);
+ if(nameLocation != null) {
+ change(declarationFile, nameLocation.getStartPosition(), nameLocation.getLength(), newText);
+ } else if(stereotypeLocation != null) {
+ change(declarationFile, stereotypeLocation.getStartPosition() + stereotypeLocation.getLength(), 0, " " + newText);
+ }
}
protected void renameBean(IProgressMonitor pm, IBean bean)throws CoreException{
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-08-04 17:58:27 UTC (rev 33595)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-08-04 19:11:05 UTC (rev 33596)
@@ -587,10 +587,7 @@
*/
Set<IBean> beans = cdiProject.getBeans(name, true);
if(beans.size()>1 && beans.contains(bean)) {
- ITextSourceReference reference = bean.getNameLocation();
- if(reference==null) {
- reference = CDIUtil.getNamedDeclaration(bean);
- }
+ ITextSourceReference reference = bean.getNameLocation(true);
Set<String> names = new HashSet<String>();
String bName = bean.getSimpleJavaName();
names.add(bName);
@@ -623,7 +620,7 @@
String yName = name.substring(xNameAsString.length()+1);
IStatus status = JavaConventions.validateJavaTypeName(yName, CompilerOptions.VERSION_1_6, CompilerOptions.VERSION_1_6);
if (status.getSeverity() != IStatus.ERROR) {
- ITextSourceReference reference = bean.getNameLocation();
+ ITextSourceReference reference = bean.getNameLocation(true);
if(reference==null) {
reference = CDIUtil.getNamedDeclaration(bean);
}
@@ -1071,7 +1068,7 @@
ITextSourceReference decoratorDeclaration = decorator.getDecoratorAnnotation();
if(decoratorDeclaration == null) {
//for custom implementations
- decoratorDeclaration = decorator.getNameLocation();
+ decoratorDeclaration = decorator.getNameLocation(true);
}
addError(CDIValidationMessages.DISPOSER_IN_DECORATOR, CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, decoratorDeclaration, bean
.getResource(), DISPOSER_IN_DECORATOR_ID);
@@ -1089,7 +1086,7 @@
ITextSourceReference interceptorDeclaration = interceptor.getInterceptorAnnotation();
if(interceptorDeclaration == null) {
//for custom implementations
- interceptorDeclaration = interceptor.getNameLocation();
+ interceptorDeclaration = interceptor.getNameLocation(true);
}
addError(CDIValidationMessages.DISPOSER_IN_INTERCEPTOR, CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, interceptorDeclaration, bean
.getResource(), DISPOSER_IN_INTERCEPTOR_ID);
@@ -1922,7 +1919,7 @@
}
if(declaration == null) {
//for custom implementations
- declaration = interceptor.getNameLocation();
+ declaration = interceptor.getNameLocation(true);
}
addError(CDIValidationMessages.INTERCEPTOR_IS_ALTERNATIVE, CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, declaration, interceptor
.getResource());
@@ -2010,7 +2007,7 @@
}
if(declaration == null) {
//for custom implementations
- declaration = decorator.getNameLocation();
+ declaration = decorator.getNameLocation(true);
}
addError(CDIValidationMessages.DECORATOR_IS_ALTERNATIVE, CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, declaration, decorator.getResource());
}
14 years, 8 months