MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / matches

Method matches

src/completion/context/class_completion.rs:81–96  ·  view source on GitHub ↗

Check whether a `ClassInfo` matches this context.

(&self, cls: &ClassInfo)

Source from the content-addressed store, hash-verified

79impl ClassNameContext {
80 /// Check whether a `ClassInfo` matches this context.
81 pub(crate) fn matches(&self, cls: &ClassInfo) -> bool {
82 match self {
83 Self::Any => true,
84 Self::New => cls.kind == ClassLikeKind::Class && !cls.is_abstract,
85 Self::ExtendsClass => cls.kind == ClassLikeKind::Class && !cls.is_final,
86 Self::ExtendsInterface => cls.kind == ClassLikeKind::Interface,
87 Self::Implements => cls.kind == ClassLikeKind::Interface,
88 Self::TraitUse => cls.kind == ClassLikeKind::Trait,
89 Self::Instanceof | Self::TypeHint => cls.kind != ClassLikeKind::Trait,
90 Self::UseImport => true,
91 Self::UseFunction | Self::UseConst | Self::NamespaceDeclaration => false,
92 Self::Attribute(target) => {
93 cls.attribute_targets != 0 && (cls.attribute_targets & target) != 0
94 }
95 }
96 }
97
98 /// Check whether a class-like matches this context given only kind
99 /// flags (used by tests for `detect_stub_class_kind`).

Calls

no outgoing calls