Author: scabanovich
Date: 2010-11-18 09:10:06 -0500 (Thu, 18 Nov 2010)
New Revision: 26706
Modified:
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/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
JBIDE-7616
https://jira.jboss.org/browse/JBIDE-7616
Modified:
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 2010-11-18
12:26:50 UTC (rev 26705)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamContextShortVariable.java 2010-11-18
14:10:06 UTC (rev 26706)
@@ -7,17 +7,26 @@
public class SeamContextShortVariable extends SeamObject implements
ISeamContextShortVariable {
ISeamContextVariable original;
+ String prefix = null;
public SeamContextShortVariable(ISeamContextVariable original) {
this.original = original;
}
+ public SeamContextShortVariable(ISeamContextVariable original, String prefix) {
+ this.original = original;
+ this.prefix = prefix;
+ }
+
public ISeamContextVariable getOriginal() {
return original;
}
public String getName() {
String n = original.getName();
+ if(prefix != null && n.startsWith(prefix)) {
+ return n.substring(prefix.length());
+ }
int i = n.lastIndexOf('.');
return n.substring(i + 1);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2010-11-18
12:26:50 UTC (rev 26705)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2010-11-18
14:10:06 UTC (rev 26706)
@@ -36,6 +36,7 @@
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponentMethod;
+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;
@@ -68,29 +69,31 @@
public Set<ISeamContextVariable> getVariablesByName(String name) {
Set<ISeamContextVariable> result = new HashSet<ISeamContextVariable>();
for (String s: imports) {
- String qname = s + "." + name;
- Set<ISeamContextVariable> c = getSeamProject().getVariablesByName(qname);
- if((c == null || c.isEmpty()) && getSeamProject().getParentProject() != null)
c = getSeamProject().getParentProject().getVariablesByName(qname);
- if(c != null && !c.isEmpty()) {
- result.addAll(c);
- for (ISeamContextVariable v: c) {
- result.add(new SeamContextShortVariable(v));
- }
- }
+ lookUpForVariable(s, name, result);
}
if(result.isEmpty()) {
List<SeamImport> is = ((SeamProject)getSeamProject()).getPackageImports(this);
if(is != null && !is.isEmpty()) {
for (SeamImport i: is) {
- String qname = i.getSeamPackage() + "." + name;
- Set<ISeamContextVariable> c = getSeamProject().getVariablesByName(qname);
- if((c == null || c.isEmpty()) && getSeamProject().getParentProject() !=
null) c = getSeamProject().getParentProject().getVariablesByName(qname);
- if(c != null && !c.isEmpty()) result.addAll(c);
+ lookUpForVariable(i.getSeamPackage(), name, result);
}
}
}
return result;
}
+
+ private void lookUpForVariable(String importname, String name,
Set<ISeamContextVariable> result) {
+ String qname = importname + "." + name;
+ Set<ISeamContextVariable> c = getSeamProject().getVariablesByName(qname);
+ if((c == null || c.isEmpty()) && getSeamProject().getParentProject() != null) c
= getSeamProject().getParentProject().getVariablesByName(qname);
+ if(c != null && !c.isEmpty()) {
+ result.addAll(c);
+ for (ISeamContextVariable v: c) {
+ if(v instanceof ISeamContextShortVariable) continue;
+ result.add(new SeamContextShortVariable(v, importname + "."));
+ }
+ }
+ }
public void setType(IType type) {
this.type = type;
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 2010-11-18
12:26:50 UTC (rev 26705)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2010-11-18
14:10:06 UTC (rev 26706)
@@ -1438,7 +1438,7 @@
Set<ISeamContextVariable> result = getVariables(true);
Set<String> imports = new HashSet<String>();
if(context != null) {
- imports = ((SeamJavaComponentDeclaration)context).getImports();
+ imports.addAll(((SeamJavaComponentDeclaration)context).getImports());
List<SeamImport> is = getPackageImports(context);
if(is != null) {
for (SeamImport i: is) imports.add(i.getSeamPackage());
@@ -1452,8 +1452,7 @@
if(v instanceof ISeamContextShortVariable) continue;
for (String q: imports) {
if(v.getName().startsWith(q + ".")) {
- result.add(new SeamContextShortVariable(v));
- break;
+ result.add(new SeamContextShortVariable(v, q + "."));
}
}
}