Java 类org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext 实例源码

项目: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);
}
项目: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);
    }
}
项目: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);
}
项目:xtext-extras    文件:TypeAwareLinkingDiagnosticContext.java   
public TypeAwareLinkingDiagnosticContext(ILinkingDiagnosticContext delegate, IResolvedTypes resolvedTypes) {
    this.delegate = delegate;
    this.resolvedTypes = resolvedTypes;
}
项目: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    文件:LazyLinkingResource.java   
protected ILinkingDiagnosticContext createDiagnosticMessageContext(Triple<EObject, EReference, INode> triple) {
    return new DiagnosticMessageContext(triple, linkingHelper);
}
项目:xtext-core    文件:Linker.java   
protected ILinkingDiagnosticContext createDiagnosticContext(EObject obj, EReference eRef, INode node) {
    return new LinkingDiagnosticContext(obj, eRef, node, linkingHelper);
}
项目:statecharts    文件:AbstractSCTResource.java   
protected DiagnosticMessage createDiagnosticMessage(Triple<EObject, EReference, INode> triple) {
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = diagnosticMessageProvider.getUnresolvedProxyMessage(context);
    return message;
}
项目:statecharts    文件:AbstractSCTResource.java   
protected ILinkingDiagnosticContext createDiagnosticMessageContext(Triple<EObject, EReference, INode> triple) {
    return new DiagnosticMessageContext(triple, linkingHelper);
}