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

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

源代码1 项目: eclipse-cs   文件: FileMatchPatternEditDialog.java
/**
 * Creates the content assistant.
 * 
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {

  final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();

  contentAssistant
          .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());

  IContentAssistProcessor processor = new RegExContentAssistProcessor(true);
  contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
  contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
  contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
    /*
     * @see org.eclipse.jface.text.IInformationControlCreator#
     * createInformationControl( org.eclipse.swt.widgets.Shell)
     */
    @Override
    public IInformationControl createInformationControl(Shell parent) {
      return new DefaultInformationControl(parent);
    }
  });

  return contentAssistant;
}
 
源代码2 项目: eclipse-cs   文件: CheckstyleMarkerFilterDialog.java
/**
 * Creates the content assistant.
 *
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {

  final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();

  contentAssistant.setRestoreCompletionProposalSize(
          CheckstyleUIPlugin.getDefault().getDialogSettings());

  IContentAssistProcessor processor = new RegExContentAssistProcessor(true);
  contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
  contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
  contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
    /*
     * @see org.eclipse.jface.text.IInformationControlCreator# createInformationControl(
     * org.eclipse.swt.widgets.Shell)
     */
    @Override
    public IInformationControl createInformationControl(Shell parent) {
      return new DefaultInformationControl(parent);
    }
  });

  return contentAssistant;
}
 
源代码3 项目: eclipse-cs   文件: ResolvablePropertyEditDialog.java
/**
 * Creates the content assistant.
 *
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {

  final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();

  contentAssistant
          .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());

  IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
  contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
  contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
  contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
    /*
     * @see IInformationControlCreator#createInformationControl(Shell)
     */
    @Override
    public IInformationControl createInformationControl(Shell parent) {
      return new DefaultInformationControl(parent);
    }
  });

  return contentAssistant;
}
 
源代码4 项目: eclipse-cs   文件: ConfigPropertyWidgetFile.java
/**
 * Creates the content assistant.
 * 
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {

  final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();

  contentAssistant
          .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());

  IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
  contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
  contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
  contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
    /*
     * @see IInformationControlCreator#createInformationControl(Shell)
     */
    @Override
    public IInformationControl createInformationControl(Shell parent) {
      return new DefaultInformationControl(parent);
    }
  });

  return contentAssistant;
}
 
源代码5 项目: eclipse-cs   文件: ConfigPropertyWidgetRegex.java
/**
 * Creates the content assistant.
 * 
 * @return the content assistant
 */
private SubjectControlContentAssistant createContentAssistant() {

  final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();

  contentAssistant
          .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());

  IContentAssistProcessor processor = new RegExContentAssistProcessor(true);
  contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
  contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
  contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
    /*
     * @see IInformationControlCreator#createInformationControl(Shell)
     */
    @Override
    public IInformationControl createInformationControl(Shell parent) {
      return new DefaultInformationControl(parent);
    }
  });

  return contentAssistant;
}
 
源代码6 项目: http4e   文件: ParameterizeTextView.java
private StyledText buildEditorText( Composite parent){
   final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR);
   sourceViewer.configure(sourceConf);
   sourceViewer.setDocument(DocumentUtils.createDocument1());

   sourceViewer.getControl().addKeyListener(new KeyAdapter() {

      public void keyPressed( KeyEvent e){
         // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) {
         if (Utils.isAutoAssistInvoked(e)) {
            IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer);
            ca.showPossibleCompletions();
         }
      }
   });

   return sourceViewer.getTextWidget();
}
 
public ContentAssistProcessorTestBuilder assertMatchString(String matchString)
		throws Exception {
	String currentModelToParse = getModel();
	final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse));
	final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse);
	XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
	Shell shell = new Shell();
	try {
		ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
		IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
		String contentType = xtextDocument.getContentType(currentModelToParse.length());
		if (contentAssistant.getContentAssistProcessor(contentType) != null) {
			ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class);
			ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource);
			for(ContentAssistContext context: contexts) {
				Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'",
						"".equals(context.getPrefix()) || matchString.equals(context.getPrefix()));
			}
		} else {
			Assert.fail("No content assistant for content type " + contentType);
		}
		return this;
	} finally {
		shell.dispose();
	}
}
 
public ContentAssistProcessorTestBuilder assertMatchString(String matchString)
		throws Exception {
	String currentModelToParse = getModel();
	final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse, getEncoding()));
	final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse);
	XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
	Shell shell = new Shell();
	try {
		ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
		IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
		String contentType = xtextDocument.getContentType(currentModelToParse.length());
		if (contentAssistant.getContentAssistProcessor(contentType) != null) {
			ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class);
			ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource);
			for(ContentAssistContext context: contexts) {
				Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'",
						"".equals(context.getPrefix()) || matchString.equals(context.getPrefix()));
			}
		} else {
			Assert.fail("No content assistant for content type " + contentType);
		}
		return this;
	} finally {
		shell.dispose();
	}
}
 
源代码9 项目: 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;
}
 
源代码10 项目: xds-ide   文件: ModulaEditor.java
private void refreshContentProposals() {
  	final IContentAssistant contentAssistant = configuration.getContentAssistant(getSourceViewer());
  	if (contentAssistant instanceof ModulaContentAssistant) {
	Display.getDefault().asyncExec(new Runnable() {
		@Override
		public void run() {
			if (isDisposed()) {
				return;
			}
			ModulaContentAssistant modulaContentAssistant = (ModulaContentAssistant) contentAssistant;
			if (modulaContentAssistant.isProposalPopupActive()) {
				modulaContentAssistant.showPossibleCompletions(true);
			}
		}
	});
}
  }
 
源代码11 项目: xds-ide   文件: ModulaSourceViewerConfiguration.java
/**
     * {@inheritDoc}
     */
    @Override
    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    	if (contentAssistant == null) {
    		contentAssistant = new ModulaContentAssistant(sourceViewer);
    		contentAssistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    		
//    	configureContentAssistanceProcessorsOld(contentAssistant);
    		configureContentAssistanceProcessors(contentAssistant);
    		contentAssistant.setRepeatedInvocationMode(true);
    		contentAssistant.setAutoActivationDelay(100);
    		contentAssistant.enableAutoActivation(true);
    		contentAssistant.enablePrefixCompletion(false);
    		contentAssistant.enableColoredLabels(true);
    		contentAssistant.enableAutoInsert(true);
    		
    		contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
    	}
        
        return contentAssistant;
    }
 
/**
 * Internally compute completion proposals.
 *
 * @param cursorPosition
 *          the position of the cursor in the {@link IXtextDocument}
 * @param xtextDocument
 *          the {@link IXtextDocument}
 * @return a pair of {@link ICompletionProposal}[] and {@link BadLocationException}. If the tail argument is not {@code null}, an exception occurred in the UI
 *         thread.
 */
private Pair<ICompletionProposal[], BadLocationException> internalComputeCompletionProposals(final int cursorPosition, final IXtextDocument xtextDocument) {
  XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
  Shell shell = new Shell();
  try {
    ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
    IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
    String contentType = xtextDocument.getContentType(cursorPosition);
    IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
    if (processor != null) {
      return Tuples.create(processor.computeCompletionProposals(sourceViewer, cursorPosition), null);
    }
    return Tuples.create(new ICompletionProposal[0], null);
  } catch (BadLocationException e) {
    return Tuples.create(new ICompletionProposal[0], e);
  } finally {
    shell.dispose();
  }
}
 
源代码13 项目: 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 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);
}
 
源代码16 项目: 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;
}
 
源代码17 项目: Pydev   文件: AbstractWorkbenchTestCase.java
/**
 * Requests proposals in the last location of the given editor.
 */
protected ICompletionProposalHandle[] requestProposals(String mod1Contents, PyEdit editor) {
    editor.setSelection(mod1Contents.length(), 0);
    IContentAssistant contentAssistant = editor.getEditConfiguration().getContentAssistant(
            editor.getPySourceViewer());
    SimpleAssistProcessor processor = (SimpleAssistProcessor) contentAssistant
            .getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
    processor.doCycle(); //we want to show the default completions in this case (not the simple ones)
    ICompletionProposal[] props = processor.computeCompletionProposals(editor.getPySourceViewer(),
            mod1Contents.length());
    ArrayList<ICompletionProposalHandle> lst = new ArrayList<>(props.length);
    for (ICompletionProposal iCompletionProposal : props) {
        lst.add((ICompletionProposalHandle) iCompletionProposal);
    }

    return lst.toArray(new ICompletionProposalHandle[0]);
}
 
源代码18 项目: Pydev   文件: SetupContentAssist.java
public static IContentAssistant configContentAssistant(IPySyntaxHighlightingAndCodeCompletionEditor edit,
        PyContentAssistant pyContentAssistant) {
    // next create a content assistant processor to populate the completions window
    IContentAssistProcessor processor = new SimpleAssistProcessor(edit, new PythonCompletionProcessor(edit,
            pyContentAssistant), pyContentAssistant);

    PythonStringCompletionProcessor stringProcessor = new PythonStringCompletionProcessor(edit, pyContentAssistant);

    // No code completion in comments and strings
    for (String s : PythonPartitions.STRING_PROCESSOR_PARTITIONS) {
        pyContentAssistant.setContentAssistProcessor(stringProcessor, s);
    }

    pyContentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    pyContentAssistant.enableAutoActivation(true); //always true, but the chars depend on whether it is activated or not in the preferences

    //note: delay and auto activate are set on PyContentAssistant constructor.

    pyContentAssistant.setDocumentPartitioning(IPythonPartitions.PYTHON_PARTITION_TYPE);
    pyContentAssistant.setAutoActivationDelay(PyCodeCompletionPreferences.getAutocompleteDelay());

    return pyContentAssistant;
}
 
源代码19 项目: goclipse   文件: LangCompletionProposal.java
@Override
public void selected(ITextViewer viewer, boolean smartToggle) {
	if(viewer instanceof ISourceViewerExt) {
		ISourceViewerExt sourceViewer = (ISourceViewerExt) viewer;
		IContentAssistant ca = sourceViewer.getContentAssistant();
		if(ca instanceof ContentAssistantExt) {
			caext = (ContentAssistantExt) ca;
			if(!isAutoInsertable()) {
				caext.setAdditionalStatusMessage("Press 'Ctrl+Enter' for name-only insertion;");
			} else {
				caext.setAdditionalStatusMessage(null);
				caext = null;
			}
		}
	}
}
 
@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;
}
 
源代码21 项目: 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;
}
 
源代码23 项目: 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;
}
 
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer, cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer, cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
源代码27 项目: 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;
}
 
源代码29 项目: gef   文件: DotProposalProviderDelegator.java
private ICompletionProposal[] computeCompletionProposals(
		final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration
			.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant
			.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer,
				cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
public ICompletionProposal[] computeCompletionProposals(final XtextEditor editorForCompletion, final XtextEditor dirtyEditor, final int cursorPosition) throws BadLocationException {
  this.syncUtil.waitForReconciler(dirtyEditor);
  final ISourceViewer sourceViewer = editorForCompletion.getInternalSourceViewer();
  final IContentAssistant contentAssistant = editorForCompletion.getXtextSourceViewerConfiguration().getContentAssistant(sourceViewer);
  final String contentType = editorForCompletion.getDocument().getContentType(cursorPosition);
  final IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
  if ((processor != null)) {
    return processor.computeCompletionProposals(sourceViewer, cursorPosition);
  }
  return null;
}
 
 类所在包
 同包方法