mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 08:15:59 +00:00
Extended Language to distinguish between programming and non-programming languages
This commit is contained in:
1 parent
d7852341f7
commit
7df64bcee0
1 file changed
+9
-2
@@ -162,10 +162,11 @@ class Language(str, Enum):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def iter_all(cls, include_experimental: bool = False) -> Iterable[Self]:
|
||||
def iter_all(cls, include_experimental: bool = False, include_non_programming_languages: bool = True) -> Iterable[Self]:
|
||||
for lang in cls:
|
||||
if include_experimental or not lang.is_experimental():
|
||||
yield lang
|
||||
if include_non_programming_languages or lang.is_programming_language():
|
||||
yield lang
|
||||
|
||||
def is_experimental(self) -> bool:
|
||||
"""
|
||||
@@ -192,6 +193,12 @@ class Language(str, Enum):
|
||||
self.SOLIDITY,
|
||||
}
|
||||
|
||||
def is_programming_language(self) -> bool:
|
||||
"""Whether the supported language should be considered a programming language.
|
||||
Solidlsp supports languages like markdown or json, this method returns False for them.
|
||||
"""
|
||||
return self not in frozenset((self.MARKDOWN, self.JSON, self.TOML, self.YAML, self.ANSIBLE))
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.value
|
||||
|
||||
|
||||
Reference in new issue
Block a user