Search in sources :

Example 1 with CrossReferenceProposalTestLanguageGrammarAccess

use of org.eclipse.xtext.ui.tests.editor.contentassist.services.CrossReferenceProposalTestLanguageGrammarAccess in project xtext-eclipse by eclipse.

the class CrossReferenceProposalTest method testBug276742_08b.

@Test
public void testBug276742_08b() throws Exception {
    String modelAsString = "Foo {}";
    ContentAssistProcessorTestBuilder builder = newBuilder();
    XtextContentAssistProcessor processor = get(XtextContentAssistProcessor.class);
    XtextResource resource = getResourceFromString(modelAsString);
    ITextViewer viewer = builder.getSourceViewer(modelAsString, builder.getDocument(resource, modelAsString));
    ContentAssistContext[] contexts = processor.getContextFactory().create(viewer, modelAsString.length(), resource);
    assertEquals(2, contexts.length);
    Set<EClass> contextTypes = Sets.newHashSet(CrossReferenceProposalTestPackage.Literals.MODEL, CrossReferenceProposalTestPackage.Literals.CLASS);
    CrossReferenceProposalTestLanguageGrammarAccess grammarAccess = get(CrossReferenceProposalTestLanguageGrammarAccess.class);
    for (ContentAssistContext context : contexts) {
        EObject model = context.getCurrentModel();
        assertTrue(contextTypes.remove(model.eClass()));
        if (context.getFirstSetGrammarElements().contains(grammarAccess.getClassAccess().getRightCurlyBracketKeyword_3())) {
            assertEquals(CrossReferenceProposalTestPackage.Literals.CLASS, model.eClass());
        } else {
            assertEquals(CrossReferenceProposalTestPackage.Literals.MODEL, model.eClass());
        }
    }
}
Also used : XtextContentAssistProcessor(org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor) CrossReferenceProposalTestLanguageGrammarAccess(org.eclipse.xtext.ui.tests.editor.contentassist.services.CrossReferenceProposalTestLanguageGrammarAccess) ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) EClass(org.eclipse.emf.ecore.EClass) ContentAssistContext(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext) EObject(org.eclipse.emf.ecore.EObject) XtextResource(org.eclipse.xtext.resource.XtextResource) ITextViewer(org.eclipse.jface.text.ITextViewer) Test(org.junit.Test)

Aggregations

EClass (org.eclipse.emf.ecore.EClass)1 EObject (org.eclipse.emf.ecore.EObject)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 ContentAssistContext (org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext)1 XtextContentAssistProcessor (org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor)1 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)1 CrossReferenceProposalTestLanguageGrammarAccess (org.eclipse.xtext.ui.tests.editor.contentassist.services.CrossReferenceProposalTestLanguageGrammarAccess)1 Test (org.junit.Test)1