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

项目:n4js    文件:JSDocCompletionProposalComputer.java   
private void createLineTagProposal(String prefix, N4JSDocletParser docletParser,
        ArrayList<ICompletionProposal> proposals) {
    int replacementOffset = offset - prefix.length();
    // create line tag proposals
    for (ITagDefinition td : docletParser.getLineTagDictionary().getTagDefinitions()) {
        String tagString = '@' + td.getTitle() + ' ';
        if (tagString.startsWith(prefix)) {

            int replacementLength = prefix.length();
            int cursorPosition = tagString.length();
            ICompletionProposal proposal = new CompletionProposal(tagString, replacementOffset,
                    replacementLength, cursorPosition);
            proposals.add(proposal);
        }
    }
}
项目:ContentAssist    文件:JavaCompletionProposalComputer1.java   
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
    List<ICompletionProposal> propList = new ArrayList<ICompletionProposal>();
    List<ICompletionProposal> newpropList = new ArrayList<ICompletionProposal>();
    List<IContextInformation> propList2 = new ArrayList<IContextInformation>();

    ICompletionProposal first;
    DataManager datamanger = new DataManager(context,monitor);
    Activator.applyoperationlist.add(new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList));
    List<String> list = new ArrayList();
    CompletionProposal proposal;
    propList = datamanger.JavaDefaultProposal();
    propList2 = datamanger.ContextInformation();
    ApplyOperation ao = new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList);
    System.out.println(ao.toString());
    return newpropList;
}
项目:vertigo-chroma-kspplugin    文件:BaseContentAssistProcessor.java   
/**
 * Constuit les propositions d'aucomplétion.
 * 
 * @param suggestions Suggestionsà proposer.
 * @param currentWordSelection Mot courant à remplacer dans le document.
 * @return Propositions d'autocomplétion.
 */
private ICompletionProposal[] buildProposals(List<CompletionCandidate> suggestions, ITextSelection currentWordSelection) {
    /* Calcul l'offset et la longueur du mot à remplacer dans le document. */
    int replacementLength = currentWordSelection.getLength();
    int replacementOffset = currentWordSelection.getOffset();

    /* Construit les propositions en parcourant les suggestions. */
    List<ICompletionProposal> proposals = new ArrayList<>();
    for (CompletionCandidate suggestion : suggestions) {
        /* String qui remplacera le mot courant. */
        String replacementString = suggestion.getDisplayString();

        /* String affiché comme libellé de la proposition. */
        String displayString = replacementString;

        /* String affiché comme description de la proposition (dans la boîte jaune). */
        String additionalProposalInfo = suggestion.getAdditionalProposalInfo();
        CompletionProposal proposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, replacementString.length(), null,
                displayString, null, additionalProposalInfo);
        proposals.add(proposal);
    }
    return proposals.toArray(new ICompletionProposal[0]);
}
项目:Tarski    文件:LoadCompletionProcessor.java   
private void addProposals(List<ICompletionProposal> proposals, String prefix,
    int replacementOffset, String type) {

  Collection<IFile> files = null;
  if (MetaModelPartitionScanner.META_MODEL_LOADMODEL.equals(type)) {
    files = allEcoreFiles.values();
  } else if (MetaModelPartitionScanner.META_MODEL_LOADINSTANCE.equals(type)) {
    files = allFiles.values();
  }

  if (files == null)
    return;

  for (IFile iFile : files) {
    String path = iFile.getFullPath().toString();
    if (path.toLowerCase().startsWith(prefix.toLowerCase())
        || iFile.getName().toLowerCase().startsWith(prefix.toLowerCase())) {
      proposals.add(new CompletionProposal(path, replacementOffset, prefix.length(),
          path.length(), null, iFile.getName() + " - " + path, null, null));
    }
  }
}
项目:ftc    文件:TweakedProposalPosition.java   
public static CompletionProposal[] createCompletionProposals(int completionOffset, String variableType,
        String pattern, String currentText) {
    String patchedText = currentText;
    int variablePosition = completionOffset;

    debug("** create completion proposals **");
    debug("pattern: " + pattern);
    debug(String.format("completion offset %d, variable type %s calculated variable position %d", completionOffset,
            variableType, variablePosition));
    debug("query for parsing: " + patchedText);

    CompletionProposal[] proposals = FtcCompletionProcessor.getModelElementProposals(patchedText, variablePosition,
            0);
    debug(String.format("%d proposals", proposals.length));
    return proposals;
}
项目:texlipse    文件:BibCompletionProcessor.java   
/**
 * Computes the abbreviation completions available based on the prefix.
 * 
 * @param offset Cursor offset in the document
 * @param replacementLength Length of the text to be replaced
 * @param prefix The start of the abbreviation or ""
 * @return An array containing all possible completions
 */
private ICompletionProposal[] computeAbbrevCompletions(int offset, int replacementLength, String prefix) {
    ReferenceEntry[] abbrevs = abbrManager.getCompletions(prefix);
    if (abbrevs == null)
        return null;

    ICompletionProposal[] result = new ICompletionProposal[abbrevs.length];

    for (int i = 0; i < abbrevs.length; i++) {         
        result[i] = new CompletionProposal(abbrevs[i].key,
                offset - replacementLength, replacementLength,
                abbrevs[i].key.length(), null, abbrevs[i].key, null,
                abbrevs[i].info);
    }
    return result;
}
项目:texlipse    文件:TexSpellingEngine.java   
@SuppressWarnings("unchecked")
@Override
public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) {
    List<Word> sugg = fError.getSuggestions();
    int length = fError.getInvalidWord().length();
    ICompletionProposal[] props = new ICompletionProposal[sugg.size() + 2];
    for (int i=0; i < sugg.size(); i++) {
        String suggestion = sugg.get(i).toString();
        String s = MessageFormat.format(CHANGE_TO,
                new Object[] { suggestion });
        props[i] = new CompletionProposal(suggestion, 
                fOffset, length, suggestion.length(), fCorrectionImage, s, null, null);
    }
    props[props.length - 2] = new IgnoreProposal(ignore, fError.getInvalidWord(), context.getSourceViewer());
    props[props.length - 1] = new AddToDictProposal(fError, fLang, context.getSourceViewer());
    return props;
}
项目:texlipse    文件:TexCompletionProcessor.java   
/**
 * Computes and returns reference-proposals (labels).
 * 
 * @param offset
 *            Current cursor offset
 * @param replacementLength
 *            The length of the string to be replaced
 * @param prefix
 *            The already typed prefix of the entry to assist with
 * @return An array of completion proposals to use directly or null
 */
private ICompletionProposal[] computeRefCompletions(int offset,
        int replacementLength, String prefix) {
    List<ReferenceEntry> refEntries = refManager.getCompletionsRef(prefix);
    if (refEntries == null)
        return null;

    ICompletionProposal[] result = new ICompletionProposal[refEntries
            .size()];

    for (int i = 0; i < refEntries.size(); i++) {

        String infoText = null;
        ReferenceEntry ref = refEntries.get(i);

        if (ref.info != null) {
            infoText = (ref.info.length() > assistLineLength) ? wrapString(
                    ref.info, assistLineLength) : ref.info;
        }

        result[i] = new CompletionProposal(ref.key, offset
                - replacementLength, replacementLength, ref.key.length(),
                null, ref.key, null, infoText);
    }
    return result;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexCommandContentAssistProcessor.java   
private Collection<? extends ICompletionProposal> addHeaderAttributes(String oldWord, int offset) {

    int bracketPos = StringUtils.lastIndexOf(oldWord, "[");
    int wordLength = oldWord.length();
    int replacementPos = wordLength - bracketPos;
    String word = StringUtils.substringAfterLast(oldWord, "[");
    List<String> keywords = Formatter.IMPEX_KEYWORDS_ATTRIBUTES;
    Collection<ICompletionProposal> result = Lists.newArrayList();

    for (String keyword : keywords) {
        if (keyword.toUpperCase(Locale.ENGLISH).startsWith(word.toUpperCase(Locale.ENGLISH)) && word.length() < keyword.length()) {

            result.add(new CompletionProposal(keyword + "=", (offset - replacementPos) + 1, word.length(), keyword.length() + 1));
        }
    }
    return result;

}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeSystemContentAssistProcessor.java   
private ICompletionProposal[] attributeProposals(int cursorPosition, List<String> autoSuggests, String currentPart) {

    int counter = 0;
    ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();

        if (currentPart.endsWith(";") || currentPart.endsWith("(")) {
            proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
        }
        else {
            int bracketStart = currentPart.indexOf("(");
            if (bracketStart > 0) {
                int a = (cursorPosition + 1) - (currentPart.length() - bracketStart);
                int b = currentPart.length() - (bracketStart + 1);
                int c = autoSuggest.length();
                proposals[counter] = new CompletionProposal(autoSuggest, a, b, c);
            }
            else {
                proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length());
            }
        }
        counter++;
    }
    return proposals;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeAttributeContentAssistProcessor.java   
private ICompletionProposal[] attributeProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart, boolean endingSemiColon) {

    int counter = 0;
    ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();

        //Each proposal contains the text to propose, as well as information about where to insert the text into the document.
        if (thisAttrib.endsWith(";") || thisAttrib.endsWith("(") || !endingSemiColon) {
            suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
        }
        else {
            suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length());
        }
        counter++;
    }
    return suggestions;
}
项目:velocity-edit    文件:VelocityCompletionProcessor.java   
/**
    * Returns proposals from all variables with given prefix.
    */
   private ICompletionProposal[] getVariableProposals(String aPrefix, int anOffset)
   {
ICompletionProposal[] result = null;
List variables = fEditor.getVariables(fEditor.getLine(anOffset));
if (!variables.isEmpty()) {
    List proposals = new ArrayList();
    Iterator iter = variables.iterator();
    while (iter.hasNext()) {
    String variable = (String) iter.next();
    if (variable.substring(1).startsWith(aPrefix)) {
        proposals.add(new CompletionProposal(variable.substring(1), anOffset, aPrefix.length(), variable.length() - 1, null, variable, null, null));
    }
    }
    Collections.sort(proposals, proposalComparator);
    result = (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
}
return result;
   }
项目: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()]);
}
项目:vTM-eclipse    文件:TrafficScriptAssistantProcessor.java   
/**
 * Create a completion proposal with normal properties.
 * 
 * @param replacementString The string to replace
 * @param replacetmentOffset Where to replace from
 * @param replacementLength How long is the replacement
 * @param cursorPosition The cursor position after completion
 * @param image The icon to display with the proposal
 * @param displayString The string to display in the proposal
 * @param additionalProposalInfo Detailed info to be displayed in a popup.
 * @param type The type of this proposal
 */
public ZCompletionProposal( String replacementString,
   int replacetmentOffset, int replacementLength, int cursorPosition,
   Image image, String displayString, String additionalProposalInfo, Type type )
{
   this.wrapped = new CompletionProposal(
      replacementString,
      replacetmentOffset,
      replacementLength,
      cursorPosition,
      image,
      displayString,
      null,
      additionalProposalInfo 
   );

   this.type = type;
}
项目:APICloud-Studio    文件:CommonContentAssistProcessor.java   
/**
 * addCompletionProposalsForCategory
 * 
 * @param viewer
 * @param offset
 * @param index
 * @param completionProposals
 * @param category
 */
protected void addCompletionProposalsForCategory(ITextViewer viewer, int offset, Index index,
        List<ICompletionProposal> completionProposals, String category)
{
    List<QueryResult> queryResults = index.query(new String[] { category }, "", SearchPattern.PREFIX_MATCH); //$NON-NLS-1$

    if (queryResults != null)
    {
        for (QueryResult queryResult : queryResults)
        {
            String text = queryResult.getWord();
            int length = text.length();
            String info = category + " : " + text; //$NON-NLS-1$

            completionProposals.add(new CompletionProposal(text, offset, 0, length, null, text, null, info));
        }
    }
}
项目:eclipse-filecompletion    文件:FileProposalCalculator.java   
static List<ICompletionProposal> calculateProposalsForEmptyString(final StringLiteral stringLiteral,
        final int documentOffset) throws IOException {
    List<ICompletionProposal> sss = new ArrayList<ICompletionProposal>();
    File[] listRoots = File.listRoots();
    for (File file2 : listRoots) {
        long startInLoop = System.currentTimeMillis();
        String string = file2.getAbsolutePath();
        string = string.replace("\\", "/");
        sss.add(new CompletionProposal(string, stringLiteral.getStartPosition() + 1,
                stringLiteral.getLiteralValue().length(), string.length()));
        startInLoop = System.currentTimeMillis() - startInLoop;
        startInLoop = startInLoop / 1000;
        if (startInLoop > 2) {
            LOG.info("listing take too much time " + startInLoop + " " + file2.getAbsolutePath());
        }
    }
    LOG.info("returning roots " + sss);
    return sss;
}
项目:WP3    文件:LoadCompletionProcessor.java   
private void addProposals(List<ICompletionProposal> proposals, String prefix,
    int replacementOffset, String type) {

  Collection<IFile> files = null;
  if (MetaModelPartitionScanner.META_MODEL_LOADMODEL.equals(type)) {
    files = allEcoreFiles.values();
  } else if (MetaModelPartitionScanner.META_MODEL_LOADINSTANCE.equals(type)) {
    files = allFiles.values();
  }

  if (files == null)
    return;

  for (IFile iFile : files) {
    String path = iFile.getFullPath().toString();
    if (path.toLowerCase().startsWith(prefix.toLowerCase())
        || iFile.getName().toLowerCase().startsWith(prefix.toLowerCase())) {
      proposals.add(new CompletionProposal(path, replacementOffset, prefix.length(),
          path.length(), null, iFile.getName() + " - " + path, null, null));
    }
  }
}
项目:mybatipse    文件:XmlCompletionProposalComputer.java   
private void proposeStatementId(ContentAssistRequest contentAssistRequest,
    IJavaProject project, String matchString, int start, int length, IDOMNode node)
    throws JavaModelException, XPathExpressionException
{
    final List<ICompletionProposal> results = new ArrayList<ICompletionProposal>();
    final MethodNameStore methodStore = new MethodNameStore();
    String qualifiedName = MybatipseXmlUtil.getNamespace(node.getOwnerDocument());
    JavaMapperUtil.findMapperMethod(methodStore, project, qualifiedName,
        new RejectStatementAnnotation(matchString, false));
    for (String methodName : methodStore.getMethodNames())
    {
        results.add(new CompletionProposal(methodName, start, length, methodName.length(),
            Activator.getIcon(), methodName, null, null));
    }
    addProposals(contentAssistRequest, results);
}
项目:birt    文件:JdbcSQLContentAssistProcessor.java   
/**
 * @param columns
 * @return
 */
private ICompletionProposal[] convertColumnsToCompletionProposals(
        ArrayList columns, int offset )
{
    if ( columns.size( ) > 0 )
    {
        ICompletionProposal[] proposals = new ICompletionProposal[columns.size( )];
        Iterator iter = columns.iterator( );
        int n = 0;
        while ( iter.hasNext( ) )
        {
            Column column = (Column) iter.next( );
            proposals[n++] = new CompletionProposal( addQuotes( column.getName( ) ),
                    offset,
                    0,
                    column.getName( ).length( ) );
        }
        return proposals;
    }
    return null;
}
项目:birt    文件:JdbcSQLContentAssistProcessor.java   
/**
 * @param tables
 * @return
 */
private ICompletionProposal[] convertTablesToCompletionProposals(
        ArrayList tables, int offset )
{
    if ( tables.size( ) > 0 )
    {
        ICompletionProposal[] proposals = new ICompletionProposal[tables.size( )];
        Iterator iter = tables.iterator( );
        int n = 0;
        while ( iter.hasNext( ) )
        {
            Table table = (Table) iter.next( );
            proposals[n++] = new CompletionProposal( addQuotes( table.getName( ) ),
                    offset,
                    0,
                    table.getName( ).length( ) );
        }
        return proposals;
    }
    return null;
}
项目:birt    文件:JSCompletionProcessor.java   
protected CompletionProposal[] getCompletionProposals(
        JSObjectMetaData[] metas, int offset )
{
    List<CompletionProposal> proposals = new ArrayList<CompletionProposal>( );
    int wordLength = currentWord == null ? 0 : currentWord.length( );
    for ( int i = 0; i < metas.length; i++ )
    {
        if ( currentWord == null || currentWord.equals( "" ) //$NON-NLS-1$
                || metas[i].getName( )
                        .toLowerCase( )
                        .startsWith( currentWord.toLowerCase( ) ) )
        {
            proposals.add( new CompletionProposal( metas[i].getName( ),
                    offset - wordLength,
                    wordLength,
                    metas[i].getName( ).length( ),
                    null,
                    metas[i].getName( ),
                    null,
                    metas[i].getDescription( ) ) );
        }
    }
    return proposals.toArray( new CompletionProposal[proposals.size( )] );
}
项目:Pydev    文件:PyCodeCompletionUtilsTest.java   
public void testCompareWithUnder() throws Exception {
    List<ICompletionProposal> props = new ArrayList<ICompletionProposal>();
    props.add(new CompletionProposal("_foo1(a, b)", 0, 0, 0));
    props.add(new CompletionProposal("__foo1__", 0, 0, 0));
    props.add(new CompletionProposal("__foo1__()", 0, 0, 0));
    props.add(new CompletionProposal("__foo1()", 0, 0, 0));
    props.add(new CompletionProposal("__foo1 - __something__", 0, 0, 0));
    String qualifier = "_";
    boolean onlyForCalltips = false;

    ICompletionProposal[] proposals = PyCodeCompletionUtils.onlyValid(props, qualifier, onlyForCalltips,
            false, null);
    PyCodeCompletionUtils.sort(proposals, qualifier, null);
    compare(new String[] { "_foo1(a, b)", "__foo1 - __something__", "__foo1()", "__foo1__", "__foo1__()", },
            proposals);
}
项目:Pydev    文件:AssistSurroundWith.java   
private ICompletionProposal createProposal(PySelection ps, ImageCache imageCache, PyEdit edit,
        final String startIndent, IRegion region, int iComp, String comp, TemplateContext context) {
    Template t = new Template("Surround with", SURROUND_WITH_COMPLETIONS[iComp + 1], "", comp, false);
    if (context != null) {
        TemplateProposal proposal = new TemplateProposal(t, context, region,
                imageCache.get(UIConstants.COMPLETION_TEMPLATE), 5) {
            @Override
            public String getAdditionalProposalInfo() {
                return startIndent + super.getAdditionalProposalInfo();
            }
        };
        return proposal;
    } else {
        //In tests
        return new CompletionProposal(comp, region.getOffset(), region.getLength(), 0);
    }
}
项目:org.concordion.ide.eclipse    文件:ProposalSupport.java   
static List<ICompletionProposal> createProposals(String[] choices, int offset, String prefix, String postfix, int cursorOffset, int replacementLen, ProposalIcon icon) {
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    for (String choice : choices) {
        int len = choice.length();
        String display = choice;
        if (postfix != null) {
            choice = choice + postfix;
        }
        if (prefix != null) {
            choice = prefix + choice;
        }
        CompletionProposal proposal = createProposal(display, choice, offset - replacementLen, len + cursorOffset, len, replacementLen, icon);
        proposals.add(proposal);
    }
    return proposals;
}
项目:byteman-editor    文件:BytemanRuleKeywordAssistProcessor.java   
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    try {
        String lastWord = getLastWord(viewer, offset).toUpperCase();

        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
        if(TEMPLATE_RULE_TEXT.startsWith(lastWord) && !TEMPLATE_RULE_TEXT.equals(lastWord)) {
            proposals.add(createRuleTemplate(viewer.getDocument(), offset - lastWord.length()));
        }
        for(String keyword: PROPOSAL_RULE_KEYWORDS){
            if(keyword.startsWith(lastWord) && !keyword.equals(lastWord)){
                proposals.add(new CompletionProposal(
                        keyword, offset - lastWord.length(), lastWord.length(), keyword.length()));
            }
        }
        return proposals.toArray(new ICompletionProposal[proposals.size()]);

    } catch(Exception e){
        BytemanEditorPlugin.logException(e);
    }
    return null;
}
项目:mule-tooling-incubator    文件:UIUtils.java   
public static CompletionProposal build(PropertyKeySuggestion suggestion, int offset, int currentWordLength) {

    String completion = suggestion.getSuggestion() + "=" + suggestion.getDefaultValue();
    String displayName = completion;
    String imgCode = ModulesUICoreImages.AUTOCOMLETE_ATTRIBUTE;
    Image image = ModulesUICoreImages.getImage(imgCode);
    int completionLength = StringUtils.length(completion);

    return new CompletionProposal(
            completion, 
            offset - currentWordLength, 
            currentWordLength, 
            completionLength,
            image,
            displayName,
            null,
            suggestion.getDescription());
}
项目:mule-tooling-incubator    文件:GroovyCompletionProposalBuilder.java   
public static CompletionProposal build(GroovyCompletionSuggestion suggestion, int offset, int currentWordLength) {

    String completion = buildCompletion(suggestion);
    String displayName = buildDisplayName(suggestion);
    Image image = buildImage(suggestion);
    int completionLength = StringUtils.length(completion);

    return new CompletionProposal(
            completion, 
            offset - currentWordLength, 
            currentWordLength, 
            completionLength,
            image,
            displayName,
            null,
            suggestion.getSuggestionDescription());
}
项目:ec4e    文件:EditorConfigCompletionProposal.java   
@Override
public void apply(IDocument document) {
    initIfNeeded();
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(),
            getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(),
            getAdditionalProposalInfo());
    proposal.apply(document);
}
项目:eclipse-asciidoctools    文件:AsciidocAnchorsProposals.java   
public static ComparableCompletionProposal toCompletionProposal(IDocument document, int offset, int replacement, String variable, int priority) {
    String replacementString = "<<" + variable + ",>>";
    return new ComparableCompletionProposal(
            new CompletionProposal(replacementString, offset - replacement, replacement, replacementString.length() - 2,
                    Activator.getDefault().getImage("/icons/completion-gotoanchor.png"), replacementString + " - Add link to anchor", null, null),
            priority);
}
项目:http4e    文件:AssistUtils.java   
/**
 * Adding http 1.1 headers proposals
 */
public static void doHttpHeadersProposals( int offset, String qualifier, List proposalsList){
    List httpHeaders = LazyObjects.getHttpHeaders();
    int qlen = qualifier.length();

    for (Iterator iter = httpHeaders.iterator(); iter.hasNext();) {
      String text = (String) iter.next();
      if (text.toLowerCase().startsWith(qualifier.toLowerCase())) {
         int cursor = text.length();
         CompletionProposal cp = new CompletionProposal(text + AssistConstants.BRACKETS_COMPLETION, offset - qlen, qlen, cursor + 4, ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.ASSIST_HEADER), text, null, LazyObjects.getInfoMap("Headers").getInfo(text));
         proposalsList.add(cp);
      }
    }
}
项目:http4e    文件:AssistUtils.java   
private static void buildWordTrackProposals( List suggestions, String replacedWord, int offset, List proposalsList){
   int index = 0;
   for (Iterator i = suggestions.iterator(); i.hasNext();) {
      String currSuggestion = (String) i.next();
      proposalsList.add( new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.ASSIST_HEADER_CACHED), currSuggestion, null, LazyObjects.getInfoMap("Headers").getInfo(currSuggestion)));
      index++;
   }
}
项目:http4e    文件:Ch5CompletionEditor.java   
private ICompletionProposal[] buildProposals( List suggestions, String replacedWord, int offset){
   ICompletionProposal[] proposals = new ICompletionProposal[suggestions.size()];
   int index = 0;
   for (Iterator i = suggestions.iterator(); i.hasNext();) {
      String currSuggestion = (String) i.next();
      proposals[index] = new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length());
      index++;
   }
   return proposals;
}
项目:ftc    文件:FtcCompletionProcessor.java   
private static CompletionProposal[] getModelElementProposals(List<ModelElementCompletion> modelElements, int replacementOffset, int replacementLength) {
    CompletionProposal[] result = new CompletionProposal[modelElements.size()];

    int i = 0;
    for (ModelElementCompletion e : modelElements) {
        result[i] = new CompletionProposal(e.getPatch(), replacementOffset, replacementLength, e.getPatch().length());
        i++;
    }

    return result;
}
项目:ftc    文件:TweakedProposalPosition.java   
@Override
public ICompletionProposal[] getChoices() {
    CompletionProposal[] choices = createCompletionProposals(offset, variable.getType(),
            context.getCurrentTemplate().getPattern(), context.getDocument().get());
    ICompletionProposal[] result = createPositionBasedProposals(offset, variable, choices);
    return result;
}
项目:ftc    文件:FtcVariableResolver.java   
public static CompletionProposal[] createCompletionProposals(int completionOffset, String variableType,
        String pattern, String currentText) {
    debug("* variable resolver *");
    int replacementLength = 0; // TODO length of selected text actually
    CompletionProposal[] proposals;

    String patchedText = StringUtil.insert(currentText, completionOffset, prepareForParsing(pattern));
    // + 2 : in prepareForParsing e.g. "${t}" gets changed to " t "
    // so the index must be at "t" rather than "$"
    int variablePosition = completionOffset + (pattern.indexOf(String.format("${%s}", variableType))) + 2;

    if (variableType.startsWith(LEADING_CHAR_COLUMNVAR)) {
        String patch = DUMMY_COLNAME;

        CompletionProposal dummyProposal = new CompletionProposal(patch, variablePosition, replacementLength,
                patch.length());
        // 2 dummy proposals needed to trigger the use of a TweakedProposalPosition in TweakedTemplateProposal
        // no handling of this kind for tables, though, to cover the case where there's one table only too
        proposals = new CompletionProposal[] { dummyProposal, dummyProposal };

    } else {
        debug(String.format("table at %d ", variablePosition));

        debug("pattern: " + pattern);
        debug(String.format("completion offset %d, variable type %s calculated variable position %d",
                completionOffset, variableType, variablePosition));
        debug("patched query for parsing: " + patchedText);

        proposals = FtcCompletionProcessor.getModelElementProposals(patchedText, variablePosition,
                replacementLength);

        debug(String.format("%d proposals", proposals.length));
    }
    return proposals;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexCommandContentAssistProcessor.java   
private void proposeHeaderOperands(int offset, IDocument document, List<ICompletionProposal> proposals) {

    String line = getCurrentLine(document, offset);
    if (!containsHeader(line)) {

        for (String keyword : Formatter.HEADER_MODE_PROPOSALS) {
            proposals.add(new CompletionProposal(keyword + " ", offset, 0, keyword.length() + 1));
        }
    }
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeSystemContentAssistProcessor.java   
private ICompletionProposal[] typeProposals(int cursorPosition, List<String> autoSuggests, String currentPart) {

    int counter = 0;
    ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();
        //Each proposal contains the text to propose, as well as information about where to insert the text into the document. 
        proposals[counter] = new CompletionProposal(autoSuggest + ";", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1);
        counter++;
    }
    return proposals;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeSystemContentAssistProcessor.java   
private ICompletionProposal[] keywordProposals(int cursorPosition, List<String> autoSuggests, String currentPart, boolean includeEquals, boolean includesComma) {

    int counter = 0;
    ICompletionProposal[] proposals = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();

        if (currentPart.endsWith("[")) {
            proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1);
        }
        else {
            if (includeEquals) {
                if (includesComma) {
                    proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1);
                }
                else {
                    proposals[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1);
                }
            }
            else if (includesComma) {
                if (currentPart.endsWith("=")) {
                    proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
                }
                else {
                    proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1);
                }
            }
            else {
                proposals[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
            }
        }
        counter++;
    }
    return proposals;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeAttributeContentAssistProcessor.java   
private ICompletionProposal[] typeProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart) {

    int counter = 0;
    ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();

        //Each proposal contains the text to propose, as well as information about where to insert the text into the document. 
        suggestions[counter] = new CompletionProposal(autoSuggest + ";", cursorPosition - thisAttrib.length(), thisAttrib.length(), autoSuggest.length() + 1);
        counter++;
    }
    return suggestions;
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexTypeAttributeContentAssistProcessor.java   
private ICompletionProposal[] keywordProposals(int cursorPosition, List<String> autoSuggests, String thisAttrib, String currentPart, boolean includeEquals, boolean includesComma) {

    int counter = 0;
    ICompletionProposal[] suggestions = new ICompletionProposal[autoSuggests.size()];
    for (Iterator<String> iter = autoSuggests.iterator(); iter.hasNext();) {
        String autoSuggest = (String)iter.next();

        //Each proposal contains the text to propose, as well as information about where to insert the text into the document.
        if (thisAttrib.endsWith("[")) {
            suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1);
        }
        else {
            if (includeEquals) {
                if (includesComma) {
                    suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition, 0, autoSuggest.length() + 1);
                }
                else {
                    suggestions[counter] = new CompletionProposal(autoSuggest + "=", cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1);
                }
            }
            else if (includesComma) {
                if (thisAttrib.endsWith("=")) {
                    suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
                }
                else {
                    suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition - currentPart.length(), currentPart.length(), autoSuggest.length() + 1);
                }
            }
            else {
                suggestions[counter] = new CompletionProposal(autoSuggest, cursorPosition, 0, autoSuggest.length());
            }
        }
        counter++;
    }
    return suggestions;
}