@Test public void testUnresolved_02() { Type type = getContext(); INode nameNode = NodeModelUtils.findNodesForFeature(type, ImportedURIPackage.Literals.TYPE__NAME).get(0); resolve(type, "BlaBlaBla", nameNode.getOffset(), nameNode.getLength()); Resource resource = type.eResource(); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(nameNode, nameNode.getOffset()); Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0); assertEquals(nameNode.getOffset(), diagnostic.getOffset()); assertEquals(nameNode.getLength(), diagnostic.getLength()); assertEquals(lineAndColumn.getLine(), diagnostic.getLine()); assertEquals(lineAndColumn.getColumn(), diagnostic.getColumn()); assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage()); }
@Override public List<IssueResolution> getResolutions(Issue issue) { StopWatch stopWatch = new StopWatch(logger); try { if (Diagnostic.LINKING_DIAGNOSTIC.equals(issue.getCode())) { List<IssueResolution> result = new ArrayList<IssueResolution>(); result.addAll(getResolutionsForLinkingIssue(issue)); result.addAll(super.getResolutions(issue)); return result; } else return super.getResolutions(issue); } finally { stopWatch.resetAndLog("#getResolutions"); } }
private void convertFacets(final HeadlessExperiment stm, final ISyntacticElement elt, final Set<Diagnostic> errors) { final SymbolProto p = DescriptionFactory.getProto(EXPERIMENT, null); for (final Facet f : EGaml.getFacetsOf(stm)) { final String fname = EGaml.getKeyOf(f); // We compute (and convert) the expression attached to the facet final boolean label = p == null ? false : p.isLabel(fname); final IExpressionDescription fexpr = convExpr(f, label, errors); addFacet(elt, fname, fexpr, errors); } final IExpressionDescription ed = findExpr(stm, errors); addFacet(elt, NAME, ed, errors); addFacet(elt, TITLE, ed, errors); if (!elt.hasFacet(TYPE)) addFacet(elt, TYPE, convertToLabel(null, HEADLESS_UI), errors); }
private final IExpressionDescription convExpr(final Facet facet, final boolean label, final Set<Diagnostic> errors) { if (facet != null) { final Expression expr = facet.getExpr(); if (expr == null && facet.getBlock() != null) { final Block b = facet.getBlock(); final ISyntacticElement elt = SyntacticFactory.create(ACTION, new Facets(NAME, SYNTHETIC + SYNTHETIC_ACTION++), true); convertBlock(elt, b, errors); return convExpr(elt, errors); } if (expr != null) { return label ? convertToLabel(expr, EGaml.getKeyOf(expr)) : convExpr(expr, errors); } final String name = facet.getName(); // TODO Verify the use of "facet" if (name != null) { return convertToLabel(null, name); } } return null; }
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context) { EReference _reference = context.getReference(); final EClass referenceType = _reference.getEReferenceType(); String linkText = ""; try { String _linkText = context.getLinkText(); linkText = _linkText; } catch (final Throwable _t) { if (_t instanceof IllegalNodeException) { final IllegalNodeException e = (IllegalNodeException)_t; INode _node = e.getNode(); String _text = _node.getText(); linkText = _text; } else { throw Exceptions.sneakyThrow(_t); } } String _name = referenceType.getName(); String _plus = ("Couldn\'t resolve reference to " + _name); String _plus_1 = (_plus + " \'"); String _plus_2 = (_plus_1 + linkText); final String msg = (_plus_2 + "\'."); String _name_1 = referenceType.getName(); DiagnosticMessage _diagnosticMessage = new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC, _name_1, linkText); return _diagnosticMessage; }
@Test public void selectionOnPrimitiveType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("class A {"); _builder.newLine(); _builder.append("\t"); _builder.append("A m() {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("return \"a\".m();"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); SJProgram _parse = this._parseHelper.parse(_builder); EClass _sJMemberSelection = SmallJavaPackage.eINSTANCE.getSJMemberSelection(); this._validationTestHelper.assertError(_parse, _sJMemberSelection, Diagnostic.LINKING_DIAGNOSTIC, "Couldn\'t resolve reference to SJMember \'m\'"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void createMissingEntity(final Issue issue, final IssueResolutionAcceptor acceptor) { final ISemanticModification _function = new ISemanticModification() { @Override public void apply(final EObject element, final IModificationContext context) throws Exception { Entity _containerOfType = EcoreUtil2.<Entity>getContainerOfType(element, Entity.class); IXtextDocument _xtextDocument = context.getXtextDocument(); Integer _offset = issue.getOffset(); Integer _length = issue.getLength(); String _get = _xtextDocument.get((_offset).intValue(), (_length).intValue()); EntitiesModelUtil.addEntityAfter(_containerOfType, _get); } }; acceptor.accept(issue, "Create missing entity", "Create missing entity", "Entity.gif", _function); }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void createMissingEntity(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "Create missing entity", // label "Create missing entity", // description "Entity.gif", // icon new ISemanticModification() { public void apply(EObject element, IModificationContext context) throws BadLocationException { IXtextDocument xtextDocument = context.getXtextDocument(); String missingEntityName = xtextDocument.get(issue.getOffset(), issue.getLength()); Entity newEntity = EntitiesFactory.eINSTANCE.createEntity(); newEntity.setName(missingEntityName); Entity currentEntity = EcoreUtil2.getContainerOfType(element, Entity.class); Model model = (Model) currentEntity.eContainer(); model.getEntities().add(model.getEntities().indexOf(currentEntity)+1, newEntity); } } ); }
@Test public void testForwardReference() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("val j = i + 1 // forward reference"); _builder.newLine(); _builder.append("val i = 10"); _builder.newLine(); ExpressionsModel _parse = this._parseHelper.parse(_builder); EClass _xFeatureCall = XbasePackage.eINSTANCE.getXFeatureCall(); this._validationTestHelper.assertError(_parse, _xFeatureCall, Diagnostic.LINKING_DIAGNOSTIC, "Couldn\'t resolve reference to JvmIdentifiableElement \'i\'"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testNoOperationFound() throws Exception { XAnnotation annotation = annotation("@testdata.Annotation2(toString = true)", false); validator.assertNoError(annotation, IssueCodes.INCOMPATIBLE_TYPES); // TODO use better error message like in Java (e.g. Annotation A does not define an attribute b) validator.assertError(annotation, XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR, Diagnostic.LINKING_DIAGNOSTIC); validator.assertError(annotation, XAnnotationsPackage.Literals.XANNOTATION, IssueCodes.ANNOTATIONS_MISSING_ATTRIBUTE_DEFINITION, "attribute 'value'"); }
public void consume(Diagnostic diagnostic) { final Pair<Integer, Integer> newRange = Tuples.create(diagnostic.getOffset(), diagnostic.getLength()); if (coveredNodes.add(newRange)) { boolean changed = this.diagnostics.add(diagnostic); diagnosticsConsumed |= changed; } }
@Override public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) { EClass referenceType = context.getReference().getEReferenceType(); String linkText = ""; try { linkText = context.getLinkText(); } catch (IllegalNodeException e){ linkText = e.getNode().getText(); } String msg = "Couldn't resolve reference to " + referenceType.getName() + " '" + linkText + "'."; return new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC); }
@Override public DiagnosticMessage getViolatedBoundsConstraintMessage(ILinkingDiagnosticContext context, int size) { String message = "Too many matches for reference to '" + context.getLinkText() + "'. " + "Feature " + context.getReference().getName() + " can only hold " + context.getReference().getUpperBound() + " reference" + (context.getReference().getUpperBound() != 1 ? "s" : "") + " but found " + size + " candidate" + (size!=1 ? "s" : ""); return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC); }
@Test public void testCrossProjectLink() { StringConcatenation _builder = new StringConcatenation(); _builder.append("type Foo {"); _builder.newLine(); _builder.append(" "); _builder.append("Bar bar"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final URI foo = this.createFile(this.project0, "Foo.testlang", _builder); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("type Bar {"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); final URI bar = this.createFile(this.project1, "Bar.testlang", _builder_1); this.workspaceManager.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(foo, bar)), CollectionLiterals.<URI>emptyList(), CancelIndicator.NullImpl); Assert.assertEquals(2, this.diagnostics.size()); Assert.assertEquals(1, this.diagnostics.get(foo).size()); Assert.assertEquals(Diagnostic.LINKING_DIAGNOSTIC, IterableExtensions.<Issue>head(this.diagnostics.get(foo)).getCode()); Assert.assertTrue(this.diagnostics.get(bar).isEmpty()); this.diagnostics.clear(); List<String> _dependencies = this.workspaceManager.getProjectManager(this.project0.getName()).getProjectDescription().getDependencies(); String _name = this.project1.getName(); _dependencies.add(_name); this.workspaceManager.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(foo, bar)), CollectionLiterals.<URI>emptyList(), CancelIndicator.NullImpl); Assert.assertEquals(2, this.diagnostics.size()); Assert.assertTrue(this.diagnostics.get(foo).isEmpty()); Assert.assertTrue(this.diagnostics.get(bar).isEmpty()); }
@Test public void testUnresolved_01() { Type type = resolve("BlaBlaBla"); Resource resource = type.eResource(); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0); assertEquals(0, diagnostic.getOffset()); assertEquals(1, diagnostic.getLength()); assertEquals(1, diagnostic.getLine()); assertEquals(1, diagnostic.getColumn()); assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage()); }
@Test public void testLinkError() throws Exception { XtextResource resource = getResourceFromStringAndExpect(" type A extends B \n type B extends C", 1); Main model = (Main) getModel(resource); assertEquals(2, model.getTypes().size()); assertEquals(1, resource.getErrors().size()); assertEquals(0, resource.getWarnings().size()); Diagnostic error = (Diagnostic) resource.getErrors().get(0); assertEquals(2, error.getLine()); Diagnostic verboseError = error; assertEquals(35, verboseError.getOffset()); assertEquals(1, verboseError.getLength()); }
@Test public void testLinkingErrorMessage() throws Exception { XtextResource resource = getResourceFromStringAndExpect("type A extends B", 1); assertEquals(1, resource.getErrors().size()); Diagnostic error = (Diagnostic) resource.getErrors().get(0); assertEquals(1, error.getLine()); assertEquals("Couldn't resolve reference to Type 'B'.", error.getMessage()); }
@Test public void testLinkingProblemAsWarning() throws Exception { String modelAsText = "type A extends B \n type B extends C"; XtextResource resource = getResourceFromStringAndExpect(modelAsText, 0); assertTrue(resource.getErrors().isEmpty()); assertEquals(1, resource.getWarnings().size()); Diagnostic warning = (Diagnostic) resource.getWarnings().get(0); assertEquals(2, warning.getLine()); assertEquals(expected, warning.getMessage()); }
@Override public boolean hasResolutionFor(final String issueCode) { if (Diagnostic.LINKING_DIAGNOSTIC.equals(issueCode)) { return false; } return super.hasResolutionFor(issueCode); }
public void convertBlock(final ISyntacticElement elt, final Block block, final Set<Diagnostic> errors) { if (block != null) { final Expression function = block.getFunction(); if (function != null) { // If it is a function (and not a regular block), we add it as a // facet addFacet(elt, FUNCTION, convExpr(function, errors), errors); } else { convStatements(elt, EGaml.getStatementsOf(block), errors); } } }
private void addFacet(final ISyntacticElement e, final String key, final IExpressionDescription expr, final Set<Diagnostic> errors) { if (e.hasFacet(key)) { e.setFacet(IGamlIssue.DOUBLED_CODE + key, expr); // addWarning("Double definition of facet " + key + ". Only the last one will be considered", // e.getElement(), // errors); } else e.setFacet(key, expr); }
private void convElse(final S_If stm, final ISyntacticElement elt, final Set<Diagnostic> errors) { final EObject elseBlock = stm.getElse(); if (elseBlock != null) { final ISyntacticElement elseElt = SyntacticFactory.create(ELSE, elseBlock, EGaml.hasChildren(elseBlock)); if (elseBlock instanceof Statement) { elseElt.addChild(convStatement(elt, (Statement) elseBlock, errors)); } else { convStatements(elseElt, EGaml.getStatementsOf((Block) elseBlock), errors); } elt.addChild(elseElt); } }
private void convCatch(final S_Try stm, final ISyntacticElement elt, final Set<Diagnostic> errors) { final EObject catchBlock = stm.getCatch(); if (catchBlock != null) { final ISyntacticElement catchElt = SyntacticFactory.create(IKeyword.CATCH, catchBlock, EGaml.hasChildren(catchBlock)); convStatements(catchElt, EGaml.getStatementsOf((Block) catchBlock), errors); elt.addChild(catchElt); } }
private void convertArgs(final ActionArguments args, final ISyntacticElement elt, final Set<Diagnostic> errors) { if (args != null) { for (final ArgumentDefinition def : EGaml.getArgsOf(args)) { final ISyntacticElement arg = SyntacticFactory.create(ARG, def, false); addFacet(arg, NAME, convertToLabel(null, def.getName()), errors); final EObject type = def.getType(); addFacet(arg, TYPE, convExpr(type, errors), errors); final Expression e = def.getDefault(); if (e != null) { addFacet(arg, DEFAULT, convExpr(e, errors), errors); } elt.addChild(arg); } } }
private void convertFacets(final Statement stm, final String keyword, final ISyntacticElement elt, final Set<Diagnostic> errors) { final SymbolProto p = DescriptionFactory.getProto(keyword, null); for (final Facet f : EGaml.getFacetsOf(stm)) { String fname = EGaml.getKeyOf(f); // We change the "<-" and "->" symbols into full names if (fname.equals("<-")) { fname = keyword.equals(LET) || keyword.equals(SET) ? VALUE : INIT; } else if (fname.equals("->")) { fname = FUNCTION; } // We compute (and convert) the expression attached to the facet final boolean label = p == null ? false : p.isLabel(fname); final IExpressionDescription fexpr = convExpr(f, label, errors); addFacet(elt, fname, fexpr, errors); } // We add the "default" (or omissible) facet to the syntactic element String def = stm.getFirstFacet(); if (def != null) { if (def.endsWith(":")) { def = def.substring(0, def.length() - 1); } } else { def = DescriptionFactory.getOmissibleFacetForSymbol(keyword); } if (def != null && !def.isEmpty() && !elt.hasFacet(def)) { final IExpressionDescription ed = findExpr(stm, errors); if (ed != null) { elt.setFacet(def, ed); } } }
final void convStatements(final ISyntacticElement elt, final List<? extends Statement> ss, final Set<Diagnostic> errors) { for (final Statement stm : ss) { if (IKeyword.GLOBAL.equals(EGaml.getKeyOf(stm))) { convStatements(elt, EGaml.getStatementsOf(stm.getBlock()), errors); convertFacets(stm, IKeyword.GLOBAL, elt, errors); } else { final ISyntacticElement child = convStatement(elt, stm, errors); if (child != null) { elt.addChild(child); } } } }
private final IExpressionDescription findExpr(final Statement stm, final Set<Diagnostic> errors) { if (stm == null) { return null; } // The order below should be important final String name = EGaml.getNameOf(stm); if (name != null) { return convertToLabel(stm, name); } final Expression expr = stm.getExpr(); if (expr != null) { return convExpr(expr, errors); } return null; }
@Override public DiagnosticMessage getViolatedBoundsConstraintMessage(final ILinkingDiagnosticContext context, final int size) { final String message = "Too many matches for reference to '" + context.getLinkText() + "'. " + "Feature " + context.getReference().getName() + " can only hold " + context.getReference().getUpperBound() + " reference" + (context.getReference().getUpperBound() != 1 ? "s" : "") + " but found " + size + " candidate" + (size != 1 ? "s" : ""); return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC); }
@Test public void linkIsUnresolvedTest() { try { final XtextResourceSet resourceSet = this.resourceSetProvider.get(); final Leave leave = this.parseHelper.parse("Bye MissingHello!", resourceSet); Assert.assertNotNull(leave); this.validationTester.assertError(leave, GoodbyeDSLPackage.Literals.GOODBYE, Diagnostic.LINKING_DIAGNOSTIC); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void badImport() { ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class); Grammar grammar = createMock(Grammar.class); Import delegate = createMock(Import.class); Resource resource = createMock(Resource.class); URI uri = createMock(URI.class); String name = "G.g4"; expect(diagnosticContext.getLinkText()).andReturn("some"); expect(diagnosticContext.getContext()).andReturn(delegate); expect(delegate.eContainer()).andReturn(null).times(2); expect(delegate.eContainer()).andReturn(grammar); expect(grammar.eContainer()).andReturn(null); expect(grammar.eResource()).andReturn(resource); expect(resource.getURI()).andReturn(uri); expect(uri.lastSegment()).andReturn(name); Object[] mocks = {diagnosticContext, delegate, grammar, resource, uri }; replay(mocks); DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider() .getUnresolvedProxyMessage(diagnosticContext); assertNotNull(message); assertEquals(Diagnostic.LINKING_DIAGNOSTIC, message.getIssueCode()); assertArrayEquals(new String[]{"some", "import" }, message.getIssueData()); assertEquals("can't find or load grammar 'some' from 'G.g4'", message.getMessage()); assertEquals(Severity.ERROR, message.getSeverity()); verify(mocks); }
@Test public void undefinedParserRule() { ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class); ParserRule rule = createMock(ParserRule.class); RuleRef ref = createMock(RuleRef.class); expect(diagnosticContext.getLinkText()).andReturn("some"); expect(diagnosticContext.getContext()).andReturn(ref); expect(ref.eContainer()).andReturn(null); expect(ref.eContainer()).andReturn(rule); Object[] mocks = {diagnosticContext, ref, rule }; replay(mocks); DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider() .getUnresolvedProxyMessage(diagnosticContext); assertNotNull(message); assertEquals(Diagnostic.LINKING_DIAGNOSTIC, message.getIssueCode()); assertArrayEquals(new String[]{"some", "rule" }, message.getIssueData()); assertEquals("reference to undefined rule 'some'", message.getMessage()); assertEquals(Severity.ERROR, message.getSeverity()); verify(mocks); }
@Test public void undefinedLexerRule() { ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class); LexerRule rule = createMock(LexerRule.class); RuleRef ref = createMock(RuleRef.class); expect(diagnosticContext.getLinkText()).andReturn("ID"); expect(diagnosticContext.getContext()).andReturn(ref); expect(ref.eContainer()).andReturn(null); expect(ref.eContainer()).andReturn(rule); Object[] mocks = {diagnosticContext, ref, rule }; replay(mocks); DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider() .getUnresolvedProxyMessage(diagnosticContext); assertNotNull(message); assertEquals(Diagnostic.LINKING_DIAGNOSTIC, message.getIssueCode()); assertArrayEquals(new String[]{"ID", "token" }, message.getIssueData()); assertEquals("reference to undefined rule 'ID'", message.getMessage()); assertEquals(Severity.ERROR, message.getSeverity()); verify(mocks); }
@Test public void implicitTokenDefinition() { ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class); ParserRule rule = createMock(ParserRule.class); RuleRef ref = createMock(RuleRef.class); expect(diagnosticContext.getLinkText()).andReturn("ID"); expect(diagnosticContext.getContext()).andReturn(ref); expect(ref.eContainer()).andReturn(null); expect(ref.eContainer()).andReturn(rule); Object[] mocks = {diagnosticContext, ref, rule }; replay(mocks); DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider() .getUnresolvedProxyMessage(diagnosticContext); assertNotNull(message); assertEquals(Diagnostic.LINKING_DIAGNOSTIC, message.getIssueCode()); assertArrayEquals(new String[]{"ID", "token" }, message.getIssueData()); assertEquals("implicit token definition 'ID'", message.getMessage()); assertEquals(Severity.WARNING, message.getSeverity()); verify(mocks); }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void characterUnknown(final Issue issue, final IssueResolutionAcceptor acceptor) { EClass _characterDefinition = DialogScriptPackage.eINSTANCE.getCharacterDefinition(); final String linkText = this.customLinkingDiagnosticMessageProvider.getLinkText(issue, _characterDefinition); boolean _notEquals = (!Objects.equal(linkText, null)); if (_notEquals) { final ISemanticModification _function = new ISemanticModification() { public void apply(final EObject element, final IModificationContext context) throws Exception { if ((element instanceof DialogLine)) { final Script root = EcoreUtil2.<Script>getContainerOfType(element, Script.class); final CharacterDefinition charaDef = DialogScriptFactory.eINSTANCE.createCharacterDefinition(); charaDef.setName(linkText); CharactersDefinition _charactersDefinition = root.getCharactersDefinition(); boolean _equals = Objects.equal(_charactersDefinition, null); if (_equals) { CharactersDefinition _createCharactersDefinition = DialogScriptFactory.eINSTANCE.createCharactersDefinition(); root.setCharactersDefinition(_createCharactersDefinition); } CharactersDefinition _charactersDefinition_1 = root.getCharactersDefinition(); EList<CharacterDefinition> _characters = _charactersDefinition_1.getCharacters(); _characters.add(charaDef); } } }; acceptor.accept(issue, (("Create character \'" + linkText) + "\'"), (("Create character \'" + linkText) + "\'"), null, _function); } }
@Fix(Diagnostic.LINKING_DIAGNOSTIC) public void createTemplate(final Issue issue, final IssueResolutionAcceptor acceptor) { EClass _template = CharacterScriptPackage.eINSTANCE.getTemplate(); final String linkText = this.customLinkingDiagnosticMessageProvider.getLinkText(issue, _template); this.addImportTemplateFix(issue, acceptor, linkText); this.addLocalTemplateFix(issue, acceptor, linkText); }
@Override protected Diagnostic createDiagnostic(DiagnosticMessage message) { return new XtextLinkingDiagnostic(getNode(), message.getMessage(), message.getIssueCode(), message.getIssueData()); }
@Override public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context) { String _xtrycatchfinallyexpression = null; try { _xtrycatchfinallyexpression = context.getLinkText(); } catch (final Throwable _t) { if (_t instanceof IllegalNodeException) { final IllegalNodeException e = (IllegalNodeException)_t; _xtrycatchfinallyexpression = e.getNode().getText(); } else { throw Exceptions.sneakyThrow(_t); } } String linkText = _xtrycatchfinallyexpression; if ((linkText == null)) { return null; } EObject contextObject = context.getContext(); boolean _isStaticMemberCallTarget = this.isStaticMemberCallTarget(contextObject); if (_isStaticMemberCallTarget) { StringConcatenation _builder = new StringConcatenation(); _builder.append(linkText); _builder.append(" cannot be resolved to a type."); return new DiagnosticMessage(_builder.toString(), Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC, UnresolvedFeatureCallTypeAwareMessageProvider.TYPE_LITERAL); } if ((contextObject instanceof XAbstractFeatureCall)) { boolean _isOperation = ((XAbstractFeatureCall)contextObject).isOperation(); boolean _not = (!_isOperation); if (_not) { return this.handleUnresolvedFeatureCall(context, ((XAbstractFeatureCall)contextObject), linkText); } } EClass referenceType = context.getReference().getEReferenceType(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append(linkText); _builder_1.append(" cannot be resolved"); String _typeName = this.getTypeName(referenceType, context.getReference()); _builder_1.append(_typeName); _builder_1.append("."); final String msg = _builder_1.toString(); return new DiagnosticMessage(msg, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC, linkText); }
@Test public void testConstructorCall_10() throws Exception { XExpression expression = expression("new DoesNotExist"); helper.assertError(expression, XCONSTRUCTOR_CALL, Diagnostic.LINKING_DIAGNOSTIC); }
@Test public void testLocalVarWithArguments_01() throws Exception { XExpression expr = expression("{ val x = 'foo' x(42, 17bd) }"); helper.assertError(expr, XFEATURE_CALL, Diagnostic.LINKING_DIAGNOSTIC, "method", "x(int, BigDecimal)"); }
@Test public void testLocalVarWithArguments_02() throws Exception { XExpression expr = expression("{ val x = 'foo' x() }"); helper.assertError(expr, XFEATURE_CALL, Diagnostic.LINKING_DIAGNOSTIC, "method", "x()"); }