nitc :: AutocompletePhase :: defaultinit
nitc $ AutocompletePhase :: SELF
Type of this instance, automatically specialized in every classnitc $ AutocompletePhase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: _in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: _toolcontext
The toolcontext instance attached to the phasecore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: AutocompletePhase :: defaultinit
nitc :: Phase :: defaultinit
core :: Object :: defaultinit
nitc :: Phase :: in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: in_hierarchy=
The dependence relation of the phase with the other phasescore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: Phase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: process_nclassdef
Specific actions to execute on the tree of a class definitionnitc :: Phase :: process_nmodule
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_nmodule_after
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_npropdef
Specific actions to execute on the tree of a propertynitc :: Phase :: toolcontext
The toolcontext instance attached to the phasenitc :: Phase :: toolcontext=
The toolcontext instance attached to the phase
private class AutocompletePhase
super Phase
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_vim_autocomplete.value then return
var compile_dir = "NIT_VIM_DIR".environ
if compile_dir.is_empty then compile_dir = "HOME".environ / ".vim/nit"
compile_dir.mkdir
var modules_stream = new FileWriter.open(compile_dir / "modules.txt")
var classes_stream = new FileWriter.open(compile_dir / "classes.txt")
var constructors_stream = new FileWriter.open(compile_dir / "constructors.txt")
var types_stream = new FileWriter.open(compile_dir / "types.txt")
var properties_stream = new FileWriter.open(compile_dir / "properties.txt")
# Got all known modules
var model = mainmodule.model
for mmodule in model.mmodules do
mmodule.write_doc(model, mainmodule, modules_stream)
end
# TODO list other modules from the Nit lib
# Get all known classes
for mclass in model.mclasses do
if not mainmodule.is_visible(mclass.intro_mmodule, public_visibility) then continue
var mclass_intro = mclass.intro
# Can it be instantiated?
if mclass.kind != interface_kind and mclass.kind != abstract_kind then
for prop in mclass.collect_accessible_mproperties(mainmodule) do
if prop isa MMethod and prop.is_init then
mclass_intro.target_constructor = prop.intro
mclass_intro.write_doc(model, mainmodule, constructors_stream)
end
end
mclass_intro.target_constructor = null
end
# Always add to types and classes
mclass.mclass_type.write_doc(model, mainmodule, classes_stream)
mclass.mclass_type.write_doc(model, mainmodule, types_stream)
end
# Get all known properties
for mproperty in model.mproperties do
var intro_mmodule = mproperty.intro_mclassdef.mmodule
if not mainmodule.is_visible(intro_mmodule, public_visibility) then continue
# Is it a virtual type?
if mproperty isa MVirtualTypeProp then
mproperty.intro.write_doc(model, mainmodule, types_stream)
continue
end
# Skip properties beginning with @ or _
var first_letter = mproperty.name.chars.first
if first_letter == '@' or first_letter == '_' then continue
mproperty.intro.write_doc(model, mainmodule, properties_stream)
end
# Close streams
for stream in [modules_stream, classes_stream, properties_stream,
types_stream, constructors_stream] do
stream.close
var error = stream.last_error
if error != null then
toolcontext.error(null, "Error: failed to write Vim autocomplete file: {error}.")
end
end
end
end
src/doc/vim_autocomplete.nit:255,1--331,3