eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
164 stars 130 forks source link

Code format #2002

Closed appt2 closed 8 months ago

appt2 commented 8 months ago
public String format() {
      var options = DefaultCodeFormatterOptions.getEclipseDefaultSettings();

      var codeFormatter = new DefaultCodeFormatter(options);

      var edit =
          codeFormatter.format(
              DefaultCodeFormatter.K_COMPILATION_UNIT,
              source,
              0, // starting index
              source.length(), // length
              0, // initial indentation
              System.lineSeparator() // line separator
              );

      var document = new Document(source);
      try {

        edit.apply(document);
      } catch (Exception e) {
        throw new IllegalStateException(e);
      }
      // return the formatted code
      return document.get();
    }

Hello, I wrote this code to sort Java codes, are other languages ​​supported?

jukzi commented 8 months ago

Hello, I wrote this code to sort Java codes, are other languages ​​supported?

jdt is java only. JAVA-Development-Tools

appt2 commented 8 months ago

Hello, I wrote this code to sort Java codes, are other languages ​​supported?

jdt is java only. JAVA-Development-Tools

ok tnks