io.resys.hdes.runtime.spi.ImmutableHdesRuntime Maven / Gradle / Ivy
package io.resys.hdes.runtime.spi;
/*-
* #%L
* hdes-runtime
* %%
* Copyright (C) 2020 Copyright 2020 ReSys OÜ
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.resys.hdes.compiler.api.HdesCompiler.Resource;
import io.resys.hdes.compiler.api.HdesCompiler.ResourceDeclaration;
import io.resys.hdes.compiler.api.HdesCompiler.ResourceName;
import io.resys.hdes.runtime.api.HdesRuntime;
import io.resys.hdes.runtime.spi.tools.HdesJavaFileManager;
import io.resys.hdes.runtime.spi.tools.HdesJavaFileObject;
import io.resys.hdes.runtime.spi.tools.ImmutableRuntimeEnvir;
public class ImmutableHdesRuntime implements HdesRuntime {
private static final Logger LOGGER = LoggerFactory.getLogger(ImmutableHdesRuntime.class);
public static Builder builder() {
return new ImmutableEnvirBuilder();
}
public static class ImmutableEnvirBuilder implements Builder {
private final List resources = new ArrayList<>();
@Override
public RuntimeEnvir build() {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
HdesJavaFileManager fileManager = HdesJavaFileManager.create(compiler);
DiagnosticCollector