Klasse DefaultCodeFormatter

java.lang.Object
org.aspectj.org.eclipse.jdt.core.formatter.CodeFormatter
org.aspectj.org.eclipse.jdt.internal.formatter.DefaultCodeFormatter

public class DefaultCodeFormatter extends CodeFormatter
  • Felddetails

    • DEBUG

      public static boolean DEBUG
      Debug trace
    • previewEnabled

      public boolean previewEnabled
  • Konstruktordetails

  • Methodendetails

    • createIndentationString

      public String createIndentationString(int indentationLevel)
      Beschreibung aus Klasse kopiert: CodeFormatter
      Answers the string that corresponds to the indentation to the given indentation level or an empty string if the indentation cannot be computed.

      This method needs to be overridden in a subclass.

      The default implementation returns an empty string.

      Setzt außer Kraft:
      createIndentationString in Klasse CodeFormatter
      Parameter:
      indentationLevel - the given indentation level
      Gibt zurück:
      the string corresponding to the right indentation level
    • format

      public org.eclipse.text.edits.TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator)
      Beschreibung aus Klasse kopiert: CodeFormatter
      Format source, and returns a text edit that correspond to the difference between the given string and the formatted string.

      It returns null if the given string cannot be formatted.

      If the offset position is matching a whitespace, the result can include whitespaces. It would be up to the caller to get rid of preceding whitespaces.

      Angegeben von:
      format in Klasse CodeFormatter
      Parameter:
      kind - Use to specify the kind of the code snippet to format. It can be any of these: Since 3.4 for CodeFormatter.K_COMPILATION_UNIT and since 3.6 for other kinds unrelated to comments, the CodeFormatter.F_INCLUDE_COMMENTS flag can be used to format comments on the fly (see the flag documentation for more detailed explanation).
      source - the source to format
      offset - the given offset to start recording the edits (inclusive).
      length - the given length to stop recording the edits (exclusive).
      indentationLevel - the initial indentation level, used to shift left/right the entire source fragment. An initial indentation level of zero or below has no effect.
      lineSeparator - the line separator to use in formatted source, if set to null, then the platform default one will be used.
      Gibt zurück:
      the text edit
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.core.formatter.CodeFormatter#format(int, java.lang.String, int, int, int, java.lang.String)
    • format

      public org.eclipse.text.edits.TextEdit format(int kind, String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, String lineSeparator)
      Format source, and returns a text edit that correspond to the difference between the given string and the formatted string.

      It returns null if the given string cannot be formatted.

      If an offset position is matching a whitespace, the result can include whitespaces. It would be up to the caller to get rid of preceding whitespaces.

      No region in regions must overlap with any other region in regions. Each region must be within source. There must be at least one region. Regions must be sorted by their offsets, smaller offset first.

      Angegeben von:
      format in Klasse CodeFormatter
      Parameter:
      kind - Use to specify the kind of the code snippet to format. It can be any of these: Since 3.4 for CodeFormatter.K_COMPILATION_UNIT and since 3.6 for other kinds unrelated to comments, the CodeFormatter.F_INCLUDE_COMMENTS flag can be used to format comments on the fly (see the flag documentation for more detailed explanation).
      source - the source to format
      regions - a set of regions in source to format
      indentationLevel - the initial indentation level, used to shift left/right the entire source fragment. An initial indentation level of zero or below has no effect.
      lineSeparator - the line separator to use in formatted source, if set to null, then the platform default one will be used.
      Gibt zurück:
      the text edit
    • setOptions

      public void setOptions(Map<String,String> options)
      Beschreibung aus Klasse kopiert: CodeFormatter
      Sets the formatting options for this formatter.

      The default implementation ignores the options.

      Setzt außer Kraft:
      setOptions in Klasse CodeFormatter
      Parameter:
      options - the options for the formatter