Skip to content

[Feature]: Auto-suggest and auto-insert missing #uses when using functions or types from unimported libraries #26

Description

@RichardJanisch

Priority

High (Important for productivity)

Component

Project Management (lifecycle, registration)

User Story

As a WinCC OA developer, I want the extension to automatically suggest adding a missing #uses statement when I use a function, class, or type that is defined in a library not yet imported in the current file — just like the WinCC OA Control Editor already does — so that I don’t have to manually look up and type the correct #uses path.

Current Behavior

When writing code that references a function or type from an external library, e.g.:

myFunction(); // defined in libs/myProject/utils.ctl

the extension either shows an “unresolved symbol” error or silently does nothing. There is no suggestion to add the corresponding #uses "libs/myProject/utils.ctl" at the top of the file. The developer has to manually know, look up, and type the correct path — which is exactly the workflow the WinCC OA Control Editor has already solved natively

Proposed Solution

When the language server detects an unresolved symbol (function, class, struct, enum, global variable) that exists in a known library file within the workspace, it should:
Quick Fix / Code Action — offer a lightbulb action Add #uses "libs/myProject/utils.ctl" directly on the unresolved symbol, just like TypeScript’s “Add import from…”.
Auto-insert — when the user confirms, insert the #uses statement at the top of the file, grouped with existing #uses entries.
Disambiguation — if the symbol exists in multiple libraries, show a list of candidates and let the user pick the correct one.
Workspace-wide index — the language server should maintain an index of all exported symbols across all .ctl and .ctlpp files in the workspace so that lookups are instant.

Acceptance Criteria

No response

Additional Context

No response

WinCC OA Version

3.21

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions