From 20fd02917153675e53b0ddf1cfbb9e49a8b09872 Mon Sep 17 00:00:00 2001 From: mmews Date: Fri, 5 Jan 2024 14:12:59 +0100 Subject: [PATCH] deal with failures during resource loading --- .../src/org/eclipse/n4js/resource/N4JSResource.java | 5 +++++ .../src/org/eclipse/n4js/resource/XtextResourceLocator.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java index 33cca2ff63..a5de481604 100644 --- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java +++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java @@ -407,6 +407,11 @@ public boolean isReconciled() { return module != null && module.isReconciled(); } + /** Returns true iff an error occurred while this resource was loaded. */ + public boolean isLoadedWithFailure() { + return this.isLoadedWithFailure; + } + @Override public synchronized EList getContents() { if (!removingAdapters) { diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/XtextResourceLocator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/XtextResourceLocator.java index 3d9bfd3b6b..76e9e71ffe 100644 --- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/XtextResourceLocator.java +++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/XtextResourceLocator.java @@ -77,6 +77,9 @@ public Resource getResource(URI uri, boolean loadOnDemand) { demandLoadHelper(resource); if (resource instanceof N4JSResource && ((N4JSResource) resource).isLoadedWithFailure()) { + if (resource.getResourceSet() != null) { + resource.getResourceSet().getResources().remove(resource); + } return null; }