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());
}
}
}
Aggregations