tomlin7 / biscuit

Aesthetic, lightweight code editor with extension support
https://tomlin7.github.io/biscuit
MIT License
189 stars 27 forks source link

ClangD not recognizing opened files after `didChange` notifications #362

Closed tomlin7 closed 4 months ago

tomlin7 commented 4 months ago

Bug

After few requests, clangd shows

RESPONSEERROR message_id=8 code=-32602 message='trying to get AST for non-added document' data=None

clangd logs

I[14:53:30.029] clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
I[14:53:30.029] Features: windows+grpc
I[14:53:30.029] PID: 4828
I[14:53:30.029] Working directory: D:\bologna
I[14:53:30.029] argv[0]: clangd.exe
I[14:53:30.036] Starting LSP over stdin/stdout
I[14:53:30.036] <-- initialize(0)
I[14:53:30.048] --> reply:initialize(0) 12 ms
INITIALIZED capabilities={'astProvider': True, 'callHierarchyProvider': True, 'clangdInlayHintsProvider': True, 'codeActionProvider': True, 'compilationDatabase': {'automaticReload': True}, 'completionProvider': {'resolveProvider': False, 'triggerCharacters': ['.', '<', '>', ':', '"', '/', '*']}, 'declarationProvider': True, 'definitionProvider': True, 'documentFormattingProvider': True, 'documentHighlightProvider': True, 'documentLinkProvider': {'resolveProvider': False}, 'documentOnTypeFormattingProvider': {'firstTriggerCharacter': '\n', 'moreTriggerCharacter': []}, 'documentRangeFormattingProvider': True, 'documentSymbolProvider': True, 'executeCommandProvider': {'commands': ['clangd.applyFix', 'clangd.applyTweak']}, 'foldingRangeProvider': True, 'hoverProvider': True, 'implementationProvider': True, 'inactiveRegionsProvider': True, 'inlayHintProvider': True, 'memoryUsageProvider': True, 'referencesProvider': True, 'renameProvider': True, 'selectionRangeProvider': True, 'semanticTokensProvider': {'full': {'delta': True}, 'legend': {'tokenModifiers': ['declaration', 'definition', 'deprecated', 'deduced', 'readonly', 'static', 'abstract', 'virtual', 'dependentName', 'defaultLibrary', 'usedAsMutableReference', 'usedAsMutablePointer', 'constructorOrDestructor', 'userDefined', 'functionScope', 'classScope', 'fileScope', 'globalScope'], 'tokenTypes': ['variable', 'variable', 'parameter', 'function', 'method', 'function', 'property', 'variable', 'class', 'interface', 'enum', 'enumMember', 'type', 'type', 'unknown', 'namespace', 'typeParameter', 'concept', 'type', 'macro', 'modifier', 'operator', 'bracket', 'label', 'comment']}, 'range': False}, 'signatureHelpProvider': {'triggerCharacters': ['(', ')', '{', '}', '<', '>', ',']}, 'standardTypeHierarchyProvider': True, 'textDocumentSync': {'change': 2, 'openClose': True, 'save': True}, 'typeDefinitionProvider': True, 'typeHierarchyProvider': True, 'workspaceSymbolProvider': True}

I[14:53:30.195] <-- initialized
I[14:53:30.195] <-- textDocument/didOpen
I[14:53:30.197] Failed to find compilation database for D:\bologna\bologna\test.c
I[14:53:30.197] ASTWorker building file D:\bologna\bologna\test.c version 0 with command clangd fallback
[D:\bologna\bologna]
"C:\\Users\\BIT\\scoop\\apps\\mingw\\13.2.0-rt_v11-rev1\\bin\\clang" "-resource-dir=C:\\Users\\BIT\\Documents\\clangd_18.1.3\\lib\\clang\\18" -- "D:\\bologna\\bologna\\test.c"
I[14:53:30.350] <-- textDocument/documentSymbol(1)
I[14:53:30.435] Built preamble of size 2650888 for file D:\bologna\bologna\test.c version 0 in 0.22 seconds
I[14:53:30.437] Indexing c17 standard library in the context of D:\bologna\bologna\test.c
I[14:53:30.477] --> textDocument/publishDiagnostics
I[14:53:30.478] --> reply:textDocument/documentSymbol(1) 127 ms
PUBLISHDIAGNOSTICS uri='file:///D:/bologna/bologna/test.c' version=0 diagnostics=[Diagnostic(range=Range(start=Position(line=0, character=8), end=Position(line=0, character=9)), severity=<DiagnosticSeverity.ERROR: 1>, code='pp_hash_error', codeDescription=None, source='clang', message='In included file: Error in C++ Standard Library usage', tags=None, relatedInformation=[DiagnosticRelatedInformation(location=Location(uri='file:///C:/Program%20Files/Microsoft%20Visual%20Studio/2022/Community/VC/Tools/MSVC/14.38.33130/include/yvals_core.h', range=Range(start=Position(line=27, character=1), end=Position(line=27, character=6))), message='Error occurred here')], data=None), Diagnostic(range=Range(start=Position(line=0, character=0), end=Position(line=0, character=0)), severity=<DiagnosticSeverity.ERROR: 1>, code='fatal_too_many_errors', codeDescription=None, source='clang', message='Too many errors emitted, stopping now', tags=None, relatedInformation=[], data=None), Diagnostic(range=Range(start=Position(line=2, character=0), end=Position(line=2, character=5)), severity=<DiagnosticSeverity.ERROR: 1>, code='unknown_typename', codeDescription=None, source='clang', message="Unknown type name 'using'", tags=None, relatedInformation=[], data=None), Diagnostic(range=Range(start=Position(line=2, character=16), end=Position(line=2, character=19)), severity=<DiagnosticSeverity.ERROR: 1>, code='invalid_token_after_toplevel_declarator', codeDescription=None, source='clang', message="Expected ';' after top level declarator (fix available)", tags=None, relatedInformation=[], data=None), Diagnostic(range=Range(start=Position(line=0, character=0), end=Position(line=0, character=18)), severity=<DiagnosticSeverity.WARNING: 2>, code='unused-includes', codeDescription=CodeDescription(href='https://clangd.llvm.org/guides/include-cleaner'), source='clangd', message='Included header iostream is not used directly (fix available)', tags=[<DiagnosticTag.UNNECESSARY: 1>], relatedInformation=[], data=None)]

MDOCUMENTSYMBOLS message_id=1 result=[DocumentSymbol(name='namespace', detail='int', kind=<SymbolKind.VARIABLE: 13>, tags=None, deprecated=None, range=Range(start=Position(line=2, character=0), end=Position(line=2, character=15)), selectionRange=Range(start=Position(line=2, character=6), end=Position(line=2, character=15)), children=None), DocumentSymbol(name='main', detail='int ()', kind=<SymbolKind.FUNCTION: 12>, tags=None, deprecated=None, range=Range(start=Position(line=4, character=0), end=Position(line=7, character=1)), selectionRange=Range(start=Position(line=4, character=4), end=Position(line=4, character=8)), children=None)]

I[14:53:30.662] Indexed c17 standard library: 2718 symbols, 1090 filtered
I[14:53:38.743] <-- textDocument/hover(2)
I[14:53:38.746] --> reply:textDocument/hover(2) 2 ms
HOVER message_id=2 contents=MarkupContent(kind=<MarkupKind.MARKDOWN: 'markdown'>, value='### variable `namespace`  \n\n---\nType: `int`  \n\n---\n```cpp\npublic: int namespace\n```') range=Range(start=Position(line=2, character=6), end=Position(line=2, character=15))

I[14:53:39.226] <-- textDocument/hover(3)
I[14:53:39.228] --> reply:textDocument/hover(3) 1 ms
HOVER message_id=3 contents=MarkupContent(kind=<MarkupKind.MARKDOWN: 'markdown'>, value='### variable `namespace`  \n\n---\nType: `int`  \n\n---\n```cpp\npublic: int namespace\n```') range=Range(start=Position(line=2, character=0), end=Position(line=2, character=5))

I[14:53:40.848] <-- textDocument/hover(4)
I[14:53:40.849] --> reply:textDocument/hover(4) 0 ms
HOVER message_id=4 contents=[] range=None

I[14:53:41.711] <-- textDocument/hover(5)
I[14:53:41.711] --> reply:textDocument/hover(5) 0 ms
HOVER message_id=5 contents=MarkupContent(kind=<MarkupKind.MARKDOWN: 'markdown'>, value='### `iostream`  \n\n---\n```\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\iostream\n```') range=None

I[14:53:43.371] <-- textDocument/hover(6)
I[14:53:43.371] --> reply:textDocument/hover(6) 0 ms
HOVER message_id=6 contents=[] range=None

I[14:53:44.151] <-- textDocument/documentSymbol(7)
I[14:53:44.152] --> reply:textDocument/documentSymbol(7) 1 ms
MDOCUMENTSYMBOLS message_id=7 result=[DocumentSymbol(name='namespace', detail='int', kind=<SymbolKind.VARIABLE: 13>, tags=None, deprecated=None, range=Range(start=Position(line=2, character=0), end=Position(line=2, character=15)), selectionRange=Range(start=Position(line=2, character=6), end=Position(line=2, character=15)), children=None), DocumentSymbol(name='main', detail='int ()', kind=<SymbolKind.FUNCTION: 12>, tags=None, deprecated=None, range=Range(start=Position(line=4, character=0), end=Position(line=7, character=1)), selectionRange=Range(start=Position(line=4, character=4), end=Position(line=4, character=8)), children=None)]

I[14:53:45.041] <-- textDocument/documentSymbol(8)
I[14:53:45.042] --> reply:textDocument/documentSymbol(8) 0 ms
MDOCUMENTSYMBOLS message_id=8 result=[DocumentSymbol(name='namespace', detail='int', kind=<SymbolKind.VARIABLE: 13>, tags=None, deprecated=None, range=Range(start=Position(line=2, character=0), end=Position(line=2, character=15)), selectionRange=Range(start=Position(line=2, character=6), end=Position(line=2, character=15)), children=None), DocumentSymbol(name='main', detail='int ()', kind=<SymbolKind.FUNCTION: 12>, tags=None, deprecated=None, range=Range(start=Position(line=4, character=0), end=Position(line=7, character=1)), selectionRange=Range(start=Position(line=4, character=4), end=Position(line=4, character=8)), children=None)]

I[14:53:45.603] <-- textDocument/didChange
E[14:53:45.604] Failed to update D:\bologna\bologna\test.c: Line value is out of range (10)  
I[14:53:45.604] <-- textDocument/didChange
I[14:53:45.604] Trying to incrementally change non-added document: D:\bologna\bologna\test.c 
I[14:53:45.604] <-- textDocument/documentSymbol(9)
I[14:53:45.604] --> reply:textDocument/documentSymbol(9) 0 ms, error: -32602: trying to get AST for non-added document
I[14:53:45.604] <-- textDocument/documentSymbol(10)
I[14:53:45.604] --> reply:textDocument/documentSymbol(10) 0 ms, error: -32602: trying to get AST for non-added document
RESPONSEERROR message_id=9 code=-32602 message='trying to get AST for non-added document' data=None

message_id=9 code=-32602 message='trying to get AST for non-added document' data=None        
RESPONSEERROR message_id=10 code=-32602 message='trying to get AST for non-added document' data=None

message_id=10 code=-32602 message='trying to get AST for non-added document' data=None       
I[14:53:46.665] <-- textDocument/didChange
I[14:53:46.665] Trying to incrementally change non-added document: D:\bologna\bologna\test.c 
I[14:53:46.721] <-- textDocument/documentSymbol(11)
I[14:53:46.721] --> reply:textDocument/documentSymbol(11) 0 ms, error: -32602: trying to get AST for non-added document
RESPONSEERROR message_id=11 code=-32602 message='trying to get AST for non-added document' data=None

message_id=11 code=-32602 message='trying to get AST for non-added document' data=None       
I[14:53:49.066] <-- textDocument/didChange
I[14:53:49.066] Trying to incrementally change non-added document: D:\bologna\bologna\test.c 
I[14:53:49.066] <-- textDocument/documentSymbol(12)
I[14:53:49.066] --> reply:textDocument/documentSymbol(12) 0 ms, error: -32602: trying to get AST for non-added document
RESPONSEERROR message_id=12 code=-32602 message='trying to get AST for non-added document' data=None

message_id=12 code=-32602 message='trying to get AST for non-added document' data=None       
I[14:53:49.440] <-- textDocument/didChange
I[14:53:49.440] Trying to incrementally change non-added document: D:\bologna\bologna\test.c 
I[14:53:49.440] <-- textDocument/documentSymbol(13)
I[14:53:49.440] --> reply:textDocument/documentSymbol(13) 0 ms, error: -32602: trying to get AST for non-added document
RESPONSEERROR message_id=13 code=-32602 message='trying to get AST for non-added document' data=None

message_id=13 code=-32602 message='trying to get AST for non-added document' data=None       

System Information