Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
housengw committed Mar 2, 2022
2 parents cbd5d12 + c2633ee commit 6485326
Show file tree
Hide file tree
Showing 47 changed files with 925 additions and 1,076 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.lflang.lf.Connection;
import org.lflang.lf.Model;
import org.lflang.lf.Reactor;
import org.lflang.util.FileUtil;

/**
* Diagram synthesis for Lingua Franca programs.
Expand Down Expand Up @@ -985,7 +986,7 @@ private String createReactorLabel(ReactorInstance reactorInstance) {
}
if (reactorInstance.isMainOrFederated()) {
try {
b.append(FileConfig.nameWithoutExtension(reactorInstance.reactorDeclaration.eResource()));
b.append(FileUtil.nameWithoutExtension(reactorInstance.reactorDeclaration.eResource()));
} catch (Exception e) {
throw Exceptions.sneakyThrow(e);
}
Expand Down
6 changes: 3 additions & 3 deletions org.lflang.lfc/src/org/lflang/lfc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import org.lflang.FileConfig;
import org.lflang.LFRuntimeModule;
import org.lflang.LFStandaloneSetup;
import org.lflang.TargetConfig.Mode;
import org.lflang.generator.LFGeneratorContext;
import org.lflang.generator.MainContext;
import org.lflang.util.FileUtil;

import com.google.inject.Inject;
import com.google.inject.Injector;
Expand Down Expand Up @@ -285,7 +285,7 @@ private void runGenerator(List<Path> files, Injector injector) {
exitIfCollectedErrors();

LFGeneratorContext context = new MainContext(
Mode.STANDALONE,CancelIndicator.NullImpl, (m, p) -> {}, properties, false,
LFGeneratorContext.Mode.STANDALONE, CancelIndicator.NullImpl, (m, p) -> {}, properties, false,
fileConfig -> injector.getInstance(ErrorReporter.class)
);

Expand Down Expand Up @@ -346,7 +346,7 @@ public Resource getValidatedResource(Path path) {
issueCollector.accept(new LfIssue(issue.getMessage(), issue.getSeverity(),
issue.getLineNumber(), issue.getColumn(),
issue.getLineNumberEnd(), issue.getColumnEnd(),
issue.getLength(), FileConfig.toPath(uri)));
issue.getLength(), FileUtil.toPath(uri)));
} catch (IOException e) {
reporter.printError("Unable to convert '" + uri + "' to path." + e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.eclipse.xtext.validation.EObjectDiagnosticImpl;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;

import org.lflang.FileConfig;
import org.lflang.util.FileUtil;

import com.google.inject.Inject;

Expand Down Expand Up @@ -57,7 +57,7 @@ void accept(Severity severity, String message, EObject object, EStructuralFeatur
private Path getPath(EObjectDiagnosticImpl diagnostic) {
Path file = null;
try {
file = FileConfig.toPath(diagnostic.getUriToProblem());
file = FileUtil.toPath(diagnostic.getUriToProblem());
} catch (IOException e) {
// just continue with null
}
Expand Down
4 changes: 2 additions & 2 deletions org.lflang.tests/src/org/lflang/tests/Configurators.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface Configurator {
* @return True if successful, false otherwise.
*/
public static boolean useSingleThread(LFTest test) {
test.getContext().getArgs().setProperty("threads", "0");
test.context.getArgs().setProperty("threads", "0");
return true;
}

Expand All @@ -63,7 +63,7 @@ public static boolean useSingleThread(LFTest test) {
* @return True if successful, false otherwise.
*/
public static boolean useFourThreads(LFTest test) {
test.getContext().getArgs().setProperty("threads", "4");
test.context.getArgs().setProperty("threads", "4");
return true;
}

Expand Down
11 changes: 3 additions & 8 deletions org.lflang.tests/src/org/lflang/tests/LFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class LFTest implements Comparable<LFTest> {
/** Object used to determine where the code generator puts files. */
public FileConfig fileConfig;

/** Context provided to the code generators */
public LFGeneratorContext context;

/** Path of the test program relative to the package root. */
private final Path relativePath;

Expand Down Expand Up @@ -113,14 +116,6 @@ public boolean hasFailed() {
return result != Result.TEST_PASS;
}

/**
* Return the context stored in this test's file configuration.
* @return The context for this test, to be passed to the code generator.
*/
public LFGeneratorContext getContext() {
return this.fileConfig.context;
}

/**
* Compile a string that contains all collected errors and return it.
* @return A string that contains all collected errors.
Expand Down
10 changes: 5 additions & 5 deletions org.lflang.tests/src/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.lflang.LFRuntimeModule;
import org.lflang.LFStandaloneSetup;
import org.lflang.Target;
import org.lflang.TargetConfig.Mode;
import org.lflang.generator.GeneratorResult;
import org.lflang.generator.LFGenerator;
import org.lflang.generator.LFGeneratorContext;
Expand Down Expand Up @@ -366,7 +365,7 @@ private static void checkAndReportFailures(Set<LFTest> tests) {
*/
private LFGeneratorContext configure(LFTest test, Configurator configurator, TestLevel level) throws IOException {
var context = new MainContext(
Mode.STANDALONE, CancelIndicator.NullImpl, (m, p) -> {}, new Properties(), true,
LFGeneratorContext.Mode.STANDALONE, CancelIndicator.NullImpl, (m, p) -> {}, new Properties(), true,
fileConfig -> new DefaultErrorReporter()
);

Expand All @@ -380,7 +379,8 @@ private LFGeneratorContext configure(LFTest test, Configurator configurator, Tes
}

fileAccess.setOutputPath(FileConfig.findPackageRoot(test.srcFile, s -> {}).resolve(FileConfig.DEFAULT_SRC_GEN_DIR).toString());
test.fileConfig = new FileConfig(r, FileConfig.getSrcGenRoot(fileAccess), context);
test.context = context;
test.fileConfig = new FileConfig(r, FileConfig.getSrcGenRoot(fileAccess), context.useHierarchicalBin());

// Set the no-compile flag the test is not supposed to reach the build stage.
if (level.compareTo(TestLevel.BUILD) < 0) {
Expand Down Expand Up @@ -437,8 +437,8 @@ protected void addExtraLfcArgs(Properties args) {
private GeneratorResult generateCode(LFTest test) {
GeneratorResult result = GeneratorResult.NOTHING;
if (test.fileConfig.resource != null) {
generator.doGenerate(test.fileConfig.resource, fileAccess, test.fileConfig.context);
result = test.fileConfig.context.getResult();
generator.doGenerate(test.fileConfig.resource, fileAccess, test.context);
result = test.context.getResult();
if (generator.errorsOccurred()) {
test.result = Result.CODE_GEN_FAIL;
throw new AssertionError("Code generation unsuccessful.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ private void runTest(SchedulerOption scheduler, EnumSet<TestCategory> categories
Message.DESC_SCHED_SWAPPING + scheduler.toString() +".",
categories::contains,
test -> {
test.getContext()
.getArgs()
test.context.getArgs()
.setProperty(
"scheduler",
scheduler.toString()
Expand Down
Loading

0 comments on commit 6485326

Please sign in to comment.