Java 类org.eclipse.xtext.diagnostics.DiagnosticMessage 实例源码

项目:n4js    文件:N4JSResource.java   
@Override
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
    // check if unresolved reference is special case handled by {@link N4JSScopingDiagnostician}
    DiagnosticMessage scopingDiagnostic = scopingDiagnostician.getMessageFor(triple.getFirst(), triple.getSecond(),
            triple.getThird());
    // if so, use more specific diagnostic message
    if (null != scopingDiagnostic) {
        List<Diagnostic> list = getDiagnosticList(scopingDiagnostic);
        Diagnostic diagnostic = createDiagnostic(triple, scopingDiagnostic);
        if (!list.contains(diagnostic)) {
            list.add(diagnostic);
        }
    } else {
        // if not, use default generic scoping message
        super.createAndAddDiagnostic(triple);
    }
}
项目:xtext-extras    文件:AbstractUnresolvableReferenceWithNode.java   
@Override
public void applyToModel(IResolvedTypes resolvedTypes) {
    Resource resource = getExpression().eResource();
    if (resource instanceof LazyLinkingResource) {
        LazyLinkingResource lazyLinkingResource = (LazyLinkingResource) resource;

        TypeAwareLinkingDiagnosticContext context = new TypeAwareLinkingDiagnosticContext(this, resolvedTypes);
        DiagnosticMessage message = lazyLinkingResource.getDiagnosticMessageProvider()
                .getUnresolvedProxyMessage(context);
        if (message != null) {
            List<Resource.Diagnostic> diagnostics = getDiagnosticList(lazyLinkingResource, message);
            Diagnostic diagnostic = createDiagnostic(message);
            diagnostics.add(diagnostic);
        }
        EObject referenced = (InternalEObject) getExpression().eGet(getReference(), false);
        lazyLinkingResource.markUnresolvable(referenced);
    }
}
项目:xtext-extras    文件:BatchLinkableResource.java   
@Override
protected EObject handleCyclicResolution(Triple<EObject, EReference, INode> triple) throws AssertionError {
    if (!isValidationDisabled()) {
        EObject context = triple.getFirst();
        if (context.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
            // here we may end up with cyclic resolution requests in rare situations, e.g. for input types
            // like :
            /*
             * package p;
             * class C extends p.C.Bogus {}
             */
            return null;
        }
        DiagnosticMessage message = new DiagnosticMessage("Cyclic linking detected : " + getReferences(triple, resolving), Severity.ERROR, "cyclic-resolution");
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
    return null;
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@Test
public void defaultModesOK() {
  ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
  LexerCommand command = createMock(LexerCommand.class);
  LexerCommands commands = createMock(LexerCommands.class);

  expect(diagnosticContext.getLinkText()).andReturn("HIDDEN");
  expect(diagnosticContext.getContext()).andReturn(command);

  expect(command.eContainer()).andReturn(commands);

  Object[] mocks = {diagnosticContext, command, commands };

  replay(mocks);

  DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider()
      .getUnresolvedProxyMessage(diagnosticContext);
  assertNull(message);

  verify(mocks);
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@Test
public void undefinedMode() {
  ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
  LexerCommand command = createMock(LexerCommand.class);
  LexerCommands commands = createMock(LexerCommands.class);

  expect(diagnosticContext.getLinkText()).andReturn("INSIDE");
  expect(diagnosticContext.getContext()).andReturn(command);

  expect(command.eContainer()).andReturn(commands);

  Object[] mocks = {diagnosticContext, command, commands };

  replay(mocks);

  DiagnosticMessage message = new Antlr4MissingReferenceMessageProvider()
      .getUnresolvedProxyMessage(diagnosticContext);
  assertNull(message);

  verify(mocks);
}
项目:DialogScriptDSL    文件:CustomLinkingDiagnosticMessageProvider.java   
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;
}
项目:n4js    文件:N4JSScopingInstanceOfPrimitivTypeDiagnosis.java   
/**
 * Creates a {@link DiagnosticMessage} for instanceof expressions where the right-hand-side is a primitive type
 * identifier.
 *
 * It is assumed that the given qualified name was extracted from the {@link IdentifierRef} on the rhs of the given
 * relational expression.
 *
 * Returns null if not applicable.
 *
 * @param name
 *            The unresolved name of an IdentifierRef on the RHS of the expression.
 *
 * @param expression
 *            A pair of the instanceof-expression and the unresolved IdentifierRef.
 */
@Override
DiagnosticMessage diagnose(QualifiedName name, RelationalExpression expression) {
    // only applicable for the instanceof operator
    if (expression.getOp() != RelationalOperator.INSTANCEOF) {
        return null;
    }

    // query built-in type scope for the unresolved name
    BuiltInTypeScope builtInTypeScope = BuiltInTypeScope.get(expression.eResource().getResourceSet());
    IEObjectDescription singleElement = builtInTypeScope.getSingleElement(name);

    // if there is no primitive type with this name, this diagnosis is not applicable
    if (null == singleElement) {
        return null;
    }

    // if we can find a primitive type for the qualified name
    if (singleElement.getEClass().getClassifierID() == TypesPackage.Literals.PRIMITIVE_TYPE.getClassifierID()) {
        // create special error message
        return createMessage(IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES,
                IssueCodes.getMessageForTYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES());
    } else {
        // the found element is not a primitive type, diagnosis not applicable
        return null;
    }

}
项目:n4js    文件:N4JSScopingConsumableMethodsDiagnosis.java   
@Override
DiagnosticMessage diagnose(QualifiedName name, ParameterizedPropertyAccessExpression propertyAccess) {
    // determine containing member declaration and classifier definition
    N4MemberDeclaration containingMemberDeclaration = EcoreUtil2.getContainerOfType(propertyAccess,
            N4MemberDeclaration.class);
    N4ClassifierDefinition classifierDefinition = EcoreUtil2.getContainerOfType(containingMemberDeclaration,
            N4ClassifierDefinition.class);

    // if ancestors present and non-static context (no super in static context)
    if (containingMemberDeclaration != null &&
            !containingMemberDeclaration.isStatic() &&
            classifierDefinition != null) {

        // Get candidate methods
        MemberList<TMember>.MemberIterable<TMethod> methods = containerTypesHelper.fromContext(propertyAccess)
                .membersOfImplementedInterfacesForConsumption((TClassifier) classifierDefinition.getDefinedType())
                .methods();

        boolean hasMethod = methods.stream()
                .filter(m -> !m.isHasNoBody() && !m.isStatic()) // Filter for non-static non-abstract methods
                .anyMatch(m -> m.getName().equals(name.toString()));

        if (hasMethod) {
            return createMessage(IssueCodes.CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER,
                    IssueCodes.getMessageForCLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER());
        }
    }
    return null;
}
项目:xtext-extras    文件:AbstractUnresolvableReferenceWithNode.java   
protected Resource.Diagnostic createDiagnostic(DiagnosticMessage message) {
    Diagnostic diagnostic = new XtextLinkingDiagnostic(
            node, 
            message.getMessage(),
            message.getIssueCode(), message.getIssueData());
    return diagnostic;
}
项目:xtext-extras    文件:AbstractUnresolvableReferenceWithNode.java   
protected List<Diagnostic> getDiagnosticList(LazyLinkingResource resource, /* @Nullable */ DiagnosticMessage message) throws AssertionError {
    if (message != null) {
        switch (message.getSeverity()) {
            case ERROR:
                return resource.getErrors();
            case WARNING:
                return resource.getWarnings();
            default:
                throw new AssertionError("Unexpected severity: " + message.getSeverity());
        }
    }
    return Collections.emptyList();
}
项目:xtext-core    文件:TransformationDiagnosticsProducer.java   
@Override
public void acceptError(TransformationErrorCode errorCode, String message, EObject element) {
    setTarget(element, null);
    lastError = errorCode;
    addDiagnostic(new DiagnosticMessage(message, Severity.ERROR, null));    
    lastError = null;
}
项目:xtext-core    文件:XtextLinkingDiagnosticMessageProvider.java   
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {
    DiagnosticMessage diagnosticMessage = new XtextSwitch<DiagnosticMessage>() {
        @Override
        public DiagnosticMessage caseRuleCall(RuleCall ruleCall) {
            return new DiagnosticMessage(context.getLinkText()+" cannot be resolved to a rule", Severity.ERROR,
                    UNRESOLVED_RULE, context.getLinkText());
        }

    }.doSwitch(context.getContext());
    return diagnosticMessage != null ? diagnosticMessage : super.getUnresolvedProxyMessage(context);
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
    if (isValidationDisabled())
        return;
    DiagnosticMessage message = createDiagnosticMessage(triple);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
/**
 * @since 2.3
 */
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple, IllegalNodeException ex) {
    if (isValidationDisabled())
        return;
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = linkingDiagnosticMessageProvider.getIllegalNodeMessage(context, ex);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected void removeDiagnostic(Triple<EObject, EReference, INode> triple) {
    // return early if there's nothing to remove
    if (getErrors().isEmpty() && getWarnings().isEmpty())
        return;
    DiagnosticMessage message = createDiagnosticMessage(triple);
    List<Diagnostic> list = getDiagnosticList(message);
    if (!list.isEmpty()) {
        Diagnostic diagnostic = createDiagnostic(triple, message);
        list.remove(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected List<Diagnostic> getDiagnosticList(DiagnosticMessage message) throws AssertionError {
    if (message != null) {
        switch (message.getSeverity()) {
            case ERROR:
                return getErrors();
            case WARNING:
                return getWarnings();
            default:
                throw new AssertionError("Unexpected severity: " + message.getSeverity());
        }
    }
    return Collections.emptyList();
}
项目:xtext-core    文件:LinkingDiagnosticMessageProvider.java   
@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);
}
项目:xtext-core    文件:LinkingDiagnosticMessageProvider.java   
@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);
}
项目:statecharts    文件:AbstractSCTResource.java   
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);

}
项目:PHDL    文件:PhdlLinkingDiagnosticMessageProvider.java   
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {

    EObject object = context.getContext();
    if (object instanceof ConnectionRef) {
        return new DiagnosticMessage("Missing connection declaration", Severity.ERROR,
                IssueCodes.MISSING_CONNECTION_DECL, context.getLinkText());
    }
    return super.getUnresolvedProxyMessage(context);
}
项目:gama    文件:GamlLinkingErrorMessageProvider.java   
@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);
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@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);
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@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);
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@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);
}
项目:antlr4ide    文件:Antlr4MissingReferenceMessageProviderTest.java   
@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);
}
项目:n4js    文件:ASTStructureDiagnosticProducer.java   
@Override
protected Diagnostic createDiagnostic(DiagnosticMessage message) {
    return new XtextLinkingDiagnostic(getNode(), message.getMessage(), message.getIssueCode(),
            message.getIssueData());
}
项目:n4js    文件:N4JSLinker.java   
/**
 * Creates the proxy with a custom encoded URI format (starting with "|"). The object used to produce the encoded
 * URI are collected as tuple inside {@link N4JSResource}. Then the node text is checked if it is convertible to a
 * valid value. If there is a {@link BadEscapementException} is thrown then there is either a warning or an error
 * produced via the diagnosticProducer.
 *
 *
 * @param resource
 *            the N4JSResource
 * @param obj
 *            the EObject containing the cross reference
 * @param node
 *            the node representing the EObject
 * @param eRef
 *            the cross reference in the domain model
 * @param xref
 *            the cross reference in the node model
 * @param diagnosticProducer
 *            to produce errors or warnings
 * @return the created proxy
 */
private EObject createProxy(N4JSResource resource, EObject obj, INode node, EReference eRef, CrossReference xref,
        IDiagnosticProducer diagnosticProducer) {
    final URI uri = resource.getURI();
    /*
     * as otherwise with 0 the EObjectDescription created for Script would be fetched
     */
    final int fragmentNumber = resource.addLazyProxyInformation(obj, eRef, node);
    final URI encodedLink = uri.appendFragment("|" + fragmentNumber);
    EClass referenceType = findInstantiableCompatible(eRef.getEReferenceType());
    final EObject proxy = EcoreUtil.create(referenceType);
    ((InternalEObject) proxy).eSetProxyURI(encodedLink);
    AbstractElement terminal = xref.getTerminal();
    if (!(terminal instanceof RuleCall)) {
        throw new IllegalArgumentException(String.valueOf(xref));
    }
    AbstractRule rule = ((RuleCall) terminal).getRule();
    try {
        String tokenText = NodeModelUtils.getTokenText(node);
        Object value = valueConverterService.toValue(tokenText, rule.getName(), node);
        if (obj instanceof IdentifierRef && value instanceof String) {
            ((IdentifierRef) obj).setIdAsText((String) value);
        } else if (obj instanceof LabelRef && value instanceof String) {
            ((LabelRef) obj).setLabelAsText((String) value);
        } else if (obj instanceof ParameterizedPropertyAccessExpression && value instanceof String) {
            ((ParameterizedPropertyAccessExpression) obj).setPropertyAsText((String) value);
        } else if (obj instanceof NamedImportSpecifier && value instanceof String) {
            ((NamedImportSpecifier) obj).setImportedElementAsText((String) value);
        } else if ((obj instanceof JSXPropertyAttribute) && (value instanceof String)) {
            ((JSXPropertyAttribute) obj).setPropertyAsText((String) value);
        } else {
            setOtherElementAsText(tokenText, obj, value);
        }
    } catch (BadEscapementException e) {
        diagnosticProducer.addDiagnostic(new DiagnosticMessage(e.getMessage(), e.getSeverity(), e.getIssueCode(),
                Strings.EMPTY_ARRAY));
    } catch (N4JSValueConverterException vce) {
        diagnosticProducer.addDiagnostic(new DiagnosticMessage(vce.getMessage(), vce.getSeverity(),
                vce.getIssueCode(), Strings.EMPTY_ARRAY));
    } catch (N4JSValueConverterWithValueException vcwve) {
        diagnosticProducer.addDiagnostic(new DiagnosticMessage(vcwve.getMessage(), vcwve.getSeverity(),
                vcwve.getIssueCode(), Strings.EMPTY_ARRAY));
    }
    return proxy;
}
项目:xtext-extras    文件:UnresolvedAnnotationTypeAwareMessageProvider.java   
@Override
public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
    if (isPropertyOfUnresolvedAnnotation(context))
        return null;
    return super.getUnresolvedProxyMessage(context);
}
项目:xtext-extras    文件:UnresolvedFeatureCallTypeAwareMessageProvider.java   
@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);
}
项目:xtext-core    文件:TransformationDiagnosticsProducer.java   
@Override
protected Diagnostic createDiagnostic(DiagnosticMessage message) {
    return new TransformationDiagnostic(getNode(), message.getMessage(), lastError);
}
项目:xtext-core    文件:XtextLinker.java   
@Override
protected void setDefaultValueImpl(EObject obj, EReference ref, IDiagnosticProducer producer) {
    if (XtextPackage.eINSTANCE.getTypeRef_Metamodel() == ref) {
        final TypeRef typeRef = (TypeRef) obj;
        final String typeRefName = GrammarUtil.getTypeRefName(typeRef);
        final List<EObject> metamodels = XtextMetamodelReferenceHelper.findBestMetamodelForType(typeRef, "",
                typeRefName, scopeProvider.getScope(typeRef, ref));
        if (metamodels.isEmpty() || metamodels.size() > 1)
            producer.addDiagnostic(new DiagnosticMessage("Cannot find meta model for type '" + typeRefName + "'", Severity.ERROR, null));
        else
            typeRef.setMetamodel((AbstractMetamodelDeclaration) metamodels.get(0));
    } else if (XtextPackage.eINSTANCE.getCrossReference_Terminal() == ref) {
        AbstractRule rule = GrammarUtil.findRuleForName(GrammarUtil.getGrammar(obj), "ID");
        if (rule == null)
            producer.addDiagnostic(new DiagnosticMessage("Cannot resolve implicit reference to rule 'ID'", Severity.ERROR, null));
        else {
            RuleCall call = XtextFactory.eINSTANCE.createRuleCall();
            call.setRule(rule);
            ((CrossReference) obj).setTerminal(call);
        }
    } else if (XtextPackage.eINSTANCE.getNamedArgument_Parameter() == ref) {
        final NamedArgument argument = (NamedArgument) obj;
        if (!argument.isCalledByName()) {
            RuleCall ruleCall = EcoreUtil2.getContainerOfType(argument, RuleCall.class);
            AbstractRule calledRule = ruleCall.getRule();
            if (!(calledRule instanceof ParserRule)) {
                producer.addDiagnostic(new DiagnosticMessage("Arguments can only be used with parser rules.", Severity.ERROR, null));   
                return;
            }
            if (!calledRule.eIsProxy()) {
                ParserRule casted = (ParserRule) calledRule;
                int idx = ruleCall.getArguments().indexOf(argument);
                if (idx < casted.getParameters().size()) {
                    argument.setParameter(casted.getParameters().get(idx));
                    return;
                } else if (casted.getParameters().size() == 0) {
                    producer.addDiagnostic(new DiagnosticMessage(
                            "Rule " + calledRule.getName() + " has no arguments.", Severity.ERROR, null));
                } else {
                    String message = "Invalid number of arguments for rule " + calledRule.getName() + ", expecting "
                            + casted.getParameters().size() + " but was " + (idx+1);
                    producer.addDiagnostic(new DiagnosticMessage(message, Severity.ERROR, null));
                }
            }
        }
    } else {
        super.setDefaultValueImpl(obj, ref, producer);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected Diagnostic createDiagnostic(Triple<EObject, EReference, INode> triple, DiagnosticMessage message) {
    Diagnostic diagnostic = new XtextLinkingDiagnostic(triple.getThird(), message.getMessage(),
            message.getIssueCode(), message.getIssueData());
    return diagnostic;
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected DiagnosticMessage createDiagnosticMessage(Triple<EObject, EReference, INode> triple) {
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = diagnosticMessageProvider.getUnresolvedProxyMessage(context);
    return message;
}
项目:xtext-core    文件:LinkingDiagnosticProducer.java   
@Override
protected Diagnostic createDiagnostic(DiagnosticMessage message) {
    return new XtextLinkingDiagnostic(getNode(), message.getMessage(), message.getIssueCode(), message.getIssueData());
}
项目:xtext-core    文件:LinkingDiagnosticMessageProvider.java   
@Override
public DiagnosticMessage getIllegalNodeMessage(ILinkingDiagnosticContext context, IllegalNodeException ex) {
    String message = ex.getMessage();
    return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
项目:xtext-core    文件:LinkingDiagnosticMessageProvider.java   
@Override
public DiagnosticMessage getIllegalCrossReferenceMessage(ILinkingDiagnosticContext context, CrossReference reference) {
    String message = "Cannot find reference " + reference;
    return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
项目:xtext-core    文件:LinkingDiagnosticMessageProvider.java   
@Override
public DiagnosticMessage getViolatedUniqueConstraintMessage(ILinkingDiagnosticContext context) {
    String message = "Cannot refer to '" + context.getLinkText() + "' more than once.";
    return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}
项目:xtext-core    文件:LinkingWarningsTest.java   
@Override
public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
    return new DiagnosticMessage(expected, Severity.WARNING, Diagnostic.LINKING_DIAGNOSTIC);
}
项目:statecharts    文件:AbstractSCTResource.java   
protected DiagnosticMessage createDiagnosticMessage(Triple<EObject, EReference, INode> triple) {
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = diagnosticMessageProvider.getUnresolvedProxyMessage(context);
    return message;
}
项目:gama    文件:GamlLinkingErrorMessageProvider.java   
@Override
public DiagnosticMessage getIllegalNodeMessage(final ILinkingDiagnosticContext context,
        final IllegalNodeException ex) {
    final String message = ex.getMessage();
    return new DiagnosticMessage(message, Severity.ERROR, Diagnostic.LINKING_DIAGNOSTIC);
}