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

Deleting included template causes Exception in validation #935

Open
fbricon opened this issue Sep 14, 2023 · 2 comments
Open

Deleting included template causes Exception in validation #935

fbricon opened this issue Sep 14, 2023 · 2 comments
Labels
bug Something isn't working qute validation

Comments

@fbricon
Copy link
Collaborator

fbricon commented Sep 14, 2023

If you have a page.qute.html with an include like

{#include includes/footer}

{/}

After deleting the includes directory, saving page.qute.html shows Qute LS throwing an exception:


[Trace - 15:38:03] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/target/classes/templates/includes/footer.html",
            "type": 3
        }
    ]
}



[Trace - 15:40:30] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html"
    }
}


[Trace - 15:40:30] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
            "type": 2
        }
    ]
}


[Trace - 15:40:30] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 30,
                    "character": 10
                },
                "end": {
                    "line": 30,
                    "character": 25
                }
            },
            "severity": 1,
            "code": "TemplateNotFound",
            "source": "qute",
            "message": "Template not found: `includes/footer`."
        }
    ]
}


[Trace - 15:40:30] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/template.html",
    "diagnostics": []
}


Sep 14, 2023 3:40:30 PM com.redhat.qute.project.documents.QuteClosedTextDocument loadTemplate
SEVERE: Error while loading closed template 'file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/includes/footer.html'.
java.io.FileNotFoundException: /Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/includes/footer.html (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at com.redhat.qute.utils.IOUtils.getContent(IOUtils.java:29)
	at com.redhat.qute.project.documents.QuteClosedTextDocument.loadTemplate(QuteClosedTextDocument.java:74)
	at com.redhat.qute.project.documents.QuteClosedTextDocument.getTemplate(QuteClosedTextDocument.java:64)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:392)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:325)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:333)
	at com.redhat.qute.project.QuteProject.validateClosedTemplates(QuteProject.java:152)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:448)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:335)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:343)
	at com.redhat.qute.project.QuteProjectRegistry.didChangeWatchedFiles(QuteProjectRegistry.java:390)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.didChangeWatchedFiles(TemplateFileTextDocumentService.java:385)
	at com.redhat.qute.ls.QuteTextDocumentService.didChangeWatchedFiles(QuteTextDocumentService.java:320)
	at com.redhat.qute.ls.QuteLanguageServer.didChangeWatchedFiles(QuteLanguageServer.java:317)
	at com.redhat.qute.ls.QuteWorkspaceService.didChangeWatchedFiles(QuteWorkspaceService.java:60)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at com.redhat.qute.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:148)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Sep 14, 2023 3:40:30 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "workspace/didChangeWatchedFiles",
  "params": {
    "changes": [
      {
        "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/src/main/resources/templates/page.qute.html",
        "type": 2
      }
    ]
  }
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at com.redhat.qute.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:148)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 12 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.redhat.qute.parser.template.Template.getProjectUri()" because "template" is null
	at com.redhat.qute.services.ResolvingJavaTypeContext.<init>(ResolvingJavaTypeContext.java:50)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:395)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:325)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:333)
	at com.redhat.qute.project.QuteProject.validateClosedTemplates(QuteProject.java:152)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.triggerValidationFor(TemplateFileTextDocumentService.java:448)
	at com.redhat.qute.ls.QuteTextDocumentService.triggerValidationFor(QuteTextDocumentService.java:335)
	at com.redhat.qute.ls.QuteLanguageServer.triggerValidationFor(QuteLanguageServer.java:343)
	at com.redhat.qute.project.QuteProjectRegistry.didChangeWatchedFiles(QuteProjectRegistry.java:390)
	at com.redhat.qute.ls.template.TemplateFileTextDocumentService.didChangeWatchedFiles(TemplateFileTextDocumentService.java:385)
	at com.redhat.qute.ls.QuteTextDocumentService.didChangeWatchedFiles(QuteTextDocumentService.java:320)
	at com.redhat.qute.ls.QuteLanguageServer.didChangeWatchedFiles(QuteLanguageServer.java:317)
	at com.redhat.qute.ls.QuteWorkspaceService.didChangeWatchedFiles(QuteWorkspaceService.java:60)
	... 17 more

[Trace - 15:40:31] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///Users/fbricon/Dev/souk/code-with-qute/target/classes/templates/page.qute.html",
            "type": 2
        }
    ]
}
@fbricon fbricon added bug Something isn't working validation qute labels Sep 14, 2023
@angelozerr
Copy link
Contributor

I cannot reproduce the issue since on Windows, the 'workspace/didChangeWatchedFiles' is never send when include folder is deleted. I need to name with include.html (to follow pattern FileSystemWatcher from Qute LS ) to have ta notification but only with folder which is deleted and not with html files deleted.

I create an issue at microsoft/vscode-languageserver-node#1317 to understand more the LSP specification. @rgrunber have you some idea?

@angelozerr
Copy link
Contributor

@fbricon have you this error in vscode too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working qute validation
Projects
None yet
Development

No branches or pull requests

2 participants