use of org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic in project statecharts by Yakindu.
the class AbstractSCTResource method createDiagnostic.
protected void createDiagnostic(Triple<EObject, EReference, INode> triple) {
SpecificationElement specificationElement = EcoreUtil2.getContainerOfType(triple.getFirst(), SpecificationElement.class);
DiagnosticMessage message = createDiagnosticMessage(triple);
Diagnostic diagnostic = new XtextLinkingDiagnostic(triple.getThird(), message.getMessage(), message.getIssueCode(), message.getIssueData());
linkingDiagnostics.put(specificationElement, diagnostic);
}
use of org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic in project xtext-xtend by eclipse.
the class UTF8ParserErrorTest method testInvalidReference_01.
@Test
public void testInvalidReference_01() throws Exception {
XtendFunction func = function("def m() { \\u0020invalidStart }");
XBlockExpression block = (XBlockExpression) func.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(0);
String featureName = featureCall.getConcreteSyntaxFeatureName();
assertEquals("\\u0020invalidStart", featureName);
assertTrue(featureCall.getFeature().eIsProxy());
List<Diagnostic> errorList = func.eResource().getErrors();
assertEquals(2, errorList.size());
XtextLinkingDiagnostic diagnostic = (XtextLinkingDiagnostic) errorList.get(1);
assertTrue(diagnostic.getMessage().contains("invalidStart"));
}
use of org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic in project n4js by eclipse.
the class ErrorAwareLinkingService method addError.
/**
* Add the error to the resource of the given {@code context} if it does support validation.
*
* @param context
* the context object that caused the error.
* @param node
* the error location.
* @param error
* the actual error description.
*/
protected void addError(EObject context, INode node, IEObjectDescriptionWithError error) {
N4JSResource resource = (N4JSResource) context.eResource();
if (resource.isValidationDisabled())
return;
List<Diagnostic> list = resource.getErrors();
// Convert key value user data to String array
String[] userData = null;
if (error.getUserDataKeys() != null) {
ArrayList<String> userDataList = new ArrayList<>(error.getUserDataKeys().length * 2);
for (String userDataKey : error.getUserDataKeys()) {
final String userDataValue = error.getUserData(userDataKey);
if (userDataValue != null) {
userDataList.add(userDataKey);
userDataList.add(userDataValue);
}
}
userData = userDataList.toArray(new String[userDataList.size()]);
}
Diagnostic diagnostic = new XtextLinkingDiagnostic(node, error.getMessage(), error.getIssueCode(), userData);
if (!list.contains(diagnostic))
list.add(diagnostic);
}
use of org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic in project xtext-xtend by eclipse.
the class LinkingTest method testStaticImports_01.
@Test
public void testStaticImports_01() throws Exception {
String fileAsText = "import java.util.Collections.* class Clazz { def void method() { ''.singletonList() } }";
XtendFile file = file(fileAsText, false);
EcoreUtil.resolveAll(file);
List<Diagnostic> errors = file.eResource().getErrors();
assertEquals(1, errors.size());
assertTrue(errors.get(0) instanceof XtextLinkingDiagnostic);
XtextLinkingDiagnostic diagnostic = (XtextLinkingDiagnostic) errors.get(0);
assertEquals(fileAsText.indexOf("singletonList"), diagnostic.getOffset());
}
use of org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic in project xtext-xtend by eclipse.
the class LinkingTest method testStaticImports_02.
@Test
public void testStaticImports_02() throws Exception {
String fileAsText = "import static java.util.Collections.* class Clazz { def void method() { ''.singletonList() } }";
XtendFile file = file(fileAsText, false);
EcoreUtil.resolveAll(file);
List<Diagnostic> errors = file.eResource().getErrors();
assertEquals(1, errors.size());
assertTrue(errors.get(0) instanceof XtextLinkingDiagnostic);
XtextLinkingDiagnostic diagnostic = (XtextLinkingDiagnostic) errors.get(0);
assertEquals(fileAsText.indexOf("singletonList"), diagnostic.getOffset());
}
Aggregations