Skip to content

Supoprt passing in LanguageIn and LanguageOut #10

@ScottHuston

Description

@ScottHuston

Enhancement request

The Google Closure Compiler supports setting the LanguageIn and LanguageOut for the compilation. This is pretty useful.

Currently, they are both set to ECMASCRIPT_2021

Adding a LanguageIn and LanguageOut property would be ideal. Valid values are in com.google.javascript.jscomp.CompilerOptions

NOTE: I'm not a Java developer. A dozen other languages, but just never Java, so the code changes below are educated guidance from examining the codebase.

Changes would be needed to openapi.yaml ~line:90

    CompileRequest:
      type: "object"
      properties:
        compilationLevel:
          type: "string"
        warningLevel:
          type: "string"
        outputFileName:
          type: "string"
        payload:
          type: "string"
        formatting:
          $ref: "#/components/schemas/Formatting"
        externalScripts:
          $ref: "#/components/schemas/ExternalScripts"
        languageIn:
          type: "string"
        languageOut:
          type: "string"

domain\CompileRequest.java

+line 26

import com.google.javascript.jscomp.CompilerOptions;

+line59-93

  public LanguageMode getLanguageIn() {
	LanguageMode rv;
	try {
	  rv = LanguageMode.valueOf(languageIn);
	} catch {
		// If it is not a recognized enum value, set it to STABLE.
		this.languageIn = "STABLE";
		rv = LanguageMode.STABLE;
	} finally {
		return rv;
	}
  }

  public void setLanguageIn(String languageIn) {
    this.languageIn = languageIn;
  }

  public LanguageMode getLanguageOut() {
	LanguageMode rv;
	try {
	  rv = LanguageMode.valueOf(languageOut);
	} catch {
		// If it is not a recognized enum value defeat transpiling.
		this.languageOut = "NO_TRANSPILE";
		rv = LanguageMode.NO_TRANSPILE;
	} finally {
		return rv;
	}
  }

  public void setLanguageOut(String languageOut) {
    this.languageOut = languageOut;
  }

~line 125:

  public String toString() {
    return "CompileRequest{"
        + "compilationLevel='"
        + compilationLevel
        + '\''
        + ", warningLevel='"
        + warningLevel
        + '\''
        + ", languageIn='"
        + languageIn
        + '\''
        + ", languageOut='"
        + languageOut
        + '\''
        + ", outputFileName='"
        + outputFileName
        + '\''
        + ", formatting='"
        + formatting
        + '\''
        + ", workload='"
        + payload
        + '\''
        + ", externalScripts='"
        + externalScripts
        + '\''
        + '}';
  }

~line 159:

    return Objects.equals(compilationLevel, that.compilationLevel)
        && Objects.equals(warningLevel, that.warningLevel)
        && Objects.equals(languageIn, that.languageIn)
        && Objects.equals(languageOut, that.languageOut)
        && Objects.equals(outputFileName, that.outputFileName)
        && Objects.equals(payload, that.payload)
        && Objects.equals(formatting, that.formatting)
        && Objects.equals(externalScripts, that.externalScripts);

~line 172:

    return Objects.hash(
        compilationLevel, warningLevel, languageIn, languageOut, outputFileName, payload, formatting, externalScripts);
  }

rest\CompilerResource.java
~line 146:

    options.setLanguageIn(request.getLanguageIn());
    options.setLanguageOut(request.getLanguageOut());

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions