use of org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor 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());
}
}
}
use of org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor in project xtext-eclipse by eclipse.
the class CrossReferenceProposalTest method testBug276742_09b.
@Test
public void testBug276742_09b() 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, 0, resource);
assertEquals(1, contexts.length);
for (ContentAssistContext context : contexts) {
assertEquals(CrossReferenceProposalTestPackage.Literals.MODEL, context.getCurrentModel().eClass());
}
}
Aggregations