Author: scabanovich
Date: 2007-10-17 09:44:03 -0400 (Wed, 17 Oct 2007)
New Revision: 4289
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextShortVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamContextShortVariable.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
Log:
JBIDE-1075
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextShortVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextShortVariable.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextShortVariable.java 2007-10-17
13:44:03 UTC (rev 4289)
@@ -0,0 +1,5 @@
+package org.jboss.tools.seam.core;
+
+public interface ISeamContextShortVariable extends ISeamContextVariable {
+ public ISeamContextVariable getOriginal();
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-10-17
13:22:23 UTC (rev 4288)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-10-17
13:44:03 UTC (rev 4289)
@@ -146,6 +146,13 @@
public Set<ISeamContextVariable> getVariables();
/**
+ * Adds references to variables that provide short name if
+ * seam package including the original variable is imported.
+ * @return all seam context variables of project
+ */
+ public Set<ISeamContextVariable> getVariables(boolean includeShortNames);
+
+ /**
* @param name
* @return all seam variables by name from all contexts
*/
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamContextShortVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamContextShortVariable.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamContextShortVariable.java 2007-10-17
13:44:03 UTC (rev 4289)
@@ -0,0 +1,37 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.jboss.tools.seam.core.ISeamContextShortVariable;
+import org.jboss.tools.seam.core.ISeamContextVariable;
+import org.jboss.tools.seam.core.ScopeType;
+
+public class SeamContextShortVariable extends SeamObject implements
ISeamContextShortVariable {
+ ISeamContextVariable original;
+
+ public SeamContextShortVariable(ISeamContextVariable original) {
+ this.original = original;
+ }
+
+ public ISeamContextVariable getOriginal() {
+ return original;
+ }
+
+ public String getName() {
+ String n = original.getName();
+ int i = n.lastIndexOf('.');
+ return n.substring(i + 1);
+ }
+
+ public ScopeType getScope() {
+ return original.getScope();
+ }
+
+ public void setName(String name) {
+ }
+
+ public void setScope(ScopeType type) {
+ }
+
+ public SeamContextShortVariable clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-10-17
13:22:23 UTC (rev 4288)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-10-17
13:44:03 UTC (rev 4289)
@@ -971,6 +971,32 @@
}
/**
+ * @see org.jboss.tools.seam.core.ISeamProject#getVariables()
+ */
+ public Set<ISeamContextVariable> getVariables(boolean includeShortNames) {
+ if(!includeShortNames) {
+ return allVariables;
+ }
+ Set<ISeamContextVariable> result = new HashSet<ISeamContextVariable>();
+ result.addAll(allVariables);
+ for (ISeamContextVariable v: allVariables) {
+ String n = v.getName();
+ int i = n.lastIndexOf('.');
+ if(i < 0) continue;
+ String packageName = n.substring(0, i);
+ if(isImportedPackage(packageName)) {
+ result.add(new SeamContextShortVariable(v));
+ }
+ }
+ return result;
+ }
+
+ public boolean isImportedPackage(String packageName) {
+ //TODO implement processing imported packages
+ return false;
+ }
+
+ /**
* @see org.jboss.tools.seam.core.ISeamProject#getVariablesByName(java.lang.String)
*/
public Set<ISeamContextVariable> getVariablesByName(String name) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-10-17
13:22:23 UTC (rev 4288)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-10-17
13:44:03 UTC (rev 4289)
@@ -28,6 +28,7 @@
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamContextShortVariable;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamElement;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
@@ -71,20 +72,8 @@
* @return
*/
private static List<ISeamContextVariable> internalResolveVariables(ISeamProject
project, String name, boolean onlyEqualNames) {
- List<ISeamContextVariable> resolvedVariables = new
ArrayList<ISeamContextVariable>();
- Set<ISeamContextVariable> variables = project.getVariables();
- for (ISeamContextVariable variable : variables) {
- if(onlyEqualNames) {
- if (variable.getName().equals(name)) {
- resolvedVariables.add(variable);
- }
- } else {
- if (variable.getName().startsWith(name)) {
- resolvedVariables.add(variable);
- }
- }
- }
- return resolvedVariables;
+ Set<ISeamContextVariable> variables = project.getVariables(true);
+ return internalResolveVariables(project, name, onlyEqualNames, variables);
}
/**
@@ -97,15 +86,20 @@
* @return
*/
private static List<ISeamContextVariable>
internalResolveVariablesByScope(ISeamProject project, ScopeType scope, String name,
boolean onlyEqualNames) {
- List<ISeamContextVariable> resolvedVariables = new
ArrayList<ISeamContextVariable>();
Set<ISeamContextVariable> variables = project.getVariablesByScope(scope, true);
+ return internalResolveVariables(project, name, onlyEqualNames, variables);
+ }
+
+ private static List<ISeamContextVariable> internalResolveVariables(ISeamProject
project, String name, boolean onlyEqualNames, Set<ISeamContextVariable> variables)
{
+ List<ISeamContextVariable> resolvedVariables = new
ArrayList<ISeamContextVariable>();
for (ISeamContextVariable variable : variables) {
+ String n = variable.getName();
if(onlyEqualNames) {
- if (variable.getName().equals(name)) {
+ if (n.equals(name)) {
resolvedVariables.add(variable);
}
} else {
- if (variable.getName().startsWith(name)) {
+ if (n.startsWith(name)) {
resolvedVariables.add(variable);
}
}
@@ -121,6 +115,9 @@
*/
public static IMember getMemberByVariable(ISeamContextVariable variable, boolean
onlyEqualNames) {
IMember member = null;
+ if(variable instanceof ISeamContextShortVariable) {
+ return getMemberByVariable(((ISeamContextShortVariable)variable).getOriginal(),
onlyEqualNames);
+ }
if (variable instanceof ISeamComponent) {
ISeamComponent component = (ISeamComponent)variable;
ISeamJavaComponentDeclaration decl = component.getJavaDeclaration();
Show replies by date