Skip to content

feat: add TCodeToolManager Helper #150

Open
xuming wants to merge 1 commit intogenericptr:trunkfrom
coolchyni:feat/codetoolhelper
Open

feat: add TCodeToolManager Helper #150
xuming wants to merge 1 commit intogenericptr:trunkfrom
coolchyni:feat/codetoolhelper

Conversation

@xuming
Copy link
Contributor

@xuming xuming commented Jan 30, 2026

Add TCodeToolManagerHelper with methods for reporting defines, directives, and unit info
This class provides some methods to print relevant information, which can help with debugging.

Additionally, although Pascal Language Server has already implemented many commonly used features, in practical use it is still not as stable as Lazarus. This is reflected in the frequent occurrence of errors such as “unit not found” or “Identifier not found.” Do we have the ability to make this component as stable as Lazarus?

@genericptr
Copy link
Owner

I don't know if there's anything we can do so does it really matter if we can dump output? What are looking for even?

I have constant problems with CodeTools. Look at this. When I save (maybe from the check unused regions?) it shows errors from text within a comment. I find strange this like this all the time. Most annoying are VSCode files where the symbol list doesn't show and I think that's because CodeTools is messing up.

Screenshot 2026-01-30 at 12 47 22 PM

@genericptr
Copy link
Owner

I just filed that bug at #151 but if you find reproducible CodeTools errors can you file those and we can see if they can be fixed in CodeTools.

You may just mean during typing and legit identifiers don't exist and thus CodeTools fail at that point. I think that's just how it works and nothing can be done.

@mvancanneyt
Copy link
Collaborator

Define "stable" ?

I doubt it will ever be possible to get it as correct as Lazarus:
VS Code simply does not provide enough context for Lazarus codetools to work with.

I have had many discussions with the Lazarus devs, and a 'workspace' directory (VS Code terminology) is not compatible with the Lazarus notion of project and packages. In the best case, a workspace corresponds to a project group.
The codetools need a project file to work correctly. There are some ideas to auto-generate project group and project files but they have not yet been implemented.

This does not mean codetools has no bugs, of course: Mattias Gaertner fixed some bugs this week.

@genericptr
Copy link
Owner

Define "stable" ?

I doubt it will ever be possible to get it as correct as Lazarus: VS Code simply does not provide enough context for Lazarus codetools to work with.

what is it missing exactly? We can provide all the paths it needs to find units and we provide the full text of the unit so isn't everything there? Simon needs to report the bugs he's seeing so we can look in to them.

@mvancanneyt
Copy link
Collaborator

A project file is more than just a set of paths. For simple cases this is indeed sufficient.

But for complex setups with different paths/dependencies per OS/CPU, it is not sufficient.

For larger projects, if you have one or more testsuites in one of the subdirectories, then search paths will differ for these projects, and you may end up at wildly different places when ctrl-clicking on an identifier.

At first I thought like you, but Mattias quickly set me straight...

@xuming
Copy link
Contributor Author

xuming commented Feb 3, 2026

Even in some small projects, similar errors sometimes occur. I’ve always suspected that I might not be providing enough information to CodeTools, but I don’t know what else needs to be provided.

So I provided this helper class to compare with Lazarus, but I didn’t find anything particularly significant.

@mvancanneyt
Copy link
Collaborator

Maybe the lazarus source editor itself already filters out some cases before calling the code tools.
The syntax highlighting (which is done independently of codetools in Lazarus) already provides some context, so that is possible.

@genericptr
Copy link
Owner

The pattern I see often is code tools breaks and gives random missing identifiers or strange errors that doesn't reflect at all what's in the document. Restarting the server always fixes the problem. Not sure if it's the editor/server integration or a bug in the server we messed up the document content and confused code tools with bad input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants