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

项目:tlaplus    文件:TLACompletionProcessor.java   
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
    // Retrieve selected range
    Point selectedRange = viewer.getSelectedRange();
    if (selectedRange.y > 0)
    {
        // Text is selected. Create a context information array.
        ContextInformation[] contextInfos = new ContextInformation[ITLAReserveredWords.ALL_WORDS_ARRAY.length];

        // Create one context information item for each style
        for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++)
            contextInfos[i] = new ContextInformation(null, ITLAReserveredWords.ALL_WORDS_ARRAY[i] + " Style");
        return contextInfos;
    }
    return new ContextInformation[0];
}
项目:brainfuck    文件:BfKeywordCompletionProposal.java   
@Override
public ICompletionProposal[] computeCompletionProposals(
        ITextViewer viewer, int offset) {
    List<ICompletionProposal> proposals = new ArrayList<>();
    for (String[] texts : PROPOSAL_TEXTS) {
        String replacement = texts[0];
        String text = texts[1];
        CompletionProposal proposal = 
                new CompletionProposal(replacement, 
                                       offset, 
                                       replacement.length(), 
                                       replacement.length(),
                                       null,
                                       text,
                                       new ContextInformation(replacement, text),
                                       null);
        proposals.add(proposal);
    }
    return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
项目:http4e    文件:HContentAssistProcessor.java   
public IContextInformation[] computeContextInformation( ITextViewer viewer, int documentOffset){
   // viewer.getSelectedRange();
   // if (selectedRange.y > 0) Text is selected. Create a context information array.
   // ContextInformation[] contextInfos = new
   // ContextInformation[STYLELABELS.length];
   // // Create one context information item for each style
   // for (int i = 0; i < STYLELABELS.length; i++)
   // contextInfos[i] = new ContextInformation("<" + STYLETAGS[i] + ">",
   // STYLELABELS[i] + " Style");
   // return contextInfos;
   // }
   return new ContextInformation[0];
}
项目:texlipse    文件:TexStyleCompletionManager.java   
/**
 * Returns the style context.
 * 
 * @return Array of style contexts
 */
public IContextInformation[] getStyleContext() {
    ContextInformation[] contextInfos = new ContextInformation[STYLELABELS.length];

    // Create one context information item for each style
    for (int i = 0; i < STYLELABELS.length; i++) {
        contextInfos[i] = new ContextInformation(null, STYLELABELS[i]+" Style");
    }
    return contextInfos;
}
项目:texlipse    文件:TexCompletionProcessor.java   
public IContextInformation[] computeContextInformation(ITextViewer viewer,
        int offset) {

    // FIXME -- for testing
    // Retrieve selected range
    Point selectedRange = viewer.getSelectedRange();
    if (selectedRange.y > 0) {

        if (styleManager == null) {
            styleManager = TexStyleCompletionManager.getInstance();
        }
        return styleManager.getStyleContext();
    }
    return new ContextInformation[0];
}
项目:typescript.java    文件:TypeScriptCompletionProposal.java   
private IContextInformation createContextInformation() {
    try {
        String information = null;
        List<CompletionEntryDetails> entryDetails = super.getEntryDetails();
        if (entryDetails == null || entryDetails.size() < 1) {
            return null;
        }
        if (isFunction()) {
            information = TypeScriptHelper.extractFunctionParameters(entryDetails.get(0).getDisplayParts());
        }
        return information != null ? new ContextInformation("", information) : null;
    } catch (TypeScriptException e) {
    }
    return null;
}
项目:BYONDclipse    文件:DMContentAssistProcessor.java   
private CompletionProposal newCompletionProposal(final String proposal, final String displayName, final int documentOffset, final int qlen, final String imageID, final int offset, final String description)
{
    final Image image                                                                                                   = JavaUI.getSharedImages().getImage(imageID);
    final IContextInformation contextInformation                                                                        = new ContextInformation(proposal, description);

    return new CompletionProposal(proposal, documentOffset - qlen, qlen, proposal.length() - (-offset), image, displayName, contextInformation, description);
}
项目:pgcodekeeper    文件:SQLEditorCompletionProcessor.java   
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
        int offset) {
    String part;
    try {
        part = viewer.getDocument().get(0, offset);
    } catch (BadLocationException ex) {
        Log.log(Log.LOG_ERROR, "Document doesn't contain such offset", ex); //$NON-NLS-1$
        return null;
    }
    int nonid = offset - 1;
    while (nonid > 0 && PgDiffUtils.isValidIdChar(part.charAt(nonid))) {
        --nonid;
    }
    String text = part.substring(nonid + 1, offset);

    List<ICompletionProposal> result = new LinkedList<>();
    List<ICompletionProposal> partResult = new LinkedList<>();

    PgDbParser parser = editor.getParser();
    Stream<PgObjLocation> loc = parser.getAllObjDefinitions();
    loc
    .filter(o -> text.isEmpty() || o.getObjName().startsWith(text))
    .filter(o -> o.getObjType() != DbObjType.SEQUENCE && o.getObjType() != DbObjType.INDEX)
    .sorted((o1, o2) -> o1.getFilePath().compareTo(o2.getFilePath()))
    .forEach(obj -> {
        Image img = Activator.getDbObjImage(obj.getObjType());
        String displayText = obj.getObjName();
        if (!obj.getComment().isEmpty()) {
            displayText += " - " + obj.getComment(); //$NON-NLS-1$
        }
        IContextInformation info = new ContextInformation(
                obj.getObjName(), obj.getComment());
        if (!text.isEmpty()) {
            result.add(new CompletionProposal(obj.getObjName(), offset - text.length(),
                    text.length(), obj.getObjLength(), img, displayText, info,
                    obj.getObjName()));
        } else {
            result.add(new CompletionProposal(obj.getObjName(), offset, 0,
                    obj.getObjLength(), img, displayText, info, obj.getObjName()));
        }
    });

    // SQL Templates + Keywords
    if (text.isEmpty()) {
        keywords.forEach(k -> result.add(new CompletionProposal(k, offset, 0, k.length())));
        result.addAll(new SQLEditorTemplateAssistProcessor().getAllTemplates(viewer, offset));
    } else {
        String textUpper = text.toUpperCase();
        for (String keyword : keywords) {
            int location = keyword.indexOf(textUpper);
            if (location != -1) {
                CompletionProposal proposal = new CompletionProposal(keyword + ' ',
                        offset - text.length(), text.length(), keyword.length() + 1);
                if (location  == 0) {
                    result.add(proposal);
                } else {
                    partResult.add(proposal);
                }
            }
        }

        result.addAll(partResult);

        ICompletionProposal[] templates = new SQLEditorTemplateAssistProcessor()
                .computeCompletionProposals(viewer, offset);
        if (templates != null) {
            result.addAll(Arrays.asList(templates));
        }
    }

    return result.toArray(new ICompletionProposal[result.size()]);
}
项目:texlipse    文件:TexStyleCompletionManager.java   
/**
 * Returns the style completion proposals
 * 
 * @param selectedText The selected text
 * @param selectedRange The selected range
 * @return An array of completion proposals
 */
public ICompletionProposal[] getStyleCompletions(String selectedText, Point selectedRange) {

    /*
    ICompletionProposal[] result = new ICompletionProposal[keyValue.size()];
    int i=0;
    for (Iterator iter = keyValue.keySet().iterator(); iter.hasNext();) {
        String key = (String) iter.next();
        String value = (String) keyValue.get(key);


        String replacement = "{" + key + " " + selectedText + "}";
        int cursor = key.length() + 2;
        IContextInformation contextInfo = new ContextInformation(null, value+" Style");
        result[i] = new CompletionProposal(replacement, 
                selectedRange.x, selectedRange.y,
                cursor, null, value,
                contextInfo, replacement);
        i++;
    }
    */

    ICompletionProposal[] result = new ICompletionProposal[STYLELABELS.length];
    // Loop through all styles
    for (int i = 0; i < STYLETAGS.length; i++) {
        String tag = STYLETAGS[i];

        // Compute replacement text
        String replacement = tag + selectedText + "}";

        // Derive cursor position
        int cursor = tag.length() + selectedText.length() + 1;

        // Compute a suitable context information
        IContextInformation contextInfo = 
            new ContextInformation(null, STYLELABELS[i]+" Style");

        // Construct proposal
        result[i] = new CompletionProposal(replacement, 
                selectedRange.x, selectedRange.y,
                cursor, null, STYLELABELS[i], 
                contextInfo, replacement);
    }
    return result;
}
项目:syncope    文件:HTMLCompletionProcessor.java   
@Override public IContextInformation[] computeContextInformation(final ITextViewer viewer,
        final int documentOffset) {
    ContextInformation[] info = new ContextInformation[0];
    return info;
}
项目:BYONDclipse    文件:DMContentAssistProcessor.java   
@Override public IContextInformation[] computeContextInformation(final ITextViewer viewer, final int documentOffset)    { return new ContextInformation[0]; }