Java 类org.eclipse.jface.text.contentassist.IContentAssistProcessor 实例源码

项目:egradle    文件:GradleTextHover.java   
/**
 * Get language at given offset
 * 
 * @param offset
 * @param textViewer
 * @return language element or <code>null</code>
 */
protected HoverDataRegion getLanguageElementAt(int offset, ITextViewer textViewer) {
    IContentAssistant assist = gradleSourceViewerConfiguration.getContentAssistant(sourceViewer);
    if (assist == null) {
        return null;
    }
    IContentAssistProcessor processor = assist.getContentAssistProcessor(contentType);
    if (!(processor instanceof GradleContentAssistProcessor)) {
        return null;
    }
    GradleContentAssistProcessor gprocessor = (GradleContentAssistProcessor) processor;
    String allText = textViewer.getDocument().get();
    RelevantCodeCutter codeCutter = this.codeCutter;
    Model model = gprocessor.getModel();
    GradleFileType fileType = gradleSourceViewerConfiguration.getFileType();
    GradleLanguageElementEstimater estimator = gprocessor.getEstimator();

    HoverData data = hoverSupport.caclulateHoverData(allText, offset, codeCutter, model, fileType, estimator);
    if (data == null) {
        return null;
    }
    return new HoverDataRegion(data);
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelSourceViewerConfiguration.java   
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant assistant = new ContentAssistant();
    IContentAssistProcessor processor = new EiffelContentAssistantProcessor();
    assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    assistant.setContentAssistProcessor(new EiffelContentAssistantProcessor(),
            IDocument.DEFAULT_CONTENT_TYPE);

    assistant.setAutoActivationDelay(100);
    assistant.enableAutoActivation(true);
    assistant.enableAutoInsert(true);

    assistant.setProposalSelectorBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    return assistant;
}
项目:dsl-devkit    文件:AcfContentAssistProcessorTestBuilder.java   
/**
 * 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();
  }
}
项目:fluentmark    文件:MultiContentAssistProcessor.java   
public IContextInformationValidator getContextInformationValidator() {
    List<IContextInformationValidator> validators = null;
    for (IContentAssistProcessor delegate : delegates) {
        IContextInformationValidator validator = delegate.getContextInformationValidator();
        if (validator != null) {
            if (validators == null) {
                validators = new ArrayList<IContextInformationValidator>();
            }
        }
    }
    if (validators != null) {
        // FIXME: return a compound validator
        return validators.get(0);
    }
    return null;
}
项目:BYONDclipse    文件:DMConfiguration.java   
@Override public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer)
{
    // Create content assistant
    final ContentAssistant assistant                                                        = new ContentAssistant();

    assistant.enableAutoActivation(true);
    assistant.setAutoActivationDelay(500);
    assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    assistant.setInformationControlCreator(this.getInformationControlCreator(sourceViewer));

    // Create content assistant processor
    final IContentAssistProcessor processor                                                 = new DMContentAssistProcessor();

    // Set this processor for each supported content type
    assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    assistant.setContentAssistProcessor(processor, DMPartitionScanner.DM_STRING);

    // Return the content assistant
    return assistant;
}
项目:APICloud-Studio    文件:CompletionProposalPopup.java   
/**
 * Returns the completion proposal available at the given offset of the viewer's document. Delegates the work to the
 * code assistant.
 * 
 * @param offset
 *            the offset
 * @param autoActivated
 * @return the completion proposals available at this offset
 */
private ICompletionProposal[] computeProposals(int offset, boolean autoActivated)
{
    if (fContentAssistSubjectControl != null)
    {
        return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, offset, fActivationKey);
    }
    IContentAssistProcessor processor = fContentAssistant.getProcessor(fViewer, offset);
    if (processor == null) {
         return null;
    }
    if (processor instanceof ICommonContentAssistProcessor) {
         ICommonContentAssistProcessor commonProcessor = (ICommonContentAssistProcessor)processor;
         return commonProcessor.computeCompletionProposals(fViewer, offset, fActivationKey, autoActivated);
    } else {
         return processor.computeCompletionProposals(fViewer, offset);
    }
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Registers a given code assist processor for a particular content type. If there is already a processor registered
 * for this type, the new processor is registered instead of the old one.
 * 
 * @param processor
 *            the code assist processor to register, or <code>null</code> to remove an existing one
 * @param contentType
 *            the content type under which to register
 */
public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType)
{
    if (fProcessors == null)
    {
        fProcessors = new HashMap<String, IContentAssistProcessor>();
    }

    if (processor == null)
    {
        fProcessors.remove(contentType);
    }
    else
    {
        fProcessors.put(contentType, processor);
    }
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns the code assist processor for the content type of the specified document position.
 * 
 * @param viewer
 *            the text viewer
 * @param offset
 *            a offset within the document
 * @return a content-assist processor or <code>null</code> if none exists
 * @since 3.0
 */
public IContentAssistProcessor getProcessor(ITextViewer viewer, int offset)
{
    try
    {

        IDocument document = viewer.getDocument();
        String type = TextUtilities.getContentType(document, getDocumentPartitioning(), offset, true);

        return getContentAssistProcessor(type);

    }
    catch (BadLocationException x)
    {
    }

    return null;
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns the code assist processor for the content type of the specified document position.
 * 
 * @param contentAssistSubjectControl
 *            the code assist subject control
 * @param offset
 *            a offset within the document
 * @return a content-assist processor or <code>null</code> if none exists
 * @since 3.0
 */
private IContentAssistProcessor getProcessor(IContentAssistSubjectControl contentAssistSubjectControl, int offset)
{
    try
    {

        IDocument document = contentAssistSubjectControl.getDocument();
        String type;
        if (document != null)
        {
            type = TextUtilities.getContentType(document, getDocumentPartitioning(), offset, true);
        }
        else
        {
            type = IDocument.DEFAULT_CONTENT_TYPE;
        }

        return getContentAssistProcessor(type);

    }
    catch (BadLocationException x)
    {
    }

    return null;
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns an array of context information objects computed based on the specified document position. The position
 * is used to determine the appropriate code assist processor to invoke.
 * 
 * @param viewer
 *            the viewer for which to compute the context information
 * @param offset
 *            a document offset
 * @return an array of context information objects
 * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
 */
IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
    fLastErrorMessage = null;

    IContextInformation[] result = null;

    IContentAssistProcessor p = getProcessor(viewer, offset);
    if (p != null)
    {
        result = p.computeContextInformation(viewer, offset);
        fLastErrorMessage = p.getErrorMessage();
    }

    return result;
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns an array of context information objects computed based on the specified document position. The position
 * is used to determine the appropriate code assist processor to invoke.
 * 
 * @param contentAssistSubjectControl
 *            the code assist subject control
 * @param offset
 *            a document offset
 * @return an array of context information objects
 * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
 * @since 3.0
 */
IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int offset)
{
    fLastErrorMessage = null;

    IContextInformation[] result = null;

    IContentAssistProcessor p = getProcessor(contentAssistSubjectControl, offset);
    if (p instanceof ISubjectControlContentAssistProcessor)
    {
        result = ((ISubjectControlContentAssistProcessor) p).computeContextInformation(contentAssistSubjectControl,
                offset);
        fLastErrorMessage = p.getErrorMessage();
    }

    return result;
}
项目:APICloud-Studio    文件:HTMLSourceConfiguration.java   
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
    if (contentType.startsWith(JSSourceConfiguration.PREFIX))
    {
        return JSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    if (contentType.startsWith(CSSSourceConfiguration.PREFIX))
    {
        return CSSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    if (contentType.startsWith(SVGSourceConfiguration.PREFIX))
    {
        return SVGSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    return new HTMLContentAssistProcessor(editor);
}
项目:Eclipse-Postfix-Code-Completion    文件:PromoteTempWizard.java   
private void addFieldNameField(Composite result) {
    Label nameLabel= new Label(result, SWT.NONE);
    nameLabel.setText(RefactoringMessages.PromoteTempInputPage_Field_name);
    nameLabel.setLayoutData(new GridData());

    String[] guessedFieldNames= getPromoteTempRefactoring().guessFieldNames();
    String firstGuessedFieldName= guessedFieldNames[0];

    fNameField = new Text(result, SWT.BORDER | SWT.SINGLE);
    fNameField.setText(firstGuessedFieldName);
    getPromoteTempRefactoring().setFieldName(firstGuessedFieldName);
    fNameField.selectAll();
    fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fNameField.addModifyListener(new ModifyListener(){
        public void modifyText(ModifyEvent e) {
            PromoteTempInputPage.this.getPromoteTempRefactoring().setFieldName(fNameField.getText());
            PromoteTempInputPage.this.updateStatus();
        }
    });
    IContentAssistProcessor processor= new FieldNameProcessor(guessedFieldNames, getPromoteTempRefactoring());
    ControlContentAssistHelper.createTextContentAssistant(fNameField, processor);
    TextFieldNavigationHandler.install(fNameField);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PromoteTempWizard.java   
private void addFieldNameField(Composite result) {
    Label nameLabel= new Label(result, SWT.NONE);
    nameLabel.setText(RefactoringMessages.PromoteTempInputPage_Field_name);
    nameLabel.setLayoutData(new GridData());

    String[] guessedFieldNames= getPromoteTempRefactoring().guessFieldNames();

    fNameField = new Text(result, SWT.BORDER | SWT.SINGLE);
    fNameField.setText(guessedFieldNames[0]);
    fNameField.selectAll();
    fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fNameField.addModifyListener(new ModifyListener(){
        public void modifyText(ModifyEvent e) {
            PromoteTempInputPage.this.getPromoteTempRefactoring().setFieldName(fNameField.getText());
            PromoteTempInputPage.this.updateStatus();
        }
    });
    IContentAssistProcessor processor= new FieldNameProcessor(guessedFieldNames, getPromoteTempRefactoring());
    ControlContentAssistHelper.createTextContentAssistant(fNameField, processor);
    TextFieldNavigationHandler.install(fNameField);
}
项目: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 : 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(PyCodeCompletionPreferencesPage.getAutocompleteDelay());

    return pyContentAssistant;
}
项目:Pydev    文件:PydevConsole.java   
@Override
public SourceViewerConfiguration createSourceViewerConfiguration() {
    PyContentAssistant contentAssist = new PyContentAssistant();
    IContentAssistProcessor processor = createConsoleCompletionProcessor(contentAssist);
    contentAssist.setContentAssistProcessor(processor, PydevScriptConsoleSourceViewerConfiguration.PARTITION_TYPE);

    contentAssist.enableAutoActivation(true);
    contentAssist.enableAutoInsert(false);
    contentAssist.setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay());

    PyCorrectionAssistant quickAssist = new PyCorrectionAssistant();
    // next create a content assistant processor to populate the completions window
    IQuickAssistProcessor quickAssistProcessor = createConsoleQuickAssistProcessor(quickAssist);

    // Correction assist works on all
    quickAssist.setQuickAssistProcessor(quickAssistProcessor);

    SourceViewerConfiguration cfg = new PydevScriptConsoleSourceViewerConfiguration(createHover(), contentAssist,
            quickAssist);
    return cfg;
}
项目:eclipse-asciidoctools    文件:AsciidocSourceViewerConfiguration.java   
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant contentAssistant = new ContentAssistant();
    IContentAssistProcessor processor = new AsciidocContentAssistProcessor();
    contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    return contentAssistant;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexSourceViewerConfig.java   
@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;
}
项目:dsl-devkit    文件:AbstractContentAssistUiTest.java   
/**
 * Helper function to find the correct CompletionProposalComputer for the given offset.
 *
 * @param offset
 *          offset in test file
 * @return language and offset specific content assist proposal computer
 */
private CompletionProposalComputer createCompletionProposalComputer(final int offset) {
  XtextSourceViewerConfiguration configuration = getEditor().getXtextSourceViewerConfiguration();
  IContentAssistant contentAssistant = configuration.getContentAssistant(getViewer());
  IContentAssistProcessor contentAssistProcessor;
  try {
    contentAssistProcessor = contentAssistant.getContentAssistProcessor(getDocument().getContentType(offset));
  } catch (BadLocationException e) {
    contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
  }
  if (contentAssistProcessor == null) {
    contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
  }
  return new CompletionProposalComputer((State) contentAssistProcessor, (ITextViewer) getViewer(), offset);
}
项目:ncl30-eclipse    文件:NCLConfiguration.java   
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant assistant = new ContentAssistant();
    IContentAssistProcessor nclCompletionProcessor = new NCLCompletionProposal();
    assistant
            .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

    // set nclCompletionProposal to XML_START_TAG
    assistant.setContentAssistProcessor(nclCompletionProcessor,
            XMLPartitionScanner.XML_START_TAG);
    assistant.setContentAssistProcessor(nclCompletionProcessor,
            XMLPartitionScanner.XML_END_TAG);
    // set nclCompletionProposal to DEFAULT_CONTENT
    assistant.setContentAssistProcessor(nclCompletionProcessor,
            IDocument.DEFAULT_CONTENT_TYPE);

    assistant
            .setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    assistant
            .setInformationControlCreator(getInformationControlCreator(sourceViewer));
    // Enable AutoActivation
    assistant.enableAutoActivation(true);
    assistant.setAutoActivationDelay(500);

    Color bgColor = colorManager.getColor(new RGB(255, 255, 255));
    assistant.setProposalSelectorBackground(bgColor);
    return assistant;
}
项目:fluentmark    文件:MultiContentAssistProcessor.java   
public void addDelegate(IContentAssistProcessor processor) {
    if (delegates == null) {
        delegates = new IContentAssistProcessor[] { processor };
    } else {
        IContentAssistProcessor[] processors = new IContentAssistProcessor[delegates.length + 1];
        System.arraycopy(delegates, 0, processors, 0, delegates.length);
        processors[delegates.length] = processor;
        delegates = processors;
    }
}
项目:fluentmark    文件:MultiContentAssistProcessor.java   
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    ICompletionProposal[] allProposals = null;
    for (IContentAssistProcessor delegate : delegates) {
        allProposals = merge(allProposals, delegate.computeCompletionProposals(viewer, offset));
    }
    return allProposals;
}
项目:fluentmark    文件:MultiContentAssistProcessor.java   
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
    IContextInformation[] allInformation = null;
    for (IContentAssistProcessor delegate : delegates) {
        IContextInformation[] information = delegate.computeContextInformation(viewer, offset);
        allInformation = merge(allInformation, information);
    }
    return allInformation;
}
项目:fluentmark    文件:MultiContentAssistProcessor.java   
public String getErrorMessage() {
    for (IContentAssistProcessor delegate : delegates) {
        String message = delegate.getErrorMessage();
        if (message != null) {
            return message;
        }
    }
    return null;
}
项目:xtext-gef    文件:StateNameEditPart.java   
/**
 * @generated
 */
public IContentAssistProcessor getCompletionProcessor() {
    if (getParserElement() == null || getParser() == null) {
        return null;
    }
    return getParser().getCompletionProcessor(
            new EObjectAdapter(getParserElement()));
}
项目:umple    文件:UMPConfiguration.java   
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant ca = new ContentAssistant();
       IContentAssistProcessor cap = new CompletionProcessor();
       ca.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE);
       ca.enableAutoActivation(true);
       ca.setAutoActivationDelay(500);
       ca.setProposalPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW);
       ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));
       return ca;
}
项目:gwt-eclipse-plugin    文件:CssResourceSourceViewerConfiguration.java   
@Override
protected IContentAssistProcessor[] getContentAssistProcessors(
    ISourceViewer sourceViewer, String partitionType) {
  IContentAssistProcessor[] processors = super.getContentAssistProcessors(
      sourceViewer, partitionType);

  if ((partitionType == ICSSPartitions.STYLE)
      || (partitionType == IStructuredPartitions.UNKNOWN_PARTITION)) {
    processors = new IContentAssistProcessor[] {new IndentationFixingCssContentAssistProcessor()};
  }

  return processors;
}
项目:gwt-eclipse-plugin    文件:UiBinderXmlSourceViewerConfiguration.java   
@Override
protected IContentAssistProcessor[] getContentAssistProcessors(
    ISourceViewer sourceViewer, String partitionType) {

  if (partitionType == ICSSPartitions.STYLE) {
    return new IContentAssistProcessor[] {new InlinedCssContentAssistProcessor()};
  }

  return new IContentAssistProcessor[] {new UiBinderXmlCompletionProcessor()};
}
项目:gwt-eclipse-plugin    文件:GWTSourceViewerConfiguration.java   
@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;
}
项目:gwt-eclipse-plugin    文件:GssResourceSourceViewerConfiguration.java   
@Override
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) {
  IContentAssistProcessor[] processors = super.getContentAssistProcessors(sourceViewer, partitionType);

  if ((partitionType == ICSSPartitions.STYLE) || (partitionType == IStructuredPartitions.UNKNOWN_PARTITION)) {
    processors = new IContentAssistProcessor[] { new IndentationFixingGssContentAssistProcessor() };
  }

  return processors;
}
项目:APICloud-Studio    文件:SVGSourceConfiguration.java   
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
    if (contentType.startsWith(JSSourceConfiguration.PREFIX))
    {
        return JSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    if (contentType.startsWith(CSSSourceConfiguration.PREFIX))
    {
        return CSSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    return new SVGContentAssistProcessor(editor);
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * @see org.eclipse.jface.text.contentassist.IContentAssistant#getContentAssistProcessor(java.lang.String)
 */
public IContentAssistProcessor getContentAssistProcessor(String contentType)
{
    if (fProcessors == null)
    {
        return null;
    }

    return fProcessors.get(contentType);
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Computes the sorted set of all auto activation trigger characters.
 * 
 * @return the sorted set of all auto activation trigger characters
 * @since 3.1
 */
private String computeAllAutoActivationTriggers()
{
    if (fProcessors == null)
    {
        return ""; //$NON-NLS-1$
    }

    StringBuffer buf = new StringBuffer(5);
    Iterator<Entry<String, IContentAssistProcessor>> iter = fProcessors.entrySet().iterator();

    while (iter.hasNext())
    {
        Entry<String, IContentAssistProcessor> entry = iter.next();
        IContentAssistProcessor processor = entry.getValue();
        char[] triggers = processor.getCompletionProposalAutoActivationCharacters();

        if (triggers != null)
        {
            buf.append(triggers);
        }

        triggers = processor.getContextInformationAutoActivationCharacters();

        if (triggers != null)
        {
            buf.append(triggers);
        }
    }

    return buf.toString();
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * @param offset
 * @param document
 */
private boolean isValidAutoAssistLocation(KeyEvent e, StyledText styledText)
{
    // Don't pop up CA if we pressed a Ctrl or Command character. On Linux, Unicode characters can be inserted with
    // Ctrl + Shift + u + key sequence, but at this point, all we get is the character, no modifiers.
    if (e.stateMask == SWT.MOD1)
    {
        return false;
    }

    int keyCode = e.keyCode;
    if (keyCode == SWT.ESC || keyCode == SWT.BS || keyCode == SWT.DEL || keyCode == SWT.ARROW
            || (keyCode & SWT.KEYCODE_BIT) != 0)
    {
        return false;
    }

    int offset = styledText.getCaretOffset();
    IContentAssistProcessor processor = getProcessor(fContentAssistSubjectControlAdapter, offset);
    if (processor instanceof ICommonContentAssistProcessor)
    {
        ICommonContentAssistProcessor cp = (ICommonContentAssistProcessor) processor;
        // are we typing a valid identifier, and the previous "location" (character or lexeme) should pop up CA
        return cp.isValidIdentifier(e.character, keyCode)
                && isAutoActivationLocation(cp, styledText, e.character, keyCode);
    }
    else
    {
        return false;
    }
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns an array of completion proposals computed based on the specified document position. The position is used
 * to determine the appropriate code assist processor to invoke.
 * 
 * @param contentAssistSubjectControl
 *            the code assist subject control
 * @param offset
 *            a document offset
 * @return an array of completion proposals
 * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
 * @since 3.0
 */
ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl,
        int offset, char activationChar)
{
    fLastErrorMessage = null;
    fUserAgentColumnCount = 0;

    ICompletionProposal[] result = null;
    IContentAssistProcessor processor = getProcessor(contentAssistSubjectControl, offset);

    if (processor != null)
    {
        if (processor instanceof ISubjectControlContentAssistProcessor)
        {
            result = ((ISubjectControlContentAssistProcessor) processor).computeCompletionProposals(
                    contentAssistSubjectControl, offset);
            fLastErrorMessage = processor.getErrorMessage();
        }
        if (processor instanceof ICommonContentAssistProcessor)
        {
            String[] ids = ((ICommonContentAssistProcessor) processor).getActiveUserAgentIds();

            fUserAgentColumnCount = (ids != null) ? ids.length : 0;
        }
    }

    return result;
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * Returns an array of completion proposals computed based on the specified document position. The position is used
 * to determine the appropriate code assist processor to invoke.
 * 
 * @param viewer
 *            the viewer for which to compute the proposals
 * @param offset
 *            a document offset
 * @param autoActivated
 *            determines whether we were autoActivated or not
 * @return an array of completion proposals
 * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
 */
ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset, char activationChar,
        boolean autoActivated)
{
    fLastErrorMessage = null;
    fUserAgentColumnCount = 0;

    ICompletionProposal[] result = null;
    IContentAssistProcessor processor = this.getProcessor(viewer, offset);

    if (processor != null)
    {
        if (processor instanceof ICommonContentAssistProcessor)
        {
            ICommonContentAssistProcessor commonProcessor = (ICommonContentAssistProcessor) processor;

            result = commonProcessor.computeCompletionProposals(viewer, offset, activationChar, autoActivated);

            String[] ids = ((ICommonContentAssistProcessor) processor).getActiveUserAgentIds();

            fUserAgentColumnCount = (ids != null) ? ids.length : 0;
        }
        else
        {
            result = processor.computeCompletionProposals(viewer, offset);
        }

        fLastErrorMessage = processor.getErrorMessage();
    }

    return result;
}
项目:APICloud-Studio    文件:XMLSourceConfiguration.java   
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
    if (contentType.startsWith(DTDSourceConfiguration.PREFIX))
    {
        return DTDSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
    }
    return new XMLContentAssistProcessor(editor);
}
项目:APICloud-Studio    文件:JSSourceConfiguration.java   
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
    if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) || JSSourceConfiguration.DEFAULT.equals(contentType))
    {
        return new JSContentAssistProcessor(editor);
    }
    return null;
}
项目:APICloud-Studio    文件:CSSSourceConfiguration.java   
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
    if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) || CSSSourceConfiguration.DEFAULT.equals(contentType))
    {
        return new CSSContentAssistProcessor(editor);
    }
    return null;
}
项目:APICloud-Studio    文件:SnippetsContentAssistant.java   
@Override
public IContentAssistProcessor getContentAssistProcessor(String contentType)
{
    if (contentAssistProcessor == null)
    {
        contentAssistProcessor = new SnippetsCompletionProcessor();
    }
    return contentAssistProcessor;
}