Class: MilkTea::SemanticAnalyzer
- Inherits:
-
Object
- Object
- MilkTea::SemanticAnalyzer
- Defined in:
- lib/milk_tea/core/semantic_analyzer.rb,
lib/milk_tea/core/semantic_analyzer/calls.rb,
lib/milk_tea/core/semantic_analyzer/top_level.rb,
lib/milk_tea/core/semantic_analyzer/attributes.rb,
lib/milk_tea/core/semantic_analyzer/statements.rb,
lib/milk_tea/core/semantic_analyzer/expressions.rb,
lib/milk_tea/core/semantic_analyzer/nullability.rb,
lib/milk_tea/core/semantic_analyzer/module_context.rb,
lib/milk_tea/core/semantic_analyzer/flow_refinement.rb,
lib/milk_tea/core/semantic_analyzer/name_resolution.rb,
lib/milk_tea/core/semantic_analyzer/analysis_context.rb,
lib/milk_tea/core/semantic_analyzer/function_binding.rb,
lib/milk_tea/core/semantic_analyzer/type_declaration.rb,
lib/milk_tea/core/semantic_analyzer/type_compatibility.rb,
lib/milk_tea/core/semantic_analyzer/interface_conformance.rb
Defined Under Namespace
Classes: Analysis, AttributePresenceKey, BindingResolution, Checker, DefaultResolution, EqualResolution, GenericInterfaceBinding, HashResolution, InterfaceBinding, InterfaceMethodBinding, LocalCompletionFrame, LocalCompletionSnapshot, ModuleContext, OrderResolution, ResolvedAttributeApplication, ToolingSnapshot, TypeParamConstraintBinding
Constant Summary collapse
- INSTALLABLE_BUILTIN_TYPE_NAMES =
(MilkTea::BUILTIN_PRIMITIVE_NAMES + %w[ Subscription EventError struct_handle field_handle callable_handle attribute_handle member_handle type ]).freeze
Class Method Summary collapse
- .check(ast, imported_modules: {}, allow_missing_imports: false, path: nil, global_import_index: {}) ⇒ Object
-
.check_collecting_errors(ast, imported_modules: {}, allow_missing_imports: false, path: nil) ⇒ Object
LSP-oriented entry point: runs all sema phases and collects every error instead of stopping at the first one.
- .tooling_snapshot(ast, imported_modules: {}, allow_missing_imports: false, path: nil) ⇒ Object
Class Method Details
.check(ast, imported_modules: {}, allow_missing_imports: false, path: nil, global_import_index: {}) ⇒ Object
110 111 112 |
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 110 def self.check(ast, imported_modules: {}, allow_missing_imports: false, path: nil, global_import_index: {}) Checker.new(ast, imported_modules:, allow_missing_imports:, path:, global_import_index:).check end |
.check_collecting_errors(ast, imported_modules: {}, allow_missing_imports: false, path: nil) ⇒ Object
LSP-oriented entry point: runs all sema phases and collects every error instead of stopping at the first one. Structural phases collect per- declaration, and function-body phases collect per function/method. Returns { analysis: Analysis|nil, errors: [SemanticError] }.
118 119 120 121 122 |
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 118 def self.check_collecting_errors(ast, imported_modules: {}, allow_missing_imports: false, path: nil) Checker.new(ast, imported_modules:, allow_missing_imports:, path:).check_collecting_errors rescue SemanticError => e { analysis: nil, errors: [e] } end |
.tooling_snapshot(ast, imported_modules: {}, allow_missing_imports: false, path: nil) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 124 def self.tooling_snapshot(ast, imported_modules: {}, allow_missing_imports: false, path: nil) result = check_collecting_errors(ast, imported_modules:, allow_missing_imports:, path:) diagnostics = Array(result[:errors]).map { |error| error.to_diagnostic(path:) }.freeze ToolingSnapshot.new(facts: result[:analysis], diagnostics:) end |