Author: scabanovich
Date: 2008-09-24 10:17:52 -0400 (Wed, 24 Sep 2008)
New Revision: 10451
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
Log:
JBIDE-1497.
Syntax errors are passed to EL model and its instances.
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java 2008-09-24
13:28:20 UTC (rev 10450)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java 2008-09-24
14:17:52 UTC (rev 10451)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.common.el.core.model;
+import java.util.List;
+
import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
/**
* Instance of EL includes opening token, the expression proper,
@@ -29,4 +32,6 @@
public LexicalToken getCloseInstanceToken();
+ public List<SyntaxError> getErrors();
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java 2008-09-24
13:28:20 UTC (rev 10450)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java 2008-09-24
14:17:52 UTC (rev 10451)
@@ -37,6 +37,7 @@
}
ELModelImpl model = impl.parse(token);
model.setSource(source);
+ model.setErrors(errors);
return model;
}
@@ -60,6 +61,7 @@
}
ELModelImpl model = impl.parse(token);
model.setSource(source);
+ model.setErrors(errors);
return model;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java 2008-09-24
13:28:20 UTC (rev 10450)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java 2008-09-24
14:17:52 UTC (rev 10451)
@@ -10,10 +10,14 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
@@ -23,6 +27,7 @@
*/
public class ELInstanceImpl extends ELObjectImpl implements ELInstance {
ELExpressionImpl expression;
+ List<SyntaxError> errors = new ArrayList<SyntaxError>();
public ELInstanceImpl() {
}
@@ -49,6 +54,10 @@
return expression;
}
+ public List<SyntaxError> getErrors() {
+ return errors;
+ }
+
public void addChild(ELObjectImpl child) {
if(child instanceof ELExpressionImpl) {
setExpression((ELExpressionImpl)child);
@@ -88,4 +97,18 @@
return ELObjectType.EL_INSTANCE;
}
+ public boolean contains(int position) {
+ if(position < getFirstToken().getStart()) return false;
+ LexicalToken l = getLastToken();
+ if(l == null) l = getFirstToken();
+ int end = l.getStart() + l.getLength();
+ if(position > end) return false;
+ if(getCloseInstanceToken() != null && position == end) return false;
+ return true;
+ }
+
+ public void addError(SyntaxError error) {
+ errors.add(error);
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java 2008-09-24
13:28:20 UTC (rev 10450)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java 2008-09-24
14:17:52 UTC (rev 10451)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
/**
*
@@ -69,4 +70,17 @@
return ELObjectType.EL_MODEL;
}
+ public void setErrors(List<SyntaxError> errors) {
+ for (SyntaxError e: errors) {
+ for (ELInstance i: instances) {
+ ELInstanceImpl im = (ELInstanceImpl)i;
+ if(im.contains(e.getPosition())) {
+ im.addError(e);
+ break;
+ }
+ }
+ }
+
+ }
+
}
Show replies by date