eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
663 stars 61 forks source link

Cancellation: More Problems #1567

Closed cdietrich closed 4 hours ago

cdietrich commented 2 days ago

From https://github.com/eclipse-langium/langium/discussions/1562 and https://github.com/eclipse-langium/langium/pull/1566

Additionally to the missing notifications to the client we see more problems with cancellation respectively the recovery from it.

To be investigated: at end of iterative deletes, not all delete validations seems to be have sent to the client

cdietrich commented 2 days ago

workaround ideas:

override invalidateDocument(uri: URI): LangiumDocument | undefined {
    const result = super.invalidateDocument(uri)
    if (result !== undefined) {
      for (const node of AstUtils.streamAst(result.parseResult.value)) {
        AstUtils.streamReferences(node).forEach(refInfo => {
          const ref = refInfo.reference as DefaultReference
          if (ref._ref !== undefined) {
            delete ref._ref
            delete ref._nodeDescription
          }
        })
      }
    }
    return result
  }
protected override shouldRelink(document: LangiumDocument, changedUris: Set<string>): boolean {
    let result = super.shouldRelink(document, changedUris)

    if (!result) {
      for (const node of AstUtils.streamAst(document.parseResult.value)) {
        AstUtils.streamReferences(node).forEach(refInfo => {
          const ref = refInfo.reference as DefaultReference
          if (ref._ref !== undefined) {
            if (isLinkingError(ref._ref)) {
              result = true
            }
          }
        })
      }
    }
    return result
  }
override unlink(document: LangiumDocument): void {
    super.unlink(document)
    for (const node of AstUtils.streamAst(document.parseResult.value)) {
      AstUtils.streamReferences(node).forEach(refInfo => {
        const ref = refInfo.reference as DefaultReference
        if (ref._ref !== undefined) {
          delete ref._ref
          delete ref._nodeDescription
        }
      })
    }
  }
cdietrich commented 2 days ago

here is my attempts to reproduce the delete problem

https://github.com/eclipse-langium/langium/compare/main...cdietrich:langium:cd-repro2

but with longer timeouts it works....

cdietrich commented 1 day ago

it looks like the delete problem might be a client side one. i dont always see all deletes arrive at the server.

cdietrich commented 1 day ago

created https://github.com/microsoft/vscode-languageserver-node/issues/1503 for the client side clarification

msujew commented 4 hours ago

Has been fixed with https://github.com/eclipse-langium/langium/pull/1566. Release is available at langium@3.1.2.