Package org.eclipse.jface.text.contentassist

Examples of org.eclipse.jface.text.contentassist.CompletionProposal


    List assistInfos = new ArrayList();
   
    for(int i=0;i<DIRECTIVES.length;i++){
      String directive = DIRECTIVES[i];
      if(directive.startsWith(lastWord)){
        assistInfos.add(new CompletionProposal(
            directive,
            offset-lastWord.length(),
            lastWord.length(),
            directive.length(),
            tagImage,
View Full Code Here


   
    for(int i=0;i<attrs.length;i++){
      String attrName = attrs[i];
      String replace = attrName + "=\"\"";
      if(attrName.startsWith(lastWord)){
        assistInfos.add(new CompletionProposal(
            replace,
            offset-lastWord.length(),
            lastWord.length(),
            replace.length() - 1,
            attrImage,
View Full Code Here

        } else {
          String replacement = replacements.get(reservedWord);
          if (replacement == null)
            replacement = reservedWord;
          reservedWords.add(
              new CompletionProposal(replacement, // replacement string
                  replacementOffset, //replacement offset
                  replacementLength, // replacement length
                  replacement.length(), // cursor position
                  null, // image
                  reservedWord, // display string
                  languageContextInformation.get(reservedWord), // context information
                  MessageFormat.format("Tool reserved: {0}", //additional proposal information
                      new Object[] { reservedWord})));
        }
      }
      // Constants
      for (String constant : IToolWords.ToolConstants) {
        if (!lastWord.isEmpty() && !constant.startsWith(lastWord)){
          continue;
        }
        reservedWords.add(
          new CompletionProposal(constant,
              replacementOffset,
              replacementLength,
              constant.length()));
      }
      // Scalars
      for (String scalar : IToolWords.ToolScalarTypes) {
        if (!lastWord.isEmpty() && !scalar.startsWith(lastWord)){
          continue;
        }
        reservedWords.add(
          new CompletionProposal(scalar, // replacement string
              replacementOffset, //replacement offset
              replacementLength, // replacement length
              scalar.length()));//, // cursor position
      }
      //Sort the result
View Full Code Here

  private static ICompletionProposal forProposal(String lastWord, int offset, String indent){
      int replacementOffset = offset - lastWord.length();
      int replacementLength = lastWord.length();
    String replacement = "for x in y do\n" + indent + "end for;\n";
    CompletionProposal cp = new CompletionProposal(replacement, // replacement string
        replacementOffset, //replacement offset
        replacementLength, // replacement length
        4, // cursor position
        null, // image
        "for", // display string
View Full Code Here

                        String[] wids = getWicketIdsFrom(line);
                        for (String wid : wids) {
                          final String additionalInfo = line.trim().replaceAll("<", "&lt;").replaceAll("\"" + wid + "\"", "\"<b>" + wid + "</b>\"");
                          final IRegion sar = DocumentHelper.findStringArgumentInJava(document, context.getInvocationOffset());

                          final CompletionProposal ccp = new CompletionProposal(wid, sar.getOffset(), sar.getLength(), 0, img, wid, null, additionalInfo);
                          proposals.put(wid, ccp);
                        }
                      }
                    } else if (openKind.equals(WicketHyperlink.PROPERTIES)) {

                      if (filename.endsWith(WicketHyperlink.PROPERTIES) && line.contains("=")) {

                        final String key = line.split("=")[0];
                        final IRegion sar = DocumentHelper.findStringArgumentInJava(document, context.getInvocationOffset());
                        final CompletionProposal ccp = new CompletionProposal(key, sar.getOffset(), sar.getLength(), 0, img, key, null, line.trim().replaceAll(key, "<b>" + key + "</b>"));
                        proposals.put(key, ccp);
                      } else if (filename.endsWith(WicketHyperlink.XML) && line.contains("<entry key=\"")) {

                        final String key = line.split("<entry key=\"")[1].split("\">")[0];
                        final IRegion sar = DocumentHelper.findStringArgumentInJava(document, context.getInvocationOffset());
                        final CompletionProposal ccp = new CompletionProposal(key, sar.getOffset(), sar.getLength(), 0, img, key, null, line.trim().replaceAll("<", "&lt;").replaceAll("\"" + key + "\"", "\"<b>" + key + "</b>\""));
                        proposals.put(key, ccp);
                      }
                    }
                  }
                  br.close();
View Full Code Here

          String[] ss = line.split("\"");
          if (ss.length > 1) {
            for (int i = 1; i < ss.length; i += 2) {
              final String proposedWid = ss[i];
              if (proposedWid.length() > 0 && !proposedWid.contains(":") && !proposedWid.contains("~")) {
                final CompletionProposal proposal = new CompletionProposal(proposedWid, rtr.getOffset(), existingWid.length(), rtr.getOffset(), img, proposedWid, null, line.replaceAll("\"" + proposedWid + "\"", "\"<b>" + proposedWid + "</b>\""));
                proposals.put(proposedWid, proposal);
              }
            }
          }
        }
View Full Code Here

      String[] variables = data.getVariables();
      for (int i = 0; i < variables.length; i++) {
          if (variables[i].startsWith(prefix)) {
              String displayString = variables[i] + " - " + fileNameIncluded;
              String stringToAdd = variables[i].substring(prefix.length());
              CompletionProposal prop = new CompletionProposal(stringToAdd, offset, 0, stringToAdd.length(), null, displayString, null, null);
              proposals.put(displayString, prop);
          }
      }
     
       String[] functions = data.getFunctions();
       for (int i = 0; i < functions.length; i++) {
           String funcName = "";
           if (functions[i].indexOf('(') != -1) {
               // Add regular functions
               funcName = functions[i].substring(0, functions[i].indexOf('('));
           } else if (functions[i].indexOf(' ') != -1) {
               // Add cmdlets
               funcName = functions[i].substring(0, functions[i].indexOf(' '));
           } else {
               // Nothing to add
               break;
           }
          
           if (funcName.startsWith(prefix)) {
               String displayString = functions[i] + " - " + fileNameIncluded;
               String stringToAdd = funcName.substring(prefix.length());
               CompletionProposal prop = new CompletionProposal(stringToAdd, offset, 0, stringToAdd.length(), null, displayString, null, null);
               proposals.put(displayString, prop);
           }
       }

       String[] includes = data.getSourcedFiles();
View Full Code Here

    fRelevance = relevance;
    fUpdateLengthOnValidate = updateReplacementLengthOnValidate;
  }

  public void apply(IDocument document) {
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    proposal.apply(document);
  }
View Full Code Here

   *
   * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(org.eclipse.jface.text.IDocument,
   *      char, int)
   */
  public void apply(IDocument document, char trigger, int offset) {
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    // we currently don't do anything special for which character
    // selected the proposal, and where the cursor offset is
    // but we might in the future...
    proposal.apply(document);
    // we want to ContextInformationPresenter.updatePresentation() here
  }
View Full Code Here

    return fReplacementString;
  }

  public Point getSelection(IDocument document) {
    // return fProposal.getSelection(document);
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    return proposal.getSelection(document);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.contentassist.CompletionProposal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.