[jbosstools-commits] JBoss Tools SVN: r43879 - in trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el: internal/core/model and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 20 16:21:19 EDT 2012
Author: scabanovich
Date: 2012-09-20 16:21:19 -0400 (Thu, 20 Sep 2012)
New Revision: 43879
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java
Log:
JBIDE-12479
https://issues.jboss.org/browse/JBIDE-12479
Do not keep EL model objects in ELReference.
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2012-09-20 18:15:42 UTC (rev 43878)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2012-09-20 20:21:19 UTC (rev 43879)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.el.core;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -44,10 +45,8 @@
private int length;
private int lineNumber;
private int startPosition;
- private ELExpression[] el;
private Set<IMarker> markers;
private boolean needToInitMarkers = false;
- private List<SyntaxError> syntaxErrors;
private String source;
private String elMarkerGroupID;
@@ -137,8 +136,8 @@
}
public String getSourceText() {
- if(source==null) {
- source = getELModel().getSource();
+ if(source == null) {
+ source = getText();// getELModel().getSource();
}
return source;
}
@@ -157,44 +156,45 @@
*
* @param text
*/
- public void init(String text) {
+ public ELExpression[] init(String text) {
ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(text);
- setSyntaxErrors(model.getSyntaxErrors());
- setEl(model.getInstances());
+ return setEl(model.getInstances());
}
/**
* @return the el
*/
public ELExpression[] getEl() {
- if(el == null) {
- String text = FileUtil.getContentFromEditorOrFile(resource);
- if(getStartPosition() >= 0 && getLength() >= 0 && text.length() >= getStartPosition() + getLength()) {
- init(text.substring(getStartPosition(), getStartPosition() + getLength()));
+ ELExpression[] el = null;
+ String text = getSourceText();
+ if(text.length() > 0) {
+ el = init(text);
} else {
el = new ELExpression[0];
}
- }
return el;
}
- /**
- * @param el the el to set
- */
- public void setEl(ELExpression[] el) {
- this.el = el;
+ private String getText() {
+ String text = FileUtil.getContentFromEditorOrFile(resource);
+ if(getStartPosition() >= 0 && getLength() >= 0 && text.length() >= getStartPosition() + getLength()) {
+ return source = "" + text.substring(getStartPosition(), getStartPosition() + getLength());
+ } else {
+ return source = "";
+ }
+
}
/**
* @param insts
*/
- public void setEl(List<ELInstance> insts) {
+ public ELExpression[] setEl(List<ELInstance> insts) {
Set<ELExpression> exps = new HashSet<ELExpression>();
for (ELInstance el : insts) {
exps.add(el.getExpression());
}
- el = exps.toArray(new ELExpression[0]);
+ return exps.toArray(new ELExpression[0]);
}
private static final IMarker[] EMPTY_MARKER_ARRAY = new IMarker[0];
@@ -228,15 +228,13 @@
* @return the syntaxErrors
*/
public List<SyntaxError> getSyntaxErrors() {
- return syntaxErrors;
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ String text = getSourceText();
+ if(text.length() == 0) return Collections.emptyList();
+ ELModel model = parser.parse(text);
+ return model.getSyntaxErrors();
}
- /**
- * @param syntaxErrors the syntaxErrors to set
- */
- public void setSyntaxErrors(List<SyntaxError> syntaxErrors) {
- this.syntaxErrors = syntaxErrors;
- }
public String getMarkerGroupId() {
return this.elMarkerGroupID;
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java 2012-09-20 18:15:42 UTC (rev 43878)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java 2012-09-20 20:21:19 UTC (rev 43879)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.internal.core.model;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.jboss.tools.common.el.core.model.ELObject;
@@ -25,7 +26,7 @@
protected LexicalToken firstToken;
protected LexicalToken lastToken;
protected ELObjectImpl parent;
- protected List<ELObject> children = new ArrayList<ELObject>();
+ protected List<ELObject> children = null;
public ELObjectImpl() {
}
@@ -58,9 +59,11 @@
public ELObjectImpl getParent() {
return parent;
}
+
+ static List<ELObject> empty = Collections.emptyList();
public List<ELObject> getChildren() {
- return children;
+ return children == null ? empty : children;
}
public LexicalToken getFirstToken() {
@@ -76,12 +79,15 @@
}
public void addChild(ELObjectImpl child) {
+ if(children == null) {
+ children = new ArrayList<ELObject>(1);
+ }
children.add(child);
child.setParent(this);
}
protected void removeChild(ELObjectImpl child) {
- if(children.contains(child)) {
+ if(children != null && children.contains(child)) {
children.remove(child);
child.setParent(null);
}
More information about the jbosstools-commits
mailing list