From 271558449a8104ca794d66db5f946505d734e951 Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Fri, 21 Oct 2022 15:05:21 -0700 Subject: [PATCH] Fix NPE in Epoch. Recently, I fixed a bug in Windows error reporting in which the drive prefix (e.g., C:) was being excluded from the path. I suspect that the reason why this caused NPEs in Epoch is that Epoch uses special URIs that are not file system paths, even in local development. --- org.lflang/src/org/lflang/generator/CodeMap.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.lflang/src/org/lflang/generator/CodeMap.java b/org.lflang/src/org/lflang/generator/CodeMap.java index 28097ba21e..09a0533eb0 100644 --- a/org.lflang/src/org/lflang/generator/CodeMap.java +++ b/org.lflang/src/org/lflang/generator/CodeMap.java @@ -10,6 +10,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.xtext.nodemodel.INode; @@ -145,7 +146,8 @@ public static String tag(EObject astNode, String representation, boolean verbati Position lfStart = Position.fromOneBased( oneBasedLfLineAndColumn.getLine(), oneBasedLfLineAndColumn.getColumn() ); - final Path lfPath = Path.of(bestEffortGetEResource(astNode).getURI().toFileString()); + final URI uri = bestEffortGetEResource(astNode).getURI(); + final Path lfPath = Path.of(uri.isFile() ? uri.toFileString() : uri.path()); if (verbatim) lfStart = lfStart.plus(node.getText().substring(0, indexOf(node.getText(), representation))); return new Correspondence( lfPath,