Package org.eclipse.php.internal.core.format

Examples of org.eclipse.php.internal.core.format.IFormatterCommonPrferences


  public String[] getIndentPrefixes(ISourceViewer sourceViewer,
      String contentType) {
    Vector<String> vector = new Vector<String>();

    // prefix[0] is either '\t' or ' ' x tabWidth, depending on preference
    IFormatterCommonPrferences formatterCommonPrferences = FormatterUtils
        .getFormatterCommonPrferences();
    char indentCharPref = formatterCommonPrferences
        .getIndentationChar(sourceViewer.getDocument());
    int indentationSize = formatterCommonPrferences
        .getIndentationSize(sourceViewer.getDocument());

    for (int i = 0; i <= indentationSize; i++) {
      StringBuffer prefix = new StringBuffer();
      boolean appendTab = false;
View Full Code Here


    return result;
  }

  // This method applies the standard Tab rule and will perform a regular tab
  private void applyTabRule() {
    IFormatterCommonPrferences formatterCommonPrferences = FormatterUtils
        .getFormatterCommonPrferences();
    char indentChar = formatterCommonPrferences
        .getIndentationChar(document);

    if (indentChar == ' ') {
      // determine where in line this command begins
      int lineOffset = -1;
      try {
        IRegion lineInfo = document
            .getLineInformationOfOffset(command.offset);
        lineOffset = command.offset - lineInfo.getOffset();
      } catch (BadLocationException e) {
        Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
      }

      int indentSize = formatterCommonPrferences
          .getIndentationSize(document);

      if (lineOffset > 0) {
        lineOffset %= indentSize;
        indentSize -= lineOffset;
      }

      if (indentSize == 0) {
        indentSize = formatterCommonPrferences
            .getIndentationSize(document);
      }

      command.text += getIndentationString(indentSize);
    } else {
View Full Code Here

  }

  @Override
  public TemplateBuffer evaluate(Template template)
      throws BadLocationException, TemplateException {
    IFormatterCommonPrferences prefs = FormatterUtils
        .getFormatterCommonPrferences();
    boolean useTab = prefs.useTab(getDocument());
    if (!useTab) {
      int length = prefs.getIndentationSize(getDocument());
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < length; i++) {
        sb.append(prefs.getIndentationChar(getDocument())); //$NON-NLS-1$
      }
      String newPattern = TextUtils.replace(template.getPattern(), TAB,
          sb.toString());
      template = new Template(template.getName(),
          template.getDescription(), template.getContextTypeId(),
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.format.IFormatterCommonPrferences

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.