Search in sources :

Example 1 with ISemanticHighlightingCalculator

use of org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator in project xtext-eclipse by eclipse.

the class SemanticHighlightingTest method highlight.

protected void highlight(String grammar) {
    try {
        XtextResource resource = getResourceFromString(grammar);
        ISemanticHighlightingCalculator calculator = get(ISemanticHighlightingCalculator.class);
        calculator.provideHighlightingFor(resource, this, CancelIndicator.NullImpl);
        assertTrue(expectedRegions.toString(), expectedRegions.isEmpty());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) ISemanticHighlightingCalculator(org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator)

Example 2 with ISemanticHighlightingCalculator

use of org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator in project xtext-eclipse by eclipse.

the class SemanticHighlightingTest method testNullPointerOnInvalidReturnKeyword.

@Test
public void testNullPointerOnInvalidReturnKeyword() throws Exception {
    XtextResource resource = getResourceFromStringAndExpect("grammar test with org.eclipse.xtext.common.Terminals\n" + "import 'http://www.eclipse.org/emf/2002/Ecore'\n" + "terminal fragment FOO returns EString: 'a';", 1);
    ISemanticHighlightingCalculator calculator = get(ISemanticHighlightingCalculator.class);
    calculator.provideHighlightingFor(resource, new IHighlightedPositionAcceptor() {

        @Override
        public void addPosition(int offset, int length, String... id) {
        // ignore
        }
    }, CancelIndicator.NullImpl);
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) ISemanticHighlightingCalculator(org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator) IHighlightedPositionAcceptor(org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor) Test(org.junit.Test)

Aggregations

ISemanticHighlightingCalculator (org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 IHighlightedPositionAcceptor (org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor)1 Test (org.junit.Test)1