org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrossReferenceProposalTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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());
		}
	}
}
 
Example #2
Source File: GamlUiModule.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings ("unchecked")
@Override
public void configure(final Binder binder) {

	super.configure(binder);
	binder.bind(String.class).annotatedWith(
			com.google.inject.name.Names.named(XtextContentAssistProcessor.COMPLETION_AUTO_ACTIVATION_CHARS))
			.toInstance(".");
	binder.bind(IContentAssistParser.class).to((Class<? extends IContentAssistParser>) GamlParser.class);
	binder.bind(Lexer.class).annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
			.to(InternalGamlLexer.class);
	binder.bind(IResourceLoader.class).toProvider(ResourceLoaderProviders.getParallelLoader());
	binder.bind(IResourceClusteringPolicy.class).to(DynamicResourceClusteringPolicy.class);
	binder.bind(IModelRunner.class).to(ModelRunner.class);
	// binder.bind(XtextDocumentProvider.class).to(XtextDocumentProvider.class);
	binder.bind(IMarkerUpdater.class).to(GamlMarkerUpdater.class);
	binder.bind(IGamlLabelProvider.class).to(GamlLabelProvider.class);
}
 
Example #3
Source File: CrossReferenceProposalTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@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());
	}
}
 
Example #4
Source File: XtextUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder) {
	super.configure(binder);
	binder.bind(String.class)
			.annotatedWith(Names.named(XtextContentAssistProcessor.COMPLETION_AUTO_ACTIVATION_CHARS))
			.toInstance("[{");
}
 
Example #5
Source File: BromiumUiModule.java    From bromium with MIT License 4 votes vote down vote up
@Override
public void configure(final Binder binder) {
  super.configure(binder);
  binder.<String>bind(String.class).annotatedWith(
    Names.named(XtextContentAssistProcessor.COMPLETION_AUTO_ACTIVATION_CHARS)).toInstance("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.");
}
 
Example #6
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IContentAssistProcessor> bindIContentAssistProcessor() {
	return XtextContentAssistProcessor.class;
}