Author: akazakov
Date: 2012-02-10 18:58:01 -0500 (Fri, 10 Feb 2012)
New Revision: 38634
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IProjectValidationContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-10872 EL incremental validation doesn't work for
complex ELs.
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2012-02-10
23:19:46 UTC (rev 38633)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2012-02-10
23:58:01 UTC (rev 38634)
@@ -18,6 +18,8 @@
import java.util.TreeSet;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -692,6 +694,18 @@
List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
for (TypeInfoCollector.MemberInfo mbr : members) {
if (mbr.getMemberType() == null) continue;
+ ICompilationUnit unit = mbr.getMemberType().getCompilationUnit();
+ if(unit!=null && unit.exists()) {
+ IResource resource;
+ try {
+ resource = unit.getCorrespondingResource();
+ if(resource!=null) {
+ segment.setResource(resource);
+ }
+ } catch (JavaModelException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+ }
TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed,
isStaticMethodsCollectingEnabled());
if (TypeInfoCollector.isNotParameterizedCollection(mbr) ||
TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
resolution.setMapOrCollectionOrBundleAmoungTheTokens(true);
@@ -893,7 +907,24 @@
String filter = expr.getMemberName();
if(filter == null) filter = ""; //$NON-NLS-1$
String presentationString = proposal.getPresentation();
-
+ //proposal.getMember().getSourceType().getCompilationUnit().getCorrespondingResource()
+ MemberInfo info = proposal.getMember();
+ if(info!=null) {
+ IType type = info.getSourceType();
+ if(type!=null) {
+ ICompilationUnit unit = type.getCompilationUnit();
+ if(unit!=null && unit.exists()) {
+ try {
+ IResource resource = unit.getCorrespondingResource();
+ if(resource!=null) {
+ segment.setResource(resource);
+ }
+ } catch (JavaModelException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
if(returnEqualedVariablesOnly) {
// This is used for validation.
if (presentationString.equals(filter)) {
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IProjectValidationContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IProjectValidationContext.java 2012-02-10
23:19:46 UTC (rev 38633)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IProjectValidationContext.java 2012-02-10
23:58:01 UTC (rev 38634)
@@ -117,6 +117,12 @@
void removeLinkedEl(String name, ELReference el);
/**
+ * Removes all the links between the EL and all the linked variable name.
+ * @param el
+ */
+ void removeLinkedEl(ELReference el);
+
+ /**
* Return ELs with given variable name
* @param variableName
* @return
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java 2012-02-10
23:19:46 UTC (rev 38633)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ELValidatorContext.java 2012-02-10
23:58:01 UTC (rev 38634)
@@ -82,6 +82,23 @@
}
public synchronized void removeLinkedEls(IFile resource) {
+ String name = resource.getFullPath().toString(); // Resource path is also a variable
name
+ Set<ELReference> linkedEls = elsByVariableName.remove(name);
+ if(linkedEls!=null ) {
+ modifications++;
+ for (ELReference el : linkedEls) {
+ Set<String> variableNames = variableNamesByEl.get(el);
+ if(variableNames!=null) {
+ if(variableNames.remove(name)) {
+ modifications++;
+ }
+ if(variableNames.isEmpty()) {
+ variableNamesByEl.remove(el);
+ }
+ }
+ }
+ }
+
Set<ELReference> els = elsByResource.get(resource.getFullPath());
if(els!=null) {
if(elsByResource.remove(resource.getFullPath()) != null) {
@@ -99,6 +116,25 @@
}
}
+ public synchronized void removeLinkedEl(ELReference el) {
+ Set<String> names = variableNamesByEl.remove(el);
+ if(names==null) {
+ return;
+ }
+ if(!names.isEmpty()) {
+ modifications++;
+ }
+ for (String name : names) {
+ Set<ELReference> els = elsByVariableName.get(name);
+ if(els!=null) {
+ els.remove(el);
+ if(els.isEmpty()) {
+ elsByVariableName.remove(name);
+ }
+ }
+ }
+ }
+
/**
* Removes link between EL and variable name.
* @param name
@@ -110,10 +146,10 @@
if(linkedEls.remove(el)) {
modifications++;
}
+ if(linkedEls.isEmpty()) {
+ elsByVariableName.remove(name);
+ }
}
- if(linkedEls.isEmpty()) {
- elsByVariableName.remove(name);
- }
// Remove link between EL and variable names.
Set<String> variableNames = variableNamesByEl.get(el);
@@ -121,10 +157,10 @@
if(variableNames.remove(name)) {
modifications++;
}
+ if(variableNames.isEmpty()) {
+ variableNamesByEl.remove(el);
+ }
}
- if(variableNames.isEmpty()) {
- variableNamesByEl.remove(el);
- }
}
/**
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java 2012-02-10
23:19:46 UTC (rev 38633)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/ProjectValidationContext.java 2012-02-10
23:58:01 UTC (rev 38634)
@@ -189,10 +189,15 @@
}
}
}
+ // Threat resource path as a variable name too.
+ Set<ELReference> els =
elLinks.getElsByVariableName(resource.getFullPath().toString());
+ if(els!=null) {
+ result.addAll(els);
+ }
if(oldVariableNamesForELValidation!=null) {
for (String oldName :oldVariableNamesForELValidation) {
if(!onlyChangedVariables || newNames==null || !newNames.contains(oldName)) {
- Set<ELReference> els = elLinks.getElsByVariableName(oldName);
+ els = elLinks.getElsByVariableName(oldName);
if(els!=null) {
result.addAll(els);
}
@@ -243,6 +248,14 @@
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.IProjectValidationContext#removeLinkedEl(org.jboss.tools.common.el.core.ELReference)
+ */
+ public void removeLinkedEl(ELReference el) {
+ elLinks.removeLinkedEl(el);
+ }
+
+ /*
+ * (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.validation.IValidationContext#getElsByVariableName(java.lang.String)
*/
public Set<ELReference> getElsByVariableName(String variableName) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-02-10
23:19:46 UTC (rev 38633)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-02-10
23:58:01 UTC (rev 38634)
@@ -193,6 +193,7 @@
if(i++>1000) {
break;
}
+ validationContext.removeLinkedEl(el);
elsToValidate.add(el);
}
}
@@ -319,6 +320,18 @@
if(elResolution==null) {
continue;
}
+// ELSegment previousSegment = null;
+ for (ELSegment segment : elResolution.getSegments()) {
+ IResource resource = segment.getResource();
+ if(resource instanceof IFile) {
+ validationContext.addLinkedEl(resource.getFullPath().toString(), elReference);
+// if(!segment.isResolved() && previousSegment!=null &&
previousSegment.isResolved() && previousSegment instanceof JavaMemberELSegment) {
+// IJavaElement element = ((JavaMemberELSegment)previousSegment).getJavaElement();
+// element
+// }
+ }
+// previousSegment = segment;
+ }
if(elResolution.isResolved()) {
resolution = elResolution;
break;