improved syntax errors
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/ModelingUnitParserImpl.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/ModelingUnitParserImpl.java
index dc7dbb4..eb9e8cd 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/ModelingUnitParserImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/ModelingUnitParserImpl.java
@@ -192,6 +192,7 @@
// Content detection
index = matcher.group().length() + matcher.start();
+
try {
int endIndex = getEndIndex(string, index, '}');
String stringContent = string.substring(index, endIndex);
@@ -207,9 +208,14 @@
(Collection<? extends ModelingUnitInstruction>)manager.getContent().values());
index = endIndex;
} catch (IndexOutOfBoundsException e) {
+ int spaceLength = 0;
+ Matcher spaceMatcher = Pattern.compile("^\\s+").matcher(matcher.group());
+ if (spaceMatcher.find()) {
+ spaceLength += spaceMatcher.group().length();
+ }
throw new ParseException(
Messages.getString(
- "ModelingUnitParserImpl.INCORRECT_CONTRIBUTION_END", matcher.group().trim()), rootOffset + matcher.start(), matcher.group().length()); //$NON-NLS-1$
+ "ModelingUnitParserImpl.INCORRECT_CONTRIBUTION_END", matcher.group().trim()), spaceLength + rootOffset + matcher.start(), matcher.group().trim().length()); //$NON-NLS-1$
}
res.put(new Location(matcher.start(), index), instance);
@@ -265,7 +271,7 @@
} catch (IndexOutOfBoundsException e) {
throw new ParseException(
Messages.getString(
- "ModelingUnitParserImpl.INCORRECT_INSTANCIATION_END", matcher.group().trim()), rootOffset + matcher.start(), matcher.group().length()); //$NON-NLS-1$
+ "ModelingUnitParserImpl.INCORRECT_INSTANCIATION_END", matcher.group().trim()), rootOffset + matcher.start(), matcher.group().trim().length()); //$NON-NLS-1$
}
res.put(new Location(matcher.start(), index), instance);
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/errors/test/TestModelingUnitErrors.java b/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/errors/test/TestModelingUnitErrors.java
index 0bf4c05..13ac4b0 100644
--- a/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/errors/test/TestModelingUnitErrors.java
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/errors/test/TestModelingUnitErrors.java
@@ -45,17 +45,17 @@
UNRECOGNIZED_CONTENT_ERROR, 95, 44));
}
- // @Test
- // public void testContribution() {
- // testErrorsOnFile("dataTests/intentDocuments/errors/contribution.intent", new ParseException(
- // "Contribution instruction uml { does not end correctly.", 0, 0));
- // }
+ @Test
+ public void testContribution() {
+ testErrorsOnFile("dataTests/intentDocuments/errors/contribution.intent", new ParseException(
+ "Contribution instruction uml { does not end correctly.", 499, 5));
+ }
- // @Test
- // public void testInstanciation() {
- // testErrorsOnFile("dataTests/intentDocuments/errors/instanciation.intent", new ParseException(
- // "Instanciation instruction new EPackage uml { does not end correctly.", 0, 0));
- // }
+ @Test
+ public void testInstanciation() {
+ testErrorsOnFile("dataTests/intentDocuments/errors/instanciation.intent", new ParseException(
+ "Instanciation instruction new EPackage uml { does not end correctly.", 358, 18));
+ }
@Test
public void testResourceDeclaration() {