Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java5
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELValidationUtil.java80
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java35
3 files changed, 120 insertions, 0 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java
index 71ccead6b..7eecb4cc9 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELExpressionValidator.java
@@ -83,6 +83,11 @@ public class ELExpressionValidator
// some syntatical issue
if (expr.getLastToken().endColumn < _elText.trim().length()-1)
{
+ if (ELValidationUtil.isProjectEL22(_context) &&
+ _elText.trim().charAt(expr.getLastToken().endColumn) == '(')
+ {
+ return expr;
+ }
final int offset = _context.getDocumentPosition() + expr.getLastToken().endColumn;
final int length = _elText.trim().length() - expr.getLastToken().endColumn;
final Diagnostic diagnostic =
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELValidationUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELValidationUtil.java
new file mode 100644
index 000000000..dae7de38a
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/ELValidationUtil.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 Oracle Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Oracle Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsf.validation.internal.el;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
+import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
+
+/**
+ * Utility methods used during EL validation.
+ *
+ * @author ian.trimble@oracle.com
+ */
+public class ELValidationUtil {
+
+ /**
+ * Tests if the passed IResource instance's project has (at least) EL 2.2 on its runtime
+ * classpath.
+ *
+ * @param resource IResource instance to test.
+ * @return <code>true</code> if the project has (at least) EL 2.2 on it's runtime classpath,
+ * else <code>false</code>.
+ */
+ public static boolean isProjectEL22(final IResource resource) {
+ boolean isEL22 = false;
+ if (resource != null) {
+ final IProject project = resource.getProject();
+ if (project != null) {
+ final IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject != null) {
+ try {
+ final IType type = javaProject.findType("javax.el.ValueReference"); //$NON-NLS-1$
+ isEL22 = (type != null);
+ } catch (JavaModelException ignored) {
+ //ignore; isEL22 will remain false
+ }
+ }
+ }
+ }
+ return isEL22;
+ }
+
+ /**
+ * Tests if the project associated with the passed context has (at least) EL 2.2 on its runtime
+ * classpath.
+ *
+ * @param context IStructuredDocumentContext instance to test.
+ * @return <code>true</code> if the project has (at least) EL 2.2 on it's runtime classpath,
+ * else <code>false</code>.
+ */
+ public static boolean isProjectEL22(final IStructuredDocumentContext context) {
+ boolean isEL22 = false;
+ if (context != null) {
+ final IWorkspaceContextResolver resolver =
+ IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
+ if (resolver != null) {
+ final IResource resource = resolver.getResource();
+ if (resource != null) {
+ isEL22 = isProjectEL22(resource);
+ }
+ }
+ }
+ return isEL22;
+ }
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
index f30a5c445..a316ace4c 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/strategy/AttributeValidatingStrategy.java
@@ -32,6 +32,7 @@ import org.eclipse.jst.jsf.common.dom.AttrDOMAdapter;
import org.eclipse.jst.jsf.common.dom.AttributeIdentifier;
import org.eclipse.jst.jsf.common.dom.DOMAdapter;
import org.eclipse.jst.jsf.common.internal.types.CompositeType;
+import org.eclipse.jst.jsf.common.internal.types.IAssignable;
import org.eclipse.jst.jsf.common.internal.types.TypeComparator;
import org.eclipse.jst.jsf.common.internal.types.TypeComparatorDiagnosticFactory;
import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
@@ -65,6 +66,7 @@ import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage;
import org.eclipse.jst.jsf.validation.internal.AbstractXMLViewValidationStrategy;
import org.eclipse.jst.jsf.validation.internal.JSFValidationContext;
import org.eclipse.jst.jsf.validation.internal.el.ELExpressionValidator;
+import org.eclipse.jst.jsf.validation.internal.el.ELValidationUtil;
import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
@@ -407,6 +409,9 @@ AbstractXMLViewValidationStrategy
expectedType = maybeAddAlternativeTypes(
expectedType, exprType, elementAdapter,
attrAdapter);
+ if (ELValidationUtil.isProjectEL22(_validationContext.getFile())) {
+ expectedType = addEL22Alternatives(expectedType);
+ }
status = _typeComparator.calculateTypeCompatibility(
expectedType, exprType);
if (status.getSeverity() != Diagnostic.OK)
@@ -427,6 +432,36 @@ AbstractXMLViewValidationStrategy
}
}
+ private CompositeType addEL22Alternatives(final CompositeType expectedType) {
+ CompositeType type = expectedType;
+ if (expectedType != null) {
+ final int assignmentTypeMask = expectedType.getAssignmentTypeMask();
+ if ((assignmentTypeMask & IAssignable.ASSIGNMENT_TYPE_RHS) != 0 ||
+ assignmentTypeMask == IAssignable.ASSIGNMENT_TYPE_NONE) {
+ int assignmentType = IAssignable.ASSIGNMENT_TYPE_NONE;
+ if ((assignmentTypeMask & IAssignable.ASSIGNMENT_TYPE_RHS) != 0) {
+ assignmentType = IAssignable.ASSIGNMENT_TYPE_RHS;
+ }
+ final List<String> signatures = new ArrayList<String>();
+ for (final String signature: expectedType.getSignatures()) {
+ signatures.add(signature);
+ final List<String> methodSignatures = new ArrayList<String>();
+ for (int i = 0; i < 20; i++) {
+ final String methodSignature = Signature.createMethodSignature(
+ methodSignatures.toArray(new String[i]),
+ Signature.getElementType(signature));
+ signatures.add(methodSignature);
+ methodSignatures.add("Ljava.lang.String;"); //$NON-NLS-1$
+ }
+ }
+ type = new CompositeType(
+ signatures.toArray(new String[signatures.size()]),
+ assignmentType);
+ }
+ }
+ return type;
+ }
+
private boolean disableAlternativeTypes()
{
if (hasProperty(DISABLE_ALTERATIVE_TYPES_KEY))

Back to the top