yoctoproject / vscode-bitbake

Bitbake language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake
Other
41 stars 10 forks source link

Fix: pythonDatastoreVariableSymbols sometimes misses variables #283

Closed idillon-sfl closed 1 month ago

idillon-sfl commented 1 month ago

I noticed pythonDatastoreVariableSymbols would give inconsistent results when the document is edited.

Steps to reproduce:

  1. Create the following document:
    python() {
    d.getVar('DESCRIPTION')
    }
  2. Restart VS Code (just making sure to have a clean state) and open the document.
  3. Try to hover DESCRIPTION. It works.
  4. Try to rename DESCRIPTION. It works.
  5. Change the quotes:
    python() {
    d.getVar("DESCRIPTION")
    }
  6. Try to hover DESCRIPTION. It still works.
  7. Try to rename DESCRIPTION: The element can't be renamed (???)
  8. Save the document and restart VS Code.
  9. Try to rename DESCRIPTION: It works.

Not sure why this happens (bitBakeNodeAtPoint gives a different result after the edition), but here's a fix.

Problem has been understood: bitBakeNodeAtPoint uses the tree registered in uriToAnalyzedDocument. However, getSymbolsFromBitBakeTree is called before the new tree is registered. Therefore, if bitBakeNodeAtPoint is called whithin getSymbolsFromBitBakeTree, it will give a result from the previous tree. For that reason, it must be avoided.