diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 8e4d67c8b6..956f645fa4 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -3469,7 +3469,7 @@ class CGenerator extends GeneratorBase { // The third match is a character position within the line. // The fourth match will be the error message. static final Pattern compileErrorPattern = Pattern.compile( - "^(file:/(?.*)):(?[0-9]+):(?[0-9]+):(?.*)$" + "^(file:(?.*)):(?[0-9]+):(?[0-9]+):(?.*)$" ); /** Given a line of text from the output of a compiler, return diff --git a/org.lflang/src/org/lflang/util/FileUtil.java b/org.lflang/src/org/lflang/util/FileUtil.java index d102a9826e..63ffa003cf 100644 --- a/org.lflang/src/org/lflang/util/FileUtil.java +++ b/org.lflang/src/org/lflang/util/FileUtil.java @@ -365,7 +365,18 @@ public static IResource getIResource(Resource r) throws IOException { * Get the specified path as an Eclipse IResource or null if it is not found. */ public static IResource getIResource(Path path) { - return getIResource(path.toUri()); + IResource ret = getIResource(path.toUri()); + if (ret != null) return ret; + try { + // Handle a bug that not everyone can reproduce in which a path originating in the Ecore model is a relative + // path prefixed with a segment named "resource". + return ResourcesPlugin.getWorkspace().getRoot().findMember(org.eclipse.core.runtime.Path.fromOSString( + path.subpath(1, path.getNameCount()).toString() + )); + } catch (IllegalStateException e) { + // We are outside of Eclipse. + } + return null; } /**