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

Document highlight for symbols (field names, model names, external ids,...) #39

Open
trinhanhngoc opened this issue Nov 3, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@trinhanhngoc
Copy link
Member

trinhanhngoc commented Nov 3, 2023

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentHighlight

@trinhanhngoc trinhanhngoc added the enhancement New feature or request label Nov 3, 2023
@gustitammam
Copy link

Could this issue be related to undefined methods being referenced in field attributes, such as a compute method that hasn't been defined yet?

Currently, in my VSCode, there's no warning or highlight indicator for such cases, making it difficult to identify undefined methods being referenced. When can we expect this issue to be resolved?

@trinhanhngoc
Copy link
Member Author

@gustitammam ,

No, the document highlight feature is about highlighting all references to the symbol under the cursor. Yours is another problem. Can you take a screenshot to demonstrate the problem?

@gustitammam
Copy link

Thank you for the clarification! I was searching for an existing issue that might match the problem I’m facing because I want to avoid creating a duplicate issue. I thought this issue might be related, so I wanted to confirm.

The expected behavior is that if a method referenced in the compute attribute of a field is not defined or doesn't exist, there should be a red highlight or a similar warning—like the functionality available in PyCharm.

PyCharm:
image

Currently, no such indicator appears in VSCode.

VSCode:
image

@trinhanhngoc
Copy link
Member Author

@gustitammam ,

I just tested, everything is working fine. Are you sure the Odoo IDE extension is enabled?

image

@gustitammam
Copy link

That's strange because on my side it doesn't seem to work as expected.

Do you think I should open a separate issue for this?

I've changed the code in the Odoo source to match yours, but I still don't see any warning or indicator when an invalid method is referenced in the compute attribute of a field. I've attached a screenshot to demonstrate this.

For additional context, here's my setup:

📌 VSCode version:

Version: 1.96.2
Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f
Date: 2024-12-19T10:22:47.216Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.12.5-200.fc41.x86_64

📌 Extension version:

Identifier: trinhanhngoc.vscode-odoo
Version: 0.36.4

📌 Installed inside a devcontainer

📌 Using a multi-root workspace (configuration attached)

{
  "folders": [
    {
      "path": "."
    },
    {
      "path": "/oo"
    }
  ],
  "settings": {
    "remote.autoForwardPorts": false,
    "remote.restoreForwardedPorts": false,
    "files.exclude": {
      "**/.git": true,
      "**/.svn": true,
      "**/.hg": true,
      "**/CVS": true,
      "**/.DS_Store": true,
      "**/Thumbs.db": true,
      "**/__pycache__": true,
      "**/.idea": true
    },
    "search.exclude": {
      "workdir/data/**/*": true
    },
    "git.repositoryScanMaxDepth": 3,
    "git.allowForcePush": true,
    "python.defaultInterpreterPath": "/usr/local/bin/python",
    "python.createEnvironment.trigger": "off",
    "python.languageServer": "None",
    "python.analysis.stubPath": "",
    "autopep8.args": [
      "--max-line-length=119"
    ],
    "xml.format.maxLineWidth": 120,
    "xml.format.spaceBeforeEmptyCloseTag": false,
    "editor.rulers": [
      {
        "column": 120
      }
    ],
    "[python]": {
      "editor.defaultFormatter": "ms-python.autopep8",
      "editor.rulers": [
        {
          "column": 79
        },
        {
          "column": 119
        }
      ]
    },
    "debug.showInStatusBar": "always"
  }
}

image

The extension log also confirms that the file is being analyzed, so it seems the extension is functioning correctly. Let me know if there's anything else you'd like me to check.

@trinhanhngoc
Copy link
Member Author

@gustitammam ,

Are other features of the Odoo IDE extension still working (code completion for method names in compute='...', model names in env['...'],...)?

@gustitammam
Copy link

@gustitammam ,

Are other features of the Odoo IDE extension still working (code completion for method names in compute='...', model names in env['...'],...)?

Yes, everything else is working perfectly.

Code completion for method names:
This is working in both the Odoo source code and custom source code:

image

Code completion for model names:
This is also working in both the Odoo source code and custom source code:

image

Additionally, 'Go to Definition' is functioning correctly as well. Everything else seems to be working as expected.

@trinhanhngoc
Copy link
Member Author

@gustitammam ,

What about your Type Checking Mode setting?

image

@gustitammam
Copy link

Apologies for the late reply. The Type Checking Mode setting in my VSCode was set to Off.

I hadn't noticed this setting before, and it seems the default is Off. After changing it to "basic", the feature is now working as expected. Thank you for pointing that out!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants