Skip to content

DAPExpressionCodeFragment constructor can create a file that cannot be used for languages with dialects #1465

@SCWells72

Description

@SCWells72

The IDE's native JavaScript language has dialects, e.g.:

Image

Different dialects can be used for different files with the same extension in different project directories:

Image

Now this may seem contrived, but since IntelliJ IDEA 2026.1 includes native support for JavaScript/TypeScript/CSS but not support for the JavaScript debugger, LSP4IJ + vscode-js-debug provides a nice way to address that gap. However, if a *.js file is evaluated as being ES6 by the IDE, the resulting DAPExpressionCodeFragment can end up evaluated as being base JavaScript, and this results in the following runtime error:

java.lang.AssertionError: Language Language: ECMAScript 6 doesn't participate in view provider com.intellij.psi.SingleRootFileViewProvider{vFile=LightVirtualFile: \DAPExpressionCodeFragment.js, content=VirtualFileContent{size=0}, eventSystemEnabled=true}: [Language: JavaScript]
	at com.intellij.extapi.psi.PsiFileBase.findLanguage(PsiFileBase.java:48)
	at com.intellij.extapi.psi.PsiFileBase.<init>(PsiFileBase.java:23)
	at com.redhat.devtools.lsp4ij.dap.evaluation.DAPExpressionCodeFragment.<init>(DAPExpressionCodeFragment.java:39)
	at com.redhat.devtools.lsp4ij.dap.DAPDebuggerEditorsProvider.createExpressionCodeFragment(DAPDebuggerEditorsProvider.java:77)
	at com.redhat.devtools.lsp4ij.dap.DAPDebuggerEditorsProvider.createExpressionCodeFragment(DAPDebuggerEditorsProvider.java:70)
	at com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase.createExpressionCodeFragment(XDebuggerEditorsProviderBase.java:54)
	at com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase.createDocument(XDebuggerEditorsProviderBase.java:43)
	at com.redhat.devtools.lsp4ij.dap.DAPDebuggerEditorsProvider.createDocument(DAPDebuggerEditorsProvider.java:53)
	at com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase.createDocument(XDebuggerEditorsProviderBase.java:34)
	at com.intellij.xdebugger.impl.ui.XDebuggerEditorBase.createDocument(XDebuggerEditorBase.java:359)
	at com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox.createDocument(XDebuggerExpressionComboBox.java:168)
	at com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox.lambda$doSetText$0(XDebuggerExpressionComboBox.java:150)

The solution should be to change the way the file is created to use the original file's language instead of its file type, specifically by changing DAPExpressionCodeFragment's constructor from:

new LightVirtualFile("DAPExpressionCodeFragment." + fileType.getDefaultExtension(), fileType, text)),

to:

new LightVirtualFile("DAPExpressionCodeFragment." + fileType.getDefaultExtension(), language, text)),

Note the change from fileType to language when creating the LightVirtualFile. The main potential issue would be if in the process of debugging, files from multiple dialects are included. The alternative would be to use the common base language for the code fragment which, while a least common denominator approach, would be safe for all potential dialects that might come into play during the debugging session.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdapDebugging Adapter Protocol

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions