Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic LF code formatter #1227

Merged
merged 138 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 132 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
8dea149
[fed] Add empty overrides of toText functions.
petervdonovan Jun 8, 2022
fd5ee16
Handle ToText of Model and TargetDecl
lhstrh Jun 8, 2022
07b4415
[fed] Start implementing the new toText cases.
petervdonovan Jun 9, 2022
48cd0fe
[fed] Implement more toText cases.
petervdonovan Jun 9, 2022
234189a
[fed] All toText cases have (untested) implementations.
petervdonovan Jun 9, 2022
afd82f5
[fed] toText: Add some fixes.
petervdonovan Jun 10, 2022
a987311
[tests] First draft test for toText functions.
petervdonovan Jun 10, 2022
4dfda7a
[validator] Address runtime error for an incorrect program.
petervdonovan Jun 10, 2022
8939ee6
[fed] More fixes for pretty-printer. Still does not compile.
petervdonovan Jun 10, 2022
b67bf88
[tests] Attempt linking.
petervdonovan Jun 11, 2022
b722f6d
[tests] Linking works.
petervdonovan Jun 11, 2022
9568c3d
[fed] More fixes for pretty-printer.
petervdonovan Jun 11, 2022
d5c1f40
[ast] Separate concerns: ToLf != toText.
petervdonovan Jun 11, 2022
fa0de9d
[fed] Pretty-printer passes sanity checks.
petervdonovan Jun 11, 2022
c3a0237
[fed] Pretty-printer: cosmetic changes.
petervdonovan Jun 12, 2022
527463c
[tests] Partially implement IsEqual for versions of the AST.
petervdonovan Jun 12, 2022
68b4dde
[formatting] Bring up to date with master.
petervdonovan Jun 12, 2022
ce68934
[formatting] Address Rust test failure.
petervdonovan Jun 12, 2022
44f039d
[formatting] Finish first draft of IsEqual.
petervdonovan Jun 13, 2022
afe2332
[formatting] IsEqual works. Test passes.
petervdonovan Jun 13, 2022
a68fe47
[formatting] Bugfix.
petervdonovan Jun 13, 2022
4147eb6
basic implementation of line wrap for formatter
billy-bao Jun 14, 2022
eb92906
update docstrings
billy-bao Jun 14, 2022
90a4c97
Merge pull request #1232 from lf-lang/formatter-linewrap-string
lhstrh Jun 14, 2022
8973b11
Rename org.lflang.lfc to org.lflang.cli
billy-bao Jun 15, 2022
31a1d2c
Attempt to update build scripts for lfc
billy-bao Jun 16, 2022
646eae7
Update Github CI for lfc
billy-bao Jun 16, 2022
09fe7f1
Temporarily use the version of CI on this branch instead of master.
billy-bao Jun 16, 2022
cae81f9
fix testing change
billy-bao Jun 16, 2022
9acd538
fix testing change
billy-bao Jun 16, 2022
c7937fb
rerun CI
billy-bao Jun 16, 2022
3c314c6
Merge pull request #1235 from lf-lang/lfc-to-cli
lhstrh Jun 16, 2022
42f6f69
Update ci.yml
lhstrh Jun 16, 2022
7578dc5
initial version of lff - command-line options not implemented yet
billy-bao Jun 21, 2022
b0b3790
update ReportingUtil for both lfc + lff
billy-bao Jun 22, 2022
dd83e2e
recursively format subdirectories by default, and implement --no-recu…
billy-bao Jun 23, 2022
ff5e07a
add line wrap option
billy-bao Jun 23, 2022
9f62955
CI
billy-bao Jun 23, 2022
ee7ffbd
fix gradle scripts for building lfc/lff
billy-bao Jun 23, 2022
fbab0a0
revert previous change, which didn't work
billy-bao Jun 23, 2022
678b348
actually fix gradle scripts
billy-bao Jun 23, 2022
c62b104
formatting fixes
billy-bao Jun 24, 2022
fef0eea
refactor lfc and lff with a CliBase class
billy-bao Jun 25, 2022
5ecad19
add javadoc
billy-bao Jun 25, 2022
ebac690
refactor version string into its own file
billy-bao Jun 28, 2022
3db47f2
Update org.lflang/src/org/lflang/StringsBundle.properties
lhstrh Jun 28, 2022
efb1400
Merge pull request #1240 from lf-lang/lff-standalone
lhstrh Jun 28, 2022
5aaf430
[formatting] Start infrastructure for line wrapping.
petervdonovan Jun 14, 2022
f26efaf
[formatting] RoundTripTest passes again.
petervdonovan Jun 29, 2022
e7d3e60
[formatting] Line wrapping works.
petervdonovan Jun 30, 2022
1baa4be
Hook formatter into the Xtext framework.
petervdonovan Jun 23, 2022
47ff26b
Preserve preceding comments.
petervdonovan Jun 24, 2022
bb24802
Bugfixes.
petervdonovan Jun 24, 2022
3b87a68
[formatting] Clean up, cover edge cases.
petervdonovan Jun 27, 2022
1298287
[formatting] Comments are inserted.
petervdonovan Jul 1, 2022
b1facb1
[formatting] Line wrapping for comments works.
petervdonovan Jul 1, 2022
7ee0123
[formatting] Adjust comment placement.
petervdonovan Jul 1, 2022
ea64b4a
[formatting] Refactor.
petervdonovan Jul 1, 2022
65dcd62
[formatting] More superficial cleanups.
petervdonovan Jul 1, 2022
9bd1792
Fix IndexOutOfBoundsException when formatting.
petervdonovan Jul 2, 2022
acc3cc9
[formatting] Adjust comment placement.
petervdonovan Jul 2, 2022
5435cd8
[formatting] Clean up indentation implementation.
petervdonovan Jul 2, 2022
586ed25
[formatting] Slightly adjust cost function.
petervdonovan Jul 2, 2022
5660795
[formatting] Do not drop sibling comments.
petervdonovan Jul 2, 2022
af8b2b9
[formatting] Format C concurrent tests.
petervdonovan Jul 2, 2022
26decb5
[formatting] Do fancier tree climbing :-/
petervdonovan Jul 2, 2022
297f156
[formatting] Format C docker tests.
petervdonovan Jul 2, 2022
b0d13b4
[formatting] Minor aesthetic change.
petervdonovan Jul 2, 2022
e8a67e6
Address IOException on Windows.
petervdonovan Jul 2, 2022
85ee02e
[formatting] Fine-tune the "cost function" idea.
petervdonovan Jul 2, 2022
8d45b7f
[formatting] More small adjustments.
petervdonovan Jul 2, 2022
31f14a9
[formatting] Make badness minimizer work properly.
petervdonovan Jul 4, 2022
6c269cf
[formatter] Format C federated tests.
petervdonovan Jul 4, 2022
17f750c
[formatting] Superficial patches.
petervdonovan Jul 4, 2022
0b376ba
[formatting] More superficial patches.
petervdonovan Jul 4, 2022
bf9f119
[formatting] Format more C federated tests.
petervdonovan Jul 4, 2022
331be61
[formatting] Format C tests lib dir.
petervdonovan Jul 4, 2022
2cc2eeb
[formatting] Format multiport, serialization tests.
petervdonovan Jul 4, 2022
587c3c8
[formatting] Wrap single-line file-level comments.
petervdonovan Jul 4, 2022
a73af37
[formatting] Address CI failure.
petervdonovan Jul 4, 2022
89f4b52
[formatting] Format more C tests.
petervdonovan Jul 4, 2022
a52f32f
[formatter] Fix two more non-superficial mistakes.
petervdonovan Jul 7, 2022
1652b5d
[formatting] Two spaces before same-line comments.
petervdonovan Jul 7, 2022
956bfaf
[formatting] Simple bugfix.
petervdonovan Jul 7, 2022
1d4d4bf
[formatting] Format more C tests.
petervdonovan Jul 7, 2022
e96144e
[formatting] Aesthetic adjustment.
petervdonovan Jul 7, 2022
ce6a97d
[tests] Fix formatter test.
petervdonovan Jul 7, 2022
a6bc6dc
[formatting] Associate comments to ancestors.
petervdonovan Jul 7, 2022
88e4bf3
[formatting] Format C++ tests.
petervdonovan Jul 8, 2022
03d1059
[formatting] Small patches.
petervdonovan Jul 8, 2022
1d8c2f4
[formatting] Adjust StringUtil::trimCodeBlock.
petervdonovan Jul 8, 2022
cbd6565
[formatting] Parameterize render method.
petervdonovan Jul 8, 2022
e79427a
[formatting] Format Python tests.
petervdonovan Jul 8, 2022
3075a06
[formatting] Repair regex.
petervdonovan Jul 8, 2022
c23dd5d
[formatting] Format Rust tests.
petervdonovan Jul 8, 2022
c9d197f
[formatting] Format TypeScript tests.
petervdonovan Jul 8, 2022
ad1e196
[formatting] Clean up stray whitespace.
petervdonovan Jul 8, 2022
1da7123
[formatting] Comment code; use Linux-style EOL.
petervdonovan Jul 8, 2022
0670e13
[tests] Repair test that wrongly fails LSP tests.
petervdonovan Jul 8, 2022
c0ea3b2
[formatting] Format modal models tests.
petervdonovan Jul 9, 2022
4b50994
[formatting] Handle mode transition effects.
petervdonovan Jul 9, 2022
c216ecc
[formatting] Fix incorrectly formatted C tests.
petervdonovan Jul 9, 2022
2d85ea9
[formatting] Address comment from Wednesday.
petervdonovan Jul 18, 2022
d6917e1
[formatting] Align comments.
petervdonovan Jul 18, 2022
b321f18
[formatting] Bugfix.
petervdonovan Jul 19, 2022
651e128
[formattig] Bugfix.
petervdonovan Jul 19, 2022
d038a8c
[formatting] Delete stray whitespace.
petervdonovan Jul 19, 2022
0779c68
[formatting] Patches related to recent commits.
petervdonovan Jul 19, 2022
875a1ec
[formatting] Bugfix.
petervdonovan Jul 19, 2022
0c7f5e9
[formatting] Format tests again.
petervdonovan Jul 19, 2022
542e3f2
[formatting] Do not format invalid files in editor.
petervdonovan Jul 19, 2022
5a695db
Delete stray mark.
petervdonovan Jul 19, 2022
674b006
Preserve ordering/spacing of reactor elements.
petervdonovan Jul 27, 2022
d53ed4b
Merge branch 'master' into preserve-comments
petervdonovan Jul 27, 2022
5a4f0a3
Format tests (again).
petervdonovan Jul 27, 2022
05c0ef3
Take more care with indentation.
petervdonovan Jul 27, 2022
db4a26c
Merge pull request #1249 from lf-lang/preserve-comments
petervdonovan Jul 27, 2022
0f793c3
Format C tests.
petervdonovan Jul 27, 2022
8a11e8b
[formatting] Improve test and fix found bugs.
petervdonovan Jul 28, 2022
98f8046
[formatting] Reformat some tests.
petervdonovan Jul 28, 2022
86013b3
[formatting] Try to pass test on Windows.
petervdonovan Jul 28, 2022
c7b7ae5
Reformat some modal models tests.
petervdonovan Jul 28, 2022
608fc73
Windows does not like non-ASCII character.
petervdonovan Jul 28, 2022
c96d060
Repair tests.
petervdonovan Jul 29, 2022
d28ea4e
Bugfix.
petervdonovan Jul 29, 2022
c9d4361
Hack, because the bugfix did not work.
petervdonovan Jul 29, 2022
03633c5
[formatting] Support attributes.
petervdonovan Aug 4, 2022
1b99aa0
Merge branch 'master' into pretty-printer
petervdonovan Aug 4, 2022
dc970fd
Break Rust attributes because that is expedient.
petervdonovan Aug 5, 2022
743770d
[formatting] Format newly added tests.
petervdonovan Aug 5, 2022
d951c97
Merge branch 'master' into pretty-printer
petervdonovan Aug 7, 2022
43ba732
[formatting] Make test output more user-friendly.
petervdonovan Aug 29, 2022
421d6b6
Address comments from code review.
petervdonovan Aug 31, 2022
5a79960
Update org.lflang/src/org/lflang/StringsBundle.properties
lhstrh Aug 31, 2022
4dedbe5
Move a method from FormattingUtils to StringUtil.
petervdonovan Aug 31, 2022
d1b25c0
Merge branch 'master' into pretty-printer
petervdonovan Aug 31, 2022
e6a74c6
Format Arduino tests.
petervdonovan Aug 31, 2022
a66819f
Revert changes to IntelliJ settings.
petervdonovan Sep 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/scripts/package_lfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set -euo pipefail
./gradlew clean buildLfc

# find the version number
jar_path="org.lflang.lfc/build/libs/org.lflang.lfc-*-all.jar"
version="$(ls ${jar_path} | xargs -n 1 basename | sed 's/^org.lflang.lfc-\(.*\)-all.jar$/\1/')"
jar_path="org.lflang.cli/build/libs/org.lflang.cli-*-lfc.jar"
version="$(ls ${jar_path} | xargs -n 1 basename | sed 's/^org.lflang.cli-\(.*\)-lfc.jar$/\1/')"

# use a different naming convention for nightly build artifacts
if [[ "$#" > 0 && "$1" = "nightly" ]]; then
Expand All @@ -24,7 +24,7 @@ mkdir -p "${outname}/lib/scripts"
mkdir -p "${outname}/lib/jars"

# move the jar
mv org.lflang.lfc/build/libs/org.lflang.lfc-*-all.jar "${outname}/lib/jars"
mv org.lflang.cli/build/libs/org.lflang.cli-*-lfc.jar "${outname}/lib/jars"

# copy the Bash scripts
cp -a lib/scripts "${outname}/lib/"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ jobs:
needs: cancel

# Run tests for the standalone compiler.
# TODO: Change this back to master branch once merged!
cli-tests:
uses: lf-lang/lingua-franca/.github/workflows/cli-tests.yml@master
uses: lf-lang/lingua-franca/.github/workflows/cli-tests.yml@pretty-printer
needs: cancel

# Run the C benchmark tests.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cli-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
submodules: true
- name: Prepare build environment
uses: ./.github/actions/prepare-build-env
- name: Run standalone lfc tests
- name: Run standalone cli tests
run: |
./gradlew :org.lflang.lfc:test --stacktrace
./gradlew :org.lflang.cli:test --stacktrace
- name: Test Bash scripts (Linux or macOS only)
run: |
.github/scripts/test-lfc.sh
Expand Down
16 changes: 8 additions & 8 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bin/lfc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
$base="$PSScriptRoot\.."
$java_home = "$Env:JAVA_HOME"
$java_cmd = "$java_home\bin\java.exe"
$jarpath_dev="$base\org.lflang.lfc\build\libs\org.lflang.lfc-*-all.jar"
$jarpath_release="$base\lib\jars\org.lflang.lfc-*-all.jar"
$jarpath_dev="$base\org.lflang.cli\build\libs\org.lflang.cli-*-lfc.jar"
$jarpath_release="$base\lib\jars\org.lflang.cli-*-lfc.jar"

function Test-Dev {
Test-Path "$base\org.lflang.lfc" -PathType container
Test-Path "$base\org.lflang.cli" -PathType container
}

function Get-JarPath {
Expand Down
6 changes: 3 additions & 3 deletions lib/scripts/include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ set -euo pipefail
# Paths (relative to ${base}), which is assumed to have been set.
src_pkg_name="org.lflang"
src_pkg_path="${base}/${src_pkg_name}"
lfc_src_pkg_name="${src_pkg_name}.lfc"
lfc_src_pkg_name="${src_pkg_name}.cli"
lfc_src_pkg_path="${base}/${lfc_src_pkg_name}"
lfc_jar_build_path_pattern="${lfc_src_pkg_name}/build/libs/${lfc_src_pkg_name}-*-all.jar"
lfc_jar_release_path_pattern="lib/jars/${lfc_src_pkg_name}-*-all.jar"
lfc_jar_build_path_pattern="${lfc_src_pkg_name}/build/libs/${lfc_src_pkg_name}-*-lfc.jar"
lfc_jar_release_path_pattern="lib/jars/${lfc_src_pkg_name}-*-lfc.jar"

# Enter directory silently (without printing).
pushd() {
Expand Down
116 changes: 116 additions & 0 deletions org.lflang.cli/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

sourceSets {
test {
java.srcDirs = []
kotlin.srcDirs = ['test/kotlin']
resources.srcDir('test/resources')
resources.include '**/*'
}
}

configurations {
cli_impl {
extendsFrom implementation
}
}

compileTestKotlin {
destinationDir = compileTestJava.destinationDir
kotlinOptions {
jvmTarget = kotlinJvmTarget
}
}



dependencies {
implementation project(':org.lflang')
implementation "org.eclipse.xtext:org.eclipse.xtext.ide:${xtextVersion}"
implementation "org.eclipse.xtext:org.eclipse.xtext.xbase.ide:${xtextVersion}"

testImplementation "junit:junit:${jUnitVersion}"
}

apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

task buildLfc() {
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'org.lflang.cli.Lfc'
}

task jarLfc(type: ShadowJar) {
manifest {
attributes('Main-Class': 'org.lflang.cli.Lfc')
}
configurations = [project.configurations.cli_impl]
archiveClassifier.set('lfc')
exclude 'test/*'
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
// We should use minimize() here to reduce the size of the JAR, but it causes problems
// with regard to our Kotlin classes. Since we don't use imports to load them but load
// the classes manually, minimize does not see the dependency. While we can add an exclude
// rule, this does not seem to work very well and causes problems when compiling for a
// second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285
transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){
resource = 'plugin.properties'
}
from sourceSets.main.output
}

buildLfc.finalizedBy jarLfc

task runLfc(type: JavaExec) {
// builds and runs lfc
// The working directory will be the root directory of the lingua franca project
// CLI arguments can be passed to lfc by using --args. Note that you need
// to escape cli flags which start with --.For instance --args ' --help'.
// Otherwise they're parsed as arguments to the Gradle CLI, not lfc.
description = "Build and run lfc, use --args to pass arguments"
group = "application"
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.lflang.cli.Lfc'
workingDir = '..'
}

task buildLff() {
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'org.lflang.cli.Lff'
}

task jarLff(type: ShadowJar) {
manifest {
attributes('Main-Class': 'org.lflang.cli.Lff')
}
configurations = [project.configurations.cli_impl]
archiveClassifier.set('lff')
exclude 'test/*'
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
// We should use minimize() here to reduce the size of the JAR, but it causes problems
// with regard to our Kotlin classes. Since we don't use imports to load them but load
// the classes manually, minimize does not see the dependency. While we can add an exclude
// rule, this does not seem to work very well and causes problems when compiling for a
// second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285
transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){
resource = 'plugin.properties'
}
from sourceSets.main.output
}

buildLff.finalizedBy jarLff

task runLff(type: JavaExec) {
// builds and runs lff
// The working directory will be the root directory of the lingua franca project
// CLI arguments can be passed to lff by using --args. Note that you need
// to escape cli flags which start with --.For instance --args ' --help'.
// Otherwise they're parsed as arguments to the Gradle CLI, not lfc.
description = "Build and run lff, use --args to pass arguments"
group = "application"
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.lflang.cli.Lff'
workingDir = '..'
}
138 changes: 138 additions & 0 deletions org.lflang.cli/src/org/lflang/cli/CliBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package org.lflang.cli;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Properties;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.IResourceValidator;
import org.eclipse.xtext.validation.Issue;

import org.lflang.util.FileUtil;

import com.google.inject.Inject;
import com.google.inject.Provider;

/**
* Base class for standalone CLI applications.
*
* @author {Marten Lohstroh <[email protected]>}
* @author {Christian Menard <[email protected]>}
* @author {Billy Bao <[email protected]>}
*/
public class CliBase {
/**
* Object for interpreting command line arguments.
*/
protected CommandLine cmd;
/**
* Used to collect all errors that happen during validation/generation.
*/
@Inject
protected IssueCollector issueCollector;
/**
* Used to report error messages at the end.
*/
@Inject
protected ReportingBackend reporter;
/**
* Injected resource provider.
*/
@Inject
private Provider<ResourceSet> resourceSetProvider;
/**
* Injected resource validator.
*/
@Inject
private IResourceValidator validator;

/**
* Store command-line arguments as properties, to be passed on to the runtime.
* @param passOptions Which options should be passed to the runtime.
* @return Provided arguments in cmd as properties, which should be passed to the runtime.
*/
protected Properties filterProps(List<Option> passOptions) {
Properties props = new Properties();
for (Option o : cmd.getOptions()) {
if (passOptions.contains(o)) {
String value = "";
if (o.hasArg()) {
value = o.getValue();
}
props.setProperty(o.getLongOpt(), value);
}
}
return props;
}

/**
* If some errors were collected, print them and abort execution. Otherwise, return.
*/
protected void exitIfCollectedErrors() {
if (issueCollector.getErrorsOccurred()) {
// if there are errors, don't print warnings.
List<LfIssue> errors = printErrorsIfAny();
String cause = errors.size() == 1 ? "previous error"
: errors.size() + " previous errors";
reporter.printFatalErrorAndExit("Aborting due to " + cause);
}
}

/**
* If any errors were collected, print them, then return them.
* @return A list of collected errors.
*/
// visible in tests
public List<LfIssue> printErrorsIfAny() {
List<LfIssue> errors = issueCollector.getErrors();
errors.forEach(reporter::printIssue);
return errors;
}

/**
* Validates a given resource. If issues arise during validation,
* these are recorded using the issue collector.
*
* @param resource The resource to validate.
*/
// visible in tests
public void validateResource(Resource resource) {
assert resource != null;

List<Issue> issues = this.validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);

for (Issue issue : issues) {
URI uri = issue.getUriToProblem(); // Issues may also relate to imported resources.
try {
issueCollector.accept(new LfIssue(issue.getMessage(), issue.getSeverity(),
issue.getLineNumber(), issue.getColumn(),
issue.getLineNumberEnd(), issue.getColumnEnd(),
issue.getLength(), FileUtil.toPath(uri)));
} catch (IOException e) {
reporter.printError("Unable to convert '" + uri + "' to path." + e);
}
}
}

/**
* Obtains a resource from a path. Returns null if path is not an LF file.
* @param path The path to obtain the resource from.
* @return The obtained resource. Set to null if path is not an LF file.
*/
// visible in tests
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
public Resource getResource(Path path) {
final ResourceSet set = this.resourceSetProvider.get();
try {
return set.getResource(URI.createFileURI(path.toString()), true);
} catch (RuntimeException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* generated by Xtext 2.23.0
*/

package org.lflang.lfc;
package org.lflang.cli;

import java.util.Objects;

Expand Down
Loading