Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1034083 // invokeEcj_direct_withDiagnostics (adds ECJ as library to current program)

JavaX fragment (include) [tags: use-pretranspiled]

Uses 3106K of libraries. Click here for Pure Java version (4579L/26K).

lib 1400533 // ECJ

import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaFileObject;
import org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl;

static L<Diagnostic<? extends JavaFileObject>> invokeEcj_direct_withDiagnostics(File optionsFile) ctex {
  new StringWriter writer;
  PrintWriter printWriter = new(writer);
  
  S[] args = { "@" + optionsFile.getPath() };
  
  EclipseCompilerImpl compiler = new EclipseCompilerImpl(printWriter, printWriter, false);
  DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<>();
  compiler.diagnosticListener = diagnosticCollector;
  compiler.compile(args);
  L<Diagnostic<? extends JavaFileObject>> diagnostics = diagnosticCollector.getDiagnostics();
  ret diagnostics;
}

Author comment

Began life as a copy of #1033527

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034083
Snippet name: invokeEcj_direct_withDiagnostics (adds ECJ as library to current program)
Eternal ID of this version: #1034083/1
Text MD5: e36b50193a2c7ecd168744597eeccb7e
Transpilation MD5: b3935ca33583f4837525799501361276
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-21 15:37:47
Source code size: 811 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 140 / 205
Referenced in: [show references]