# Implementation of the method-related annotation `cached`
#
-# Note this module can be used as a reference on how to implements
-# complex annotation that modify both the model and the AST of a Nit program
+# The cached annotation is deprecated, use the `lazy` annotation instead.
module cached
import modelize
intrude import modelize::modelize_property
redef class ToolContext
+ # Process the `cached` annotation on methods
var cached_phase: Phase = new CachedPhase(self, [modelize_property_phase])
end
private import annotation
redef class ToolContext
+ # Check for unknown annotation in each module
var check_annotation_phase: Phase = new CheckAnnotationPhase(self, null)
end
redef class ToolContext
# FIXME: there is conflict in linex in nitc, so use this trick to force invocation
private var dummy: Bool = do_dummy
- fun do_dummy: Bool
+
+ # SEE `dummy`
+ private fun do_dummy: Bool
do
# Force easy warnings after modelbuilder
phases.add_edge(simple_misc_analysis_phase, modelize_property_phase)
private import annotation
redef class ToolContext
+ # Generate serialization and deserialization methods on `auto_serializable` annotated classes.
var serialization_phase_pre_model: Phase = new SerializationPhasePreModel(self, null)
+
+ # The second phase of the serialization
var serialization_phase_post_model: Phase = new SerializationPhasePostModel(self,
[modelize_class_phase, serialization_phase_pre_model])
import phase
redef class ToolContext
+ # Execute `AModule::do_simple_misc_analysis` on each module.
var simple_misc_analysis_phase: Phase = new SimpleMiscAnalysisPhase(self, null)
end
# See the License for the specific language governing permissions and
# limitations under the License.
-# Highliting of Nit AST
+# Highlighting of Nit AST
module highlight
import frontend
html.add_class("nitcode")
end
+ # The entry-point of the highlighting.
+ # Will fill `html` with the generated HTML content.
fun enter_visit(n: ANode)
do
n.parentize_tokens
return res
end
+ # The module HTML page
fun href: String
do
return name + ".html"
return res
end
+ # The class HTML page (an anchor in the module page)
fun href: String
do
return mmodule.href + "#" + to_s
return res
end
+ # The property HTML page (an anchor in the module page)
fun href: String
do
return self.mclassdef.mmodule.href + "#" + self.to_s
import phase
redef class ToolContext
+ # Parses literal values in the whole AST and produces errors if needed
var literal_phase: Phase = new LiteralPhase(self, null)
end
# See the License for the specific language governing permissions and
# limitations under the License.
-# This module is used to model Nit source-file and locations in source-file
+# Nit source-file and locations in source-file
module location
# A raw text Nit source file
super Comparable
redef type OTHER: Location
+ # The associated source-file
var file: nullable SourceFile
+
+ # The starting line number (starting from 1)
var line_start: Int
+
+ # The stopping line number (starting from 1)
var line_end: Int
# Start of this location on `line_start`
# Require: `column_start >= 0`
var column_start: Int
+ # End of this location on `line_end`
var column_end: Int
# The index in the start character in the source
private var text_cache: nullable String = null
- init with_file(f: SourceFile) do init(f,0,0,0,0)
-
redef fun ==(other: nullable Object): Bool do
if other == null then return false
if not other isa Location then return false
# is empty if the class is not generic
var mparameters = new Array[MParameterType]
+ # Initialize `mparameters` from their names.
protected fun setup_parameter_names(parameter_names: nullable Array[String]) is
autoinit
do
end
end
+ # Returns a new parameter with the `mtype` resolved.
+ # See `MType::resolve_for` for details.
fun resolve_for(mtype: MType, anchor: nullable MClassType, mmodule: MModule, cleanup_virtual: Bool): MParameter
do
if not self.mtype.need_anchor then return self
redef class ADoc
private var mdoc_cache: nullable MDoc
+
+ # Convert `self` to a `MDoc`
fun to_mdoc: MDoc
do
var res = mdoc_cache
import modelbuilder
redef class ToolContext
+ # Run `AModule::build_classes` on each module
var modelize_class_phase: Phase = new ModelizeClassPhase(self, null)
end
private import annotation
redef class ToolContext
+ # Run `AClassdef::build_property` on the classdefs of each module
var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase])
end
end
redef class AClassdef
- var build_properties_is_done = false
+ # Marker used in `ModelBuilder::build_properties`
+ private var build_properties_is_done = false
# The free init (implicitely constructed by the class if required)
var mfree_init: nullable MMethodDef = null
end
end
+# A modified lexer that feed tokens before and after the real tokens.
class InjectedLexer
super Lexer
+ # The tokens to use before the real tokens (in order).
var injected_before = new List[Token]
+
+ # The tokens to use after the real tokens (in order).
+ # The real EOF token is produced after these tokens.
var injected_after = new List[Token]
private var is_finished = false
redef class ToolContext
# The various registered phases to performs
- # The order in the poset is the dependance of phases
+ # The order in the poset is the dependence of phases
#
# While you can directly modify the poset (nodes and edges),
# it is often simpler to use the constructor in `Phase`
end
end
+ # The list of registered phases in the application order.
fun phases_list: Sequence[Phase]
do
var phases = self.phases.to_a
errors_info
end
- fun phase_process_npropdef(phase: Phase, npropdef: APropdef)
+ # Process the given `phase` on the `npropdef`
+ # Called by `run_phases`
+ protected fun phase_process_npropdef(phase: Phase, npropdef: APropdef)
do
phase.process_npropdef(npropdef)
end
# See the License for the specific language governing permissions and
# limitations under the License.
-# Computing of super-constructors that must be implicitely called at the begin of constructors.
+# Computing of super-constructors that must be implicitly called at the begin of constructors.
# The current rules are a bit crazy but whatever.
module auto_super_init
private import annotation
redef class ToolContext
+ # Phase that inject `super` in constructors that need it.
var auto_super_init_phase: Phase = new AutoSuperInitPhase(self, [typing_phase])
end
import scope
redef class ToolContext
+ # Run `APropdef::do_flow` on each propdef
var flow_phase: Phase = new FlowPhase(self, [scope_phase])
end
import flow
redef class ToolContext
+ # Run `APropdef::do_local_var_init` on each propdef
var local_var_init_phase: Phase = new LocalVarInitPhase(self, [flow_phase])
end
import phase
redef class ToolContext
+ # Run `APropdef::do_scope` on each propdef.
var scope_phase: Phase = new ScopePhase(self, null)
end
var block: String
end
-class SearchAssertVisitor
- super Visitor
- var foundit = false
- redef fun visit(node)
- do
- if foundit then
- return
- else if node isa AAssertExpr then
- foundit = true
- return
- else
- node.visit_all(self)
- end
- end
-end
-
redef class ModelBuilder
+ # Total number analyzed `MEntity`
var total_entities = 0
+
+ # The number of `MEntity` that have some documentation
var doc_entities = 0
+
+ # The total number of executed docunits
var unit_entities = 0
+
+ # The number failed docunits
var failed_entities = 0
+ # Extracts and executes all the docunits in the `mmodule`
+ # Returns a JUnit-compatible `<testsuite>` XML element that contains the results of the executions.
fun test_markdown(mmodule: MModule): HTMLTag
do
var ts = new HTMLTag("testsuite")