类org.eclipse.jface.text.contentassist.ContentAssistant源码实例Demo

下面列出了怎么用org.eclipse.jface.text.contentassist.ContentAssistant的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: texlipse   文件: BibSourceViewerConfiguration.java
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    assistant = new ContentAssistant();
    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    
    assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()),
            BibPartitionScanner.BIB_ENTRY);
    assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()),
            IDocument.DEFAULT_CONTENT_TYPE);

    assistant.enableAutoActivation(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BIB_COMPLETION));
    assistant.enableAutoInsert(true);
    assistant.setAutoActivationDelay(TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.BIB_COMPLETION_DELAY));
    assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
    return assistant;
}
 
源代码2 项目: tlaplus   文件: TLASourceViewerConfiguration.java
/**
   * Content assistant
   */
  public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
  {
      ContentAssistant assistant = new ContentAssistant();
      assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
      assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
      assistant.setContentAssistProcessor(new PCalCompletionProcessor(), TLAPartitionScanner.TLA_PCAL);
      assistant.enableColoredLabels(true);
      assistant.enableAutoActivation(true);
      assistant.setAutoActivationDelay(500);
assistant.setInformationControlCreator(new IInformationControlCreator() {
	public IInformationControl createInformationControl(final Shell parent) {
		return new DefaultInformationControl(parent, (DefaultInformationControl.IInformationPresenter) null);
	}
});
assistant.setSorter(new ICompletionProposalSorter() {
	public int compare(ICompletionProposal p1, ICompletionProposal p2) {
		return 0;
	}
});
      assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
      assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
      assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor(
              TLAColorProvider.CONTENT_ASSIST_BACKGROUND_KEY));
      return assistant;
  }
 
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant ca = new ContentAssistant();
    JsonContentAssistProcessor processor = createContentAssistProcessor(ca);

    ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    ca.enableAutoInsert(false);
    ca.enablePrefixCompletion(false);
    ca.enableAutoActivation(true);
    ca.setAutoActivationDelay(100);
    ca.enableColoredLabels(true);
    ca.setShowEmptyList(true);
    ca.setRepeatedInvocationMode(true);
    ca.addCompletionListener(processor);
    ca.setStatusLineVisible(true);

    return ca;
}
 
public void assistSessionEnded(ContentAssistEvent event) {
	if (event.processor != ContentAssistProcessor.this)
		return;

	for (CompletionProposalCategory cat : getCategoriesToNotify()) {
		cat.sessionEnded();
	}

	fCategoryIteration= null;
	fRepetition= -1;
	fIterationGesture= null;
	if (event.assistant instanceof IContentAssistantExtension2) {
		IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;
		extension.setShowEmptyList(false);
		extension.setRepeatedInvocationMode(false);
		extension.setStatusLineVisible(false);
		if (extension instanceof IContentAssistantExtension3) {
			IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
			((ContentAssistant) ext3).setRepeatedInvocationTrigger(null);
		}
	}
}
 
public TaskSourceViewerConfiguration(IPreferenceStore preferenceStore) {
	super(preferenceStore);
	
	// Initialize ContentAssistant
	contentAssistant = new ContentAssistant();
	
	// define a default ContentAssistProcessor
	contentAssistant.setContentAssistProcessor (new TaskCompletionProcessor(), 
			IDocument.DEFAULT_CONTENT_TYPE);
	
	// enable auto activation
	contentAssistant.enableAutoActivation(true);
	
	// set a proper orientation for the content assist proposal
	contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
}
 
源代码6 项目: birt   文件: SQLSourceViewerConfiguration.java
public IContentAssistant getContentAssistant( ISourceViewer sourceViewer )
{
	if ( !enableCodeAssist )
	{
		return null;
	}
	ContentAssistant assistant = new ContentAssistant( );
	JdbcSQLContentAssistProcessor contentAssist = new JdbcSQLContentAssistProcessor( timeout );
	contentAssist.setDataSourceHandle( dsd );
	assistant.setContentAssistProcessor( contentAssist,
			IDocument.DEFAULT_CONTENT_TYPE );
	assistant.enableAutoActivation( true );
	assistant.setAutoActivationDelay( 500 );
	assistant.setProposalPopupOrientation( IContentAssistant.PROPOSAL_OVERLAY );
	return assistant;
}
 
源代码7 项目: goclipse   文件: ContentAssistPreferenceHandler.java
protected void setAutoActivationTriggers(ContentAssistant assistant, 
		@SuppressWarnings("unused") IPreferenceStore store) {
	LangContentAssistProcessor jcp = getLangContentAssistProcessor(assistant);
	if(jcp == null)
		return;
	
	String triggers = "";
	if(AUTO_ACTIVATE__DotTrigger.get()) {
		triggers += ".";
	}
	if(AUTO_ACTIVATE__DoubleColonTrigger.get()) {
		triggers += ":"; // Not perfect match, will match single colons too...
	}
	if(AUTO_ACTIVATE__AlphaNumericTrigger.get()) {
		triggers +="abcdefghijklmnopqrstuvwxyz";
		triggers +="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	}
	
	if(triggers != null) {
		jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
	}
}
 
@Override
public ContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
	if(sourceViewer instanceof LangSourceViewer) {
		LangSourceViewer langSourceViewer = (LangSourceViewer) sourceViewer;
		
		ContentAssistantExt assistant = createContentAssitant(langSourceViewer);
		assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
		
		assistant.setRestoreCompletionProposalSize(LangUIPlugin.getDialogSettings("completion_proposal_size"));
		assistant.setInformationControlCreator(
			getInformationControl_ContentAsssist(getAdditionalInfoAffordanceString()));
		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.enableColoredLabels(true);
		
		configureContentAssistantProcessors(assistant);
		// Note: configuration must come after processors are created
		assistant.configure();
		
		return assistant;
	}
	
	return null;
}
 
源代码9 项目: bonita-studio   文件: BonitaGroovyConfiguration.java
@SuppressWarnings("unchecked")
@Override
public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) {
    // returns only Groovy-approved completion proposal categories
    ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer);
    assistant.setStatusLineVisible(false);

    // retain only relevant categories
    IContentAssistProcessor processor = assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);

    List<CompletionProposalCategory> categories = (List<CompletionProposalCategory>) ReflectionUtils
            .getPrivateField(ContentAssistProcessor.class, "fCategories", processor);

    ReflectionUtils.setPrivateField(ContentAssistProcessor.class, "fCategories", processor, categories.stream()
            .filter(category -> ALLOWED_CATEGORIES.contains(category.getId()))
            .collect(Collectors.toList()));

    ContentAssistPreference.configure(assistant, fPreferenceStore);

    return assistant;
}
 
@Override
public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) {
    // returns only Groovy-approved completion proposal categories
    ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer);
    assistant.enableAutoActivation(true);
    assistant.setStatusLineVisible(false);

    // retain only contract input categories
    final ExtendedJavaCompletionProcessor processor = new ExtendedJavaCompletionProcessor(getEditor(), assistant,
            IDocument.DEFAULT_CONTENT_TYPE);
    assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    List<CompletionProposalCategory> categories = (List<CompletionProposalCategory>) ReflectionUtils
            .getPrivateField(ContentAssistProcessor.class, "fCategories", processor);

    ReflectionUtils.setPrivateField(ContentAssistProcessor.class, "fCategories", processor, categories.stream()
            .filter(category -> Objects.equals(category.getId(), CONSTRAINT_CONTENT_ASSIST_CATEGORY_ID))
            .collect(Collectors.toList()));

    ContentAssistPreference.configure(assistant, fPreferenceStore);

    return assistant;
}
 
源代码11 项目: n4js   文件: ContentAssistantFactory.java
@Override
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	super.setContentAssistProcessor(assistant, configuration, sourceViewer);
	assistant.setContentAssistProcessor(jsDocContentAssistProcessor, TokenTypeToPartitionMapper.JS_DOC_PARTITION);
	assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.REG_EX_PARTITION);
	assistant.setContentAssistProcessor(null, TokenTypeToPartitionMapper.TEMPLATE_LITERAL_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
}
 
源代码12 项目: http4e   文件: XMLConfiguration.java
public IContentAssistant getContentAssistant( ISourceViewer sourceViewer){
    
    ContentAssistant assistant = new ContentAssistant();
    
    assistant.setContentAssistProcessor(new TagContentAssistProcessor(
            getXMLTagScanner()), XMLPartitionScanner.XML_START_TAG);
    assistant.enableAutoActivation(true);
    assistant.setAutoActivationDelay(500);
    assistant
            .setProposalPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW);
    assistant
            .setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW);
    return assistant;
    
}
 
@Override
public IContentAssistant createConfiguredAssistant(SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	ContentAssistant assistant = createAssistant();
	configureContentAssistant(assistant, configuration, sourceViewer);
	return assistant;
}
 
private void configureDefaults(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
	setAutoInsert(assistant);
	setAutoActivation(assistant);
	setContentAssistProcessor(assistant, configuration, sourceViewer);
	setInformationControlCreator(assistant, configuration, sourceViewer);
	setDialogSettings(assistant);
	setColoredLabels(assistant);
}
 
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
	if (contentAssistProcessor != null) {
		for(String contentType: configuration.getConfiguredContentTypes(sourceViewer)) {
			assistant.setContentAssistProcessor(contentAssistProcessor, contentType);
		}
		if (contentAssistProcessor instanceof ICompletionListener) {
			assistant.setRepeatedInvocationMode(true);
			assistant.setStatusLineVisible(true);
			assistant.addCompletionListener((ICompletionListener) contentAssistProcessor);
		}
	}
}
 
源代码16 项目: texlipse   文件: TexSourceViewerConfiguration.java
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
        
//        ContentAssistant assistant = new ContentAssistant();
        assistant = new ContentAssistant();
        assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        
        // note that partitioning affects completions
        //TexCompletionProcessor tcp = new TexCompletionProcessor(this.editor.getDocumentModel());
        TexCompletionProcessor tcp = new TexCompletionProcessor(this.editor.getDocumentModel(), sourceViewer);
        TexMathCompletionProcessor tmcp = new TexMathCompletionProcessor(this.editor.getDocumentModel(), sourceViewer);
//        assistant.setContentAssistProcessor(new TexCompletionProcessor(this.editor.getDocumentModel()),
//                IDocument.DEFAULT_CONTENT_TYPE);

        assistant.setContentAssistProcessor(tcp, IDocument.DEFAULT_CONTENT_TYPE);
        //assistant.setContentAssistProcessor(tcp, TexPartitionScanner.TEX_MATH);
        assistant.setContentAssistProcessor(tmcp, FastLaTeXPartitionScanner.TEX_MATH);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_CURLY_BRACKETS);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_SQUARE_BRACKETS);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_TIKZPIC);

        assistant.enableAutoActivation(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.TEX_COMPLETION));
        assistant.enableAutoInsert(true);
        assistant.setAutoActivationDelay(TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.TEX_COMPLETION_DELAY));
        
        assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
        assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
        assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

        return assistant;
    }
 
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
	
	ContentAssistant assistant = new ContentAssistant();
	assistant.enableAutoActivation(true);
	assistant.setAutoActivationDelay(300);
	assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
	assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
	assistant.enableAutoInsert(true);
	assistant.enablePrefixCompletion(true);
	
	IContentAssistProcessor pr = new ImpexInstructionContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_INSTRUCTION);
	
	//pr = new ImpexTypeAttributeContentAssistProcessor();
	pr = new ImpexTypeSystemContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_HEADER);
	
	pr = new ImpexDataContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_DATA);
	
	pr = new ImpexCommentContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_COMMENT);
	
	pr = new ImpexCommandContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, IDocument.DEFAULT_CONTENT_TYPE);
	
	assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
	return assistant;
}
 
源代码18 项目: xtext-xtend   文件: XtendContentAssistFactory.java
@Override
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	super.setContentAssistProcessor(assistant, configuration, sourceViewer);
	assistant.setContentAssistProcessor(javaDocContentAssistProcessor,TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
}
 
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

		IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
		JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
		IColorManager manager= textTools.getColorManager();					
		

		ContentAssistant assistant= new ContentAssistant();
		assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
			// Register the same processor for strings and single line comments to get code completion at the start of those partitions.
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_STRING);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_CHARACTER);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_DOC);

		assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
		assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
		assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
		assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.setInformationControlCreator(new IInformationControlCreator() {
			public IInformationControl createInformationControl(Shell parent) {
				return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
			}
		});

		Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);			
		assistant.setContextInformationPopupBackground(background);
		assistant.setContextSelectorBackground(background);
		assistant.setProposalSelectorBackground(background);

		Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
		assistant.setContextInformationPopupForeground(foreground);
		assistant.setContextSelectorForeground(foreground);
		assistant.setProposalSelectorForeground(foreground);
		
		return assistant;
	}
 
public TypeScriptCompletionProcessor(ITextEditor editor, ContentAssistant assistant, String partition) {
	super(editor, assistant, partition);
	this.editor = editor;
	assistant.setSorter(new ICompletionProposalSorter() {

		@Override
		public int compare(ICompletionProposal p1, ICompletionProposal p2) {
			return RELEVANCE_SORTER.compare(p1, p2);
		}
	});
}
 
@Override
protected ContentAssistant createAssistant() {
	try {
		// Async ContentAssist is only available since Oxygen
		Constructor<ContentAssistant> asyncConstructor = ContentAssistant.class.getConstructor(Boolean.TYPE);
		return asyncConstructor.newInstance(true);
	} catch (Exception e) {
		return new ContentAssistant();
	}
}
 
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
  ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer);

  ICompilationUnit cu = ((GWTJavaEditor) getEditor()).getCompilationUnit();
  IContentAssistProcessor processor = new JsniCompletionProcessor(cu);
  assistant.setContentAssistProcessor(processor, GWTPartitions.JSNI_METHOD);

  return assistant;
}
 
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

	if (getEditor() != null) {

		ContentAssistant assistant= new ContentAssistant();
		assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

		assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$

		IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
		assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);

		ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
		assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);

		ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
		assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING);

		ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
		assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);

		ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
		assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC);

		ContentAssistPreference.configure(assistant, fPreferenceStore);

		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.setInformationControlCreator(new IInformationControlCreator() {
			public IInformationControl createInformationControl(Shell parent) {
				return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
			}
		});

		return assistant;
	}

	return null;
}
 
public void assistSessionStarted(ContentAssistEvent event) {
	if (event.processor != ContentAssistProcessor.this)
		return;

	fIterationGesture= getIterationGesture();
	KeySequence binding= getIterationBinding();

	// This may show the warning dialog if all categories are disabled
	setCategoryIteration();
	for (CompletionProposalCategory cat : getCategoriesToNotify()) {
		cat.sessionStarted();
	}

	fRepetition= 0;
	if (event.assistant instanceof IContentAssistantExtension2) {
		IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;

		if (fCategoryIteration.size() == 1) {
			extension.setRepeatedInvocationMode(false);
			extension.setShowEmptyList(false);
		} else {
			extension.setRepeatedInvocationMode(true);
			extension.setStatusLineVisible(true);
			extension.setStatusMessage(createIterationMessage());
			extension.setShowEmptyList(true);
			if (extension instanceof IContentAssistantExtension3) {
				IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
				((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
			}
		}

	}
}
 
public ContentAssistProcessor(ContentAssistant assistant, String partition) {
	Assert.isNotNull(partition);
	Assert.isNotNull(assistant);
	fPartition= partition;
	fComputerRegistry= CompletionProposalComputerRegistry.getDefault();
	fCategories= fComputerRegistry.getProposalCategories();
	fAssistant= assistant;
	fAssistant.addCompletionListener(new CompletionListener());
}
 
private static void configureJavaProcessor(ContentAssistant assistant, IPreferenceStore store) {
	JavaCompletionProcessor jcp= getJavaProcessor(assistant);
	if (jcp == null)
		return;

	String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVA);
	if (triggers != null)
		jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());

	boolean enabled= store.getBoolean(SHOW_VISIBLE_PROPOSALS);
	jcp.restrictProposalsToVisibility(enabled);

	enabled= store.getBoolean(CASE_SENSITIVITY);
	jcp.restrictProposalsToMatchingCases(enabled);
}
 
private static void configureJavaDocProcessor(ContentAssistant assistant, IPreferenceStore store) {
	JavadocCompletionProcessor jdcp= getJavaDocProcessor(assistant);
	if (jdcp == null)
		return;

	String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVADOC);
	if (triggers != null)
		jdcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());

	boolean enabled= store.getBoolean(CASE_SENSITIVITY);
	jdcp.restrictProposalsToMatchingCases(enabled);
}
 
private static void changeJavaDocProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
	JavadocCompletionProcessor jdcp= getJavaDocProcessor(assistant);
	if (jdcp == null)
		return;

	if (AUTOACTIVATION_TRIGGERS_JAVADOC.equals(key)) {
		String triggers= store.getString(AUTOACTIVATION_TRIGGERS_JAVADOC);
		if (triggers != null)
			jdcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
	} else if (CASE_SENSITIVITY.equals(key)) {
		boolean enabled= store.getBoolean(CASE_SENSITIVITY);
		jdcp.restrictProposalsToMatchingCases(enabled);
	}
}
 
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

	IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
	JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
	IColorManager manager= textTools.getColorManager();


	ContentAssistant assistant= new ContentAssistant();
	assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
		// Register the same processor for strings and single line comments to get code completion at the start of those partitions.
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_STRING);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_CHARACTER);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_DOC);

	assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
	assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
	assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
	assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
	assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
	assistant.setInformationControlCreator(new IInformationControlCreator() {
		public IInformationControl createInformationControl(Shell parent) {
			return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
		}
	});

	Color background= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, manager);
	assistant.setContextInformationPopupBackground(background);
	assistant.setContextSelectorBackground(background);

	Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, manager);
	assistant.setContextInformationPopupForeground(foreground);
	assistant.setContextSelectorForeground(foreground);

	return assistant;
}
 
源代码30 项目: sarl   文件: SARLContentAssistFactory.java
@Override
protected void setContentAssistProcessor(ContentAssistant assistant, SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	super.setContentAssistProcessor(assistant, configuration, sourceViewer);
	assistant.setContentAssistProcessor(this.javaDocContentAssistProcessor, TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION);
	assistant.setContentAssistProcessor(null, TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION);
}
 
 类所在包
 同包方法