diff --git a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessor.java b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessor.java index 1add7e3a..4e42ae34 100644 --- a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessor.java +++ b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessor.java @@ -192,6 +192,11 @@ protected void processDeviate(Deviate deviate, AbstractModule module, ProcessedD } break; case "not-supported": + if (targetNode.eContainer() == null) { + processedModel.addProcessorError(moduleFileName(module), deviation.getReference(), + "Deviation target node has no apparent."); + break; + } Object eGet = targetNode.eContainer().eGet(targetNode.eContainingFeature(), true); if (eGet instanceof EList) { ((EList) eGet).remove(targetNode); diff --git a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessorApp.java b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessorApp.java index 9b81ae28..88031901 100644 --- a/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessorApp.java +++ b/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/processor/YangProcessorApp.java @@ -139,7 +139,9 @@ private static List loadModuleFileAndDependencies(List m if (!extensionProvider.getFileExtensions().isEmpty()) fileExts = extensionProvider.getFileExtensions(); } - loadAdditionalFiles(implicitLookup, rs, fileExts, false); + if(implicitLookup.canRead() && implicitLookup.isDirectory()) { + loadAdditionalFiles(implicitLookup, rs, fileExts, false); + } // handle --path argument if (paths != null) { @@ -149,8 +151,9 @@ private static List loadModuleFileAndDependencies(List m System.err.println("Path " + folder.getAbsolutePath() + " doesn't exist. Skipped."); } else if (!folder.isDirectory()) { System.err.println("Path " + folder.getAbsolutePath() + " is not a directory. Skipped."); + } else { + loadAdditionalFiles(folder.getAbsoluteFile(), rs, fileExts, !noPathRecurse); } - loadAdditionalFiles(folder.getAbsoluteFile(), rs, fileExts, !noPathRecurse); } } @@ -174,14 +177,18 @@ private static List loadModuleFileAndDependencies(List m private static void loadAdditionalFiles(File parent, XtextResourceSet rs, Set fileExtensions, final boolean recursive) { - for (File file : parent.listFiles()) { + File[] files = parent.listFiles(); + if(files == null) { + return; + } + for (File file : files) { URI fileURI = URI.createFileURI(file.getAbsolutePath()); if (file.isFile() && fileExtensions.contains(fileURI.fileExtension())) { if (rs.getResource(fileURI, false) == null) { rs.getResource(fileURI, true); } } - if (recursive && file.isDirectory()) { + if (recursive && file.canRead() && file.isDirectory()) { loadAdditionalFiles(file, rs, fileExtensions, recursive); } }