Package org.eclipse.jface.text.contentassist

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


    if (fProposals != null) {
      return fProposals;
    } else if (fProposalStrings != null) {
      ICompletionProposal[] result= new ICompletionProposal[fProposalStrings.length];
      for (int i= 0; i < fProposalStrings.length; i++) {
        result[i]= new CompletionProposal(fProposalStrings[i], position, fProposalStrings[i].length(), fProposalStrings[i].length());
      }
      return result;
    } else return null;
  }
View Full Code Here


*/
@SuppressWarnings("all")
public class TemplateProposalProvider extends AbstractTemplateProposalProvider {
  public void complete_TEXT(final EObject model, final RuleCall ruleCall, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    int _offset = context.getOffset();
    CompletionProposal _completionProposal = new CompletionProposal("«»", _offset, 0, 1);
    acceptor.accept(_completionProposal);
  }
View Full Code Here

        _offset + offset - matchString.length(), matchString.length() - _offset,
        getReplaceString().length(),
        getImage()==null ? defaultImage : getImage(),
        getDisplayString(), null, null);
    }
    return new CompletionProposal(
        getReplaceString(),
        _offset + offset - matchString.length(), matchString.length() - _offset,
        getReplaceString().length(),
        getImage()==null ? defaultImage : getImage(),
        getDisplayString(), null, null);
View Full Code Here

    ICompletionProposal[] prop = list.toArray(new ICompletionProposal[list.size()]);
    return prop;
  }
 
  private static CompletionProposal createProposal(String text, String display, String word, int offset, int position, String image){
    return new CompletionProposal(
        text, offset - word.length(), word.length(), position,
        HTMLPlugin.getDefault().getImageRegistry().get(image), display,
        null, null);
  }
View Full Code Here

    List<ICompletionProposal> assistInfos = new ArrayList<ICompletionProposal>();
   
    for(int i=0;i<values.size();i++){
      String value = values.get(i);
      if(value.startsWith(lastWord)){
        assistInfos.add(new CompletionProposal(
            value,
            offset-lastWord.length(),
            lastWord.length(),
            value.length(),
            valueImage,
View Full Code Here

    List<ICompletionProposal> assistInfos = new ArrayList<ICompletionProposal>();
   
    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

      for (int i = 0; i < tagList.size(); i++) {
        TagInfo tagInfo = tagList.get(i);
        if (tagInfo instanceof TextInfo) {
          TextInfo textInfo = (TextInfo) tagInfo;
          if ((textInfo.getText().toLowerCase()).indexOf(word) == 0) {
            list.add(new CompletionProposal(textInfo.getText(), documentOffset - word.length(), word.length(), textInfo.getPosition(), _tagImage, textInfo.getDisplayString(), null, tagInfo.getDescription()));
          }
          continue;
        }
        String tagName = tagInfo.getTagName();
        String tagNameMatch = "<" + tagName.toLowerCase();
        if (tagNameMatch.startsWith(word) && !(tagNameMatch.equals(word) && next.startsWith(">"))) {
          String assistKeyword = tagName;
          int position = 0;
          // required attributes
          AttributeInfo[] requireAttrs;
          if (inTag) {
            requireAttrs = new AttributeInfo[0];
            position = tagName.length() + 1;
          }
          else {
            requireAttrs = tagInfo.getRequiredAttributeInfo();
            for (int j = 0; j < requireAttrs.length; j++) {
              assistKeyword = assistKeyword + " " + requireAttrs[j].getAttributeName();
              if (requireAttrs[j].hasValue()) {
                assistKeyword = assistKeyword + equals + "\"\"";
                if (j == 0) {
                  position = tagName.length() + requireAttrs[j].getAttributeName().length() + (spacesAroundEquals ? 5 : 3);
                }
              }
            }
          }
          boolean forceAttributePosition = (requireAttrs.length == 0 && tagInfo.requiresAttributes());
          if (!inTag) {
            if (tagInfo.hasBody()) {
              assistKeyword = assistKeyword + ">";
              if (_assistCloseTag) {
                if (position == 0) {
                  position = assistKeyword.length();
                }
                assistKeyword = assistKeyword + "</" + tagName + ">";
              }
            }
            else {
              if (tagInfo.isEmptyTag() && _xhtmlMode == false) {
                assistKeyword = assistKeyword + ">";
              }
              else {
                assistKeyword = assistKeyword + "/>";
              }
            }
          }
          if (position == 0) {
            position = assistKeyword.length();
          }
          if (forceAttributePosition && position > 0) {
            if (tagInfo.hasBody()) {
              position--;
            }
            else if (tagInfo.isEmptyTag()) {
              if (_xhtmlMode) {
                position -= 2;
              }
              else {
                position--;
              }
            }
          }
          try {
            if (tagInfo instanceof InlineWodTagInfo && BindingReflectionUtils.memberIsDeprecated(((InlineWodTagInfo)tagInfo).getElementType())) {
              list.add(new HTMLDeprecatedCompletionProposal(assistKeyword, documentOffset - word.length() + 1, word.length() - 1, position, _tagImage, tagName, null, tagInfo.getDescription()));
            } else {
              list.add(new CompletionProposal(assistKeyword, documentOffset - word.length() + 1, word.length() - 1, position, _tagImage, tagName, null, tagInfo.getDescription()));
            }
          }
          catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }
      // custom elements
      for (int i = 0; i < _customElems.size(); i++) {
        CustomElement element = _customElems.get(i);
        if ((element.getAssistString().toLowerCase()).indexOf(word) == 0) {
          int position = element.getAssistString().indexOf('"');
          if (position == -1) {
            position = element.getAssistString().indexOf("><");
          }
          if (position == -1) {
            position = element.getAssistString().length();
          }
          list.add(new CompletionProposal(element.getAssistString(), documentOffset - word.length(), word.length(), position + 1, _tagImage, element.getDisplayName(), null, null));
        }
      }
      // attribute
    }
    else if (!prev.equals("")) {
      String tagName = prev;
      TagInfo tagInfo = getTagInfo(tagName);
      if (tagInfo != null) {
        AttributeInfo[] attrList = tagInfo.getAttributeInfo();
        for (int j = 0; j < attrList.length; j++) {
          if (attrList[j].getAttributeName().toLowerCase().indexOf(word) == 0) {
            String assistKeyword = null;
            int position = 0;
            if (attrList[j].hasValue()) {
              assistKeyword = attrList[j].getAttributeName() + equals + "\"\"";
              position = equals.length() + 1;
            }
            else {
              assistKeyword = attrList[j].getAttributeName();
              position = 0;
            }
            list.add(new CompletionProposal(assistKeyword, documentOffset - word.length(), word.length(), attrList[j].getAttributeName().length() + position, _attrImage, attrList[j].getAttributeName(), null, attrList[j].getDescription()));
          }
        }
      }
      // custom attributes
      for (int i = 0; i < _customAttrs.size(); i++) {
        CustomAttribute attrInfo = _customAttrs.get(i);
        if (attrInfo.getTargetTag().equals("*") || attrInfo.getTargetTag().equals(tagName)) {
          if (tagName.indexOf(":") < 0 || _customElemNames.contains(tagName)) {
            list.add(new CompletionProposal(attrInfo.getAttributeName() + equals + "\"\"", documentOffset - word.length(), word.length(), attrInfo.getAttributeName().length() + 2, _attrImage, attrInfo.getAttributeName(), null, null));
          }
        }
      }
      // close tag
    }
    else if (!last.equals("")) {
      TagInfo info = getTagInfo(last);
      if (info == null || _xhtmlMode == true || info.hasBody() || !info.isEmptyTag()) {
        String assistKeyword = "</" + last + ">";
        int length = 0;
        if (assistKeyword.toLowerCase().startsWith(word)) {
          length = word.length();
        }
        list.add(new CompletionProposal(assistKeyword, documentOffset - length, length, assistKeyword.length(), _tagImage, assistKeyword, null, null));
      }
    }

    HTMLUtil.sortCompilationProposal(list);

View Full Code Here

              type = VARIABLE;
              replace = children[i].getName();
              position = replace.length();
            }
            if(!addedStrings.contains(replace)){
              proposal.add(new CompletionProposal(
                  replace, offset - word.length(), word.length(),
                  position, getImageFromType(type),
                  children[i].toString(), null, null));
              addedStrings.add(replace);
            }
View Full Code Here

      this.replaceString = replaceString;
      this.position = position;
    }
   
    public CompletionProposal createCompletionProposal(int offset, String word){
      return new CompletionProposal(
          replaceString, offset - word.length(), word.length(),
          position, getImageFromType(type),
          displayString, null, null);
    }
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.