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

[Twig] Inconsistent constant() autocompletion #2249

Open
2 of 3 tasks
klkvsk opened this issue Nov 23, 2023 · 0 comments
Open
2 of 3 tasks

[Twig] Inconsistent constant() autocompletion #2249

klkvsk opened this issue Nov 23, 2023 · 0 comments

Comments

@klkvsk
Copy link

klkvsk commented Nov 23, 2023

There is a number of previous issues regarding this (#327, #639, #1167, #2049, #872), but here are summarized results:

autocompletion = visible in dropdown, completed on ctrl+space
declaration = visible on ctrl+hover, goes to declaration on ctrl+click or ctrl+B

{% set c1 = constant('ROOT_CONST') %} -- ok, full autocompletion + declaration
{% set c2 = constant('RootEnum::FOO') %} -- nothing
{% set c3 = constant('RootClass::FOO') %} -- declaration, autocompletion only after ::
{% set c4 = constant('BugDemo\\NAMESPACED_CONST') %} -- nothing
{% set c5 = constant('\\BugDemo\\NAMESPACED_CONST') %} -- nothing
{% set c6 = constant('BugDemo\\NamespacedEnum::FOO') %} -- nothing
{% set c7 = constant('\\BugDemo\\NamespacedEnum::FOO') %} -- nothing
{% set c8 = constant('BugDemo\\NamespacedClass::FOO') %} -- declaration, autocompletion only after ::
{% set c9 = constant('\\BugDemo\\NamespacedClass::FOO') %} -- declaration, autocompletion only after ::

{# @var rootClass RootClass #}
{% set c10 = constant('FOO', rootClass) %} -- nothing
{# @var namespacedClass BugDemo\NamespacedClass #}
{% set c11 = constant('FOO', namespacedClass) %} -- nothing
namespace {
    const ROOT_CONST = 'const';
    class RootClass {
        const FOO = 'in class';
    }
    enum RootEnum: string {
        case FOO = 'enum case';
    }
}

namespace BugDemo {
    const NAMESPACED_CONST = 'const';
    class NamespacedClass {
        const FOO = 'in class';
    }
    enum NamespacedEnum: string {
        case FOO = 'enum case';
    }
}

Here's what needs to be done

  • add autocompletion for namespace/fqcn before :: in constant()
  • treat enums as classes to inherit same autocompletion/declaration behaviour
  • add support for constant(name, object) if object's type is known
Haehnchen added a commit that referenced this issue Apr 7, 2024
#2249 #2049 rebuild Twig constant completion and navigation and supporting enums
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

No branches or pull requests

1 participant