class Savi::Compiler::SourceService

Defined in:

savi/compiler/source_service.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def core_package_internal_path : String #

[View source]
def core_package_internal_path=(core_package_internal_path : String) #

[View source]
def core_savi_package_path #

[View source]
def find_latest_in_deps(ctx, dep : Packaging::Dependency) : String | Nil #

Find a dependency in the local deps dir which matches the given dep spec.


[View source]
def find_relative_dep(ctx, dep : Packaging::Dependency) : String | Nil #

Find a dependency that has a local relative path as its location.


[View source]
def get_directory_sources(dirname : String, package : Source::Package) #

Given a directory name, load source objects for all the source files in it.


[View source]
def get_manifest_sources_at(dirname : String) #

Given a directory name, load source objects for all the source files in it.


[View source]
def get_manifest_sources_at_or_above(dirname : String) #

Given a directory name, load manifest sources in it, or in the nearest directory above it that contains manifest sources.


[View source]
def get_recursive_sources(root_dirname, language = :savi) #

Given a directory name, load source objects for all the source files in each subdirectory of that root directory, grouped by source package.


[View source]
def get_source_at(path, source_package) #

Get the source object at the given path, either an override or real file.


[View source]
def get_sources_for_manifest(ctx, manifest : Packaging::Manifest) #

Given a manifest, load source objects for all the source files in its paths.


[View source]
def main_directory_remap : Tuple(String, String) | Nil #

[View source]
def main_directory_remap=(main_directory_remap : Tuple(String, String) | Nil) #

[View source]
def meta_declarators_package_path #

[View source]
def overwrite_source_at(path, content) #

Write the given content to the source file at the given path. Note that these changes may not be visible if the real file is being shadowed by a source override (which this operation will not affect).


[View source]
def set_source_override(path, content) #

Add/update a source override, which causes the SourceService to pretend as if there is a file at the given path with the given content in it.

If there really is a file at that path, the source override will shadow it, overriding the real content of the file for as long as the override exists. If there is no such file at that path, the source override makes the system pretend as if there is a file there, so it will show up in that directory if and when the directory is compiled as a package in the program.

This is used by editor-interactive systems like the language server, allowing the content in the text editor that has opened the given file to temporarily override whatever content is actually saved to disk there. This allows us to compile as the user is typing, even if they haven't saved.


[View source]
def standard_declarators_package_path #

[View source]
def standard_directory_remap : Tuple(String, String) | Nil #

[View source]
def standard_directory_remap=(standard_directory_remap : Tuple(String, String) | Nil) #

[View source]
def unset_source_override(path) #

Remove the source override at the given path, if it exists.

This corresponds to the closing of a file in a text editor.

See docs for #set_source_override for more information.


[View source]