robotcode-analyze 2.9.0.dev186__py3-none-any.whl → 2.9.0.dev214__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- __version__ = "2.9.0-dev.186"
1
+ __version__ = "2.9.0-dev.214"
@@ -13,6 +13,7 @@ from robotcode.robot.config.model import RobotBaseProfile
13
13
  from robotcode.robot.diagnostics.workspace_config import WorkspaceAnalysisConfig
14
14
 
15
15
  from .diagnostics_context import DiagnosticHandlers, DiagnosticsContext
16
+ from .markdown_language_provider import MarkdownLanguageProvider
16
17
  from .robot_framework_language_provider import RobotFrameworkLanguageProvider
17
18
 
18
19
 
@@ -50,8 +51,11 @@ class CodeAnalyzer(DiagnosticsContext):
50
51
 
51
52
  self._dispatcher = DiagnosticHandlers()
52
53
 
53
- self.language_handler_types = {RobotFrameworkLanguageProvider}
54
- self.workspace.documents.languages.extend(RobotFrameworkLanguageProvider.get_language_definitions())
54
+ self.language_handler_types = [RobotFrameworkLanguageProvider, MarkdownLanguageProvider]
55
+ for handler_type in self.language_handler_types:
56
+ self.workspace.documents.languages.extend(
57
+ handler_type.get_language_definitions(robot_profile, self.root_folder)
58
+ )
55
59
  self.language_handlers = [cls(self) for cls in self.language_handler_types]
56
60
  if app.config.verbose:
57
61
  app.verbose(
@@ -3,8 +3,11 @@ from pathlib import Path
3
3
  from typing import Callable, Iterable, List, Optional
4
4
 
5
5
  from robotcode.analyze.code.diagnostics_context import DiagnosticsContext
6
+ from robotcode.core.ignore_spec import DEFAULT_SPEC_RULES, GIT_IGNORE_FILE, ROBOT_IGNORE_FILE, IgnoreSpec, iter_files
6
7
  from robotcode.core.language import LanguageDefinition
7
8
  from robotcode.core.workspace import WorkspaceFolder
9
+ from robotcode.robot.config.model import RobotBaseProfile
10
+ from robotcode.robot.diagnostics.workspace_config import WorkspaceConfig
8
11
 
9
12
 
10
13
  class LanguageProvider(ABC):
@@ -15,7 +18,27 @@ class LanguageProvider(ABC):
15
18
 
16
19
  @classmethod
17
20
  @abstractmethod
18
- def get_language_definitions(cls) -> List[LanguageDefinition]: ...
21
+ def get_language_definitions(cls, profile: RobotBaseProfile, root: Path) -> List[LanguageDefinition]: ...
19
22
 
20
23
  @abstractmethod
21
24
  def collect_workspace_folder_files(self, folder: WorkspaceFolder) -> Iterable[Path]: ...
25
+
26
+ def iter_workspace_folder_files(self, folder: WorkspaceFolder) -> Iterable[Path]:
27
+ """The files of a workspace folder, without the excluded and ignored ones."""
28
+ config = self.diagnostics_context.workspace.get_configuration(WorkspaceConfig, folder.uri)
29
+
30
+ exclude_patterns = [
31
+ *self.diagnostics_context.analysis_config.exclude_patterns,
32
+ *(config.exclude_patterns or []),
33
+ ]
34
+ return iter_files(
35
+ folder.uri.to_path(),
36
+ ignore_files=[ROBOT_IGNORE_FILE, GIT_IGNORE_FILE],
37
+ include_hidden=False,
38
+ parent_spec=IgnoreSpec.from_list(
39
+ [*DEFAULT_SPEC_RULES, *exclude_patterns],
40
+ folder.uri.to_path(),
41
+ ),
42
+ verbose_callback=self.verbose_callback,
43
+ verbose_trace=False,
44
+ )
@@ -0,0 +1,28 @@
1
+ from pathlib import Path
2
+ from typing import Iterable, List
3
+
4
+ from robotcode.core.language import LanguageDefinition
5
+ from robotcode.core.workspace import WorkspaceFolder
6
+ from robotcode.robot.config.model import RobotBaseProfile
7
+ from robotcode.robot.document_formats import markdown_extensions
8
+ from robotcode.robot.language_definitions import MARKDOWN_LANGUAGE_ID, markdown_language_definition
9
+
10
+ from .language_provider import LanguageProvider
11
+
12
+
13
+ class MarkdownLanguageProvider(LanguageProvider):
14
+ """The Markdown files Robot Framework parses; the Robot Framework provider analyses them like `.robot` files."""
15
+
16
+ @classmethod
17
+ def get_language_definitions(cls, profile: RobotBaseProfile, root: Path) -> List[LanguageDefinition]:
18
+ definition = markdown_language_definition(profile, root)
19
+ return [definition] if definition is not None else []
20
+
21
+ def collect_workspace_folder_files(self, folder: WorkspaceFolder) -> Iterable[Path]:
22
+ if not markdown_extensions(self.diagnostics_context.profile):
23
+ return []
24
+
25
+ documents = self.diagnostics_context.workspace.documents
26
+ return filter(
27
+ lambda f: documents.detect_language_id(f) == MARKDOWN_LANGUAGE_ID, self.iter_workspace_folder_files(folder)
28
+ )
@@ -7,12 +7,12 @@ from robot.utils import FileReader
7
7
 
8
8
  from robotcode.analyze.code.diagnostics_context import DiagnosticsContext
9
9
  from robotcode.core.filewatcher import FileWatcherManagerDummy
10
- from robotcode.core.ignore_spec import DEFAULT_SPEC_RULES, GIT_IGNORE_FILE, ROBOT_IGNORE_FILE, IgnoreSpec, iter_files
11
10
  from robotcode.core.language import LanguageDefinition, language_id
12
11
  from robotcode.core.lsp.types import Diagnostic, DiagnosticSeverity, DiagnosticTag
13
12
  from robotcode.core.text_document import TextDocument
14
13
  from robotcode.core.uri import Uri
15
14
  from robotcode.core.workspace import WorkspaceFolder
15
+ from robotcode.robot.config.model import RobotBaseProfile
16
16
  from robotcode.robot.diagnostics.diagnostic_rules import is_variable_name_intentionally_unused
17
17
  from robotcode.robot.diagnostics.document_cache_helper import DocumentsCacheHelper
18
18
  from robotcode.robot.diagnostics.entities import (
@@ -20,26 +20,17 @@ from robotcode.robot.diagnostics.entities import (
20
20
  VariableDefinitionType,
21
21
  )
22
22
  from robotcode.robot.diagnostics.namespace import DocumentType
23
- from robotcode.robot.diagnostics.workspace_config import WorkspaceConfig
23
+ from robotcode.robot.language_definitions import ROBOT_LANGUAGE_IDS, ROBOTFRAMEWORK_LANGUAGE
24
24
 
25
25
  from .language_provider import LanguageProvider
26
26
 
27
- ROBOTFRAMEWORK_LANGUAGE_ID = "robotframework"
28
-
29
27
 
30
28
  class RobotFrameworkLanguageProvider(LanguageProvider):
31
- LANGUAGE_DEFINITION = LanguageDefinition(
32
- id=ROBOTFRAMEWORK_LANGUAGE_ID,
33
- extensions=[".robot", ".resource"],
34
- extensions_ignore_case=True,
35
- aliases=["Robot Framework", "robotframework"],
36
- )
37
-
38
29
  SOURCE_NAME = "robotcode.diagnostics"
39
30
 
40
31
  @classmethod
41
- def get_language_definitions(cls) -> List[LanguageDefinition]:
42
- return [cls.LANGUAGE_DEFINITION]
32
+ def get_language_definitions(cls, profile: RobotBaseProfile, root: Path) -> List[LanguageDefinition]:
33
+ return [ROBOTFRAMEWORK_LANGUAGE]
43
34
 
44
35
  def __init__(self, diagnostics_context: DiagnosticsContext) -> None:
45
36
  super().__init__(diagnostics_context)
@@ -84,34 +75,15 @@ class RobotFrameworkLanguageProvider(LanguageProvider):
84
75
  if Path(f).is_dir() and f not in sys.path:
85
76
  sys.path.insert(0, f)
86
77
 
87
- @language_id("robotframework")
78
+ @language_id(*ROBOT_LANGUAGE_IDS)
88
79
  def on_read_document_text(self, sender: Any, uri: Uri) -> str:
89
80
  with FileReader(uri.to_path()) as reader:
90
81
  return str(reader.read())
91
82
 
92
83
  def collect_workspace_folder_files(self, folder: WorkspaceFolder) -> Iterable[Path]:
93
- config = self.diagnostics_context.workspace.get_configuration(WorkspaceConfig, folder.uri)
94
-
95
- extensions = self.LANGUAGE_DEFINITION.extensions
96
-
97
- exclude_patterns = [
98
- *self.diagnostics_context.analysis_config.exclude_patterns,
99
- *(config.exclude_patterns or []),
100
- ]
101
- return filter(
102
- lambda f: f.suffix.lower() in extensions,
103
- iter_files(
104
- folder.uri.to_path(),
105
- ignore_files=[ROBOT_IGNORE_FILE, GIT_IGNORE_FILE],
106
- include_hidden=False,
107
- parent_spec=IgnoreSpec.from_list(
108
- [*DEFAULT_SPEC_RULES, *exclude_patterns],
109
- folder.uri.to_path(),
110
- ),
111
- verbose_callback=self.verbose_callback,
112
- verbose_trace=False,
113
- ),
114
- )
84
+ extensions = ROBOTFRAMEWORK_LANGUAGE.extensions
85
+
86
+ return filter(lambda f: f.suffix.lower() in extensions, self.iter_workspace_folder_files(folder))
115
87
 
116
88
  def analyze_folder(self, sender: Any, folder: WorkspaceFolder) -> Optional[List[Diagnostic]]:
117
89
  imports_manager = self._document_cache.get_imports_manager_for_workspace_folder(folder)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: robotcode-analyze
3
- Version: 2.9.0-dev.186
3
+ Version: 2.9.0-dev.214
4
4
  Summary: RobotCode analyze plugin for Robot Framework
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -26,9 +26,9 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
26
26
  Classifier: Topic :: Utilities
27
27
  Classifier: Typing :: Typed
28
28
  Requires-Python: >=3.10
29
- Requires-Dist: robotcode-plugin==2.9.0-dev.186
30
- Requires-Dist: robotcode-robot==2.9.0-dev.186
31
- Requires-Dist: robotcode==2.9.0-dev.186
29
+ Requires-Dist: robotcode-plugin==2.9.0-dev.214
30
+ Requires-Dist: robotcode-robot==2.9.0-dev.214
31
+ Requires-Dist: robotcode==2.9.0-dev.214
32
32
  Requires-Dist: robotframework>=5.0.0
33
33
  Description-Content-Type: text/markdown
34
34
 
@@ -1,5 +1,5 @@
1
1
  robotcode/analyze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- robotcode/analyze/__version__.py,sha256=DeNL4QD-HLgPf68SyWkBcV4BYX1z0-0is3Fgfr1b8yo,30
2
+ robotcode/analyze/__version__.py,sha256=uSd_IGr6ERx2haC8I41GwovkJcLQLJkFPK2nCwdiFEc,30
3
3
  robotcode/analyze/cli.py,sha256=MxGeNvscB-I_h00dag3N2Gmbv-frfuYAUAxfkRo26ys,774
4
4
  robotcode/analyze/config.py,sha256=F9_k3-flt2LjJvmENst8F8OHubYCTR65kZQkQE5kdKU,17996
5
5
  robotcode/analyze/dump_model.py,sha256=yIGs2s-9aR8rni_1FME9_gC6FeJh0yA9d3BLIahLWOI,5399
@@ -9,11 +9,12 @@ robotcode/analyze/cache/cli.py,sha256=-iLof0eCba529fI7joECnqyL8LrYS0EOoe_ExM9QKz
9
9
  robotcode/analyze/code/_models.py,sha256=-MO9BGNqrgv2dkEqPGcO6suvANUew0NPXJu5g1CmQS0,1043
10
10
  robotcode/analyze/code/_sarif.py,sha256=OjS5X3fvDQxwsE2nZROSrfEgpQNhhbcuV2Um4UP_OCI,2434
11
11
  robotcode/analyze/code/cli.py,sha256=WZEmstA0bvBKCXjaq-Q0qhAQt4Oscga6eCu4vRAxmTU,38056
12
- robotcode/analyze/code/code_analyzer.py,sha256=NREAZMBPIIbtxeWAjcp6OQediAsenDWUWJFxnxru95o,7349
12
+ robotcode/analyze/code/code_analyzer.py,sha256=lDtpjdDNJBuZiaV4fJ_-Infu_4fJrXRWWTa7fvx27uE,7544
13
13
  robotcode/analyze/code/diagnostics_context.py,sha256=9JZjexOaCBXKZQFn4eUjwiKr1kGhRiZuD2f9czrSSS0,2411
14
- robotcode/analyze/code/language_provider.py,sha256=Hh3WFtB4p0_brCNgCVZuYZfxyJ0oQ0tXW70b4UXevwM,751
15
- robotcode/analyze/code/robot_framework_language_provider.py,sha256=z9dR-8QgKUdeFx6vqKq28CvxwWMKRhs1nMii2W76fcU,8541
16
- robotcode_analyze-2.9.0.dev186.dist-info/METADATA,sha256=B15E_SmZjD6W4_6bnfX50_OMC4JpqE8s-vC-ai11Hmk,2953
17
- robotcode_analyze-2.9.0.dev186.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
- robotcode_analyze-2.9.0.dev186.dist-info/entry_points.txt,sha256=tnZjhZ4BA_m0ZhDzh2TguYSOq4ywFVyFLetV10BAExI,46
19
- robotcode_analyze-2.9.0.dev186.dist-info/RECORD,,
14
+ robotcode/analyze/code/language_provider.py,sha256=wRPV3Rmzmu68EkZwRb7i4BF9geRLmtrUOAABERaDBVI,1879
15
+ robotcode/analyze/code/markdown_language_provider.py,sha256=YbDx-1RBAAKrAZ8EUZoNeKD23pTPqb0eGrHY1PHc12Q,1261
16
+ robotcode/analyze/code/robot_framework_language_provider.py,sha256=DaiOC1c34PmrLu01_b6CHmYdaaox2ttSgTq_bRMP5V0,7581
17
+ robotcode_analyze-2.9.0.dev214.dist-info/METADATA,sha256=IM_E4VBwMyxD5sa9sDCx-hMh5ligiNtQywW5Q3KGeM4,2953
18
+ robotcode_analyze-2.9.0.dev214.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
19
+ robotcode_analyze-2.9.0.dev214.dist-info/entry_points.txt,sha256=tnZjhZ4BA_m0ZhDzh2TguYSOq4ywFVyFLetV10BAExI,46
20
+ robotcode_analyze-2.9.0.dev214.dist-info/RECORD,,