Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format all the files with the new vfmt #117

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions build.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ os.setenv('BUILD_DATETIME', build_datetime, true)
os.setenv('BUILD_COMMIT', build_commit, true)

mut cmd := cli.Command{
name: 'v-analyzer-builder'
version: metadata.manifest.version
name: 'v-analyzer-builder'
version: metadata.manifest.version
description: 'Builds the v-analyzer binary.'
posix_mode: true
execute: fn (_ cli.Command) ! {
posix_mode: true
execute: fn (_ cli.Command) ! {
build(.debug, false)
}
}
Expand All @@ -107,19 +107,19 @@ mut cmd := cli.Command{
// Thanks to -d use_libbacktrace, the binary will print beautiful stack traces,
// which is very useful for debugging.
cmd.add_command(cli.Command{
name: 'debug'
name: 'debug'
description: 'Builds the v-analyzer binary in debug mode.'
execute: fn (_ cli.Command) ! {
execute: fn (_ cli.Command) ! {
build(.debug, true)
}
})

// dev builds the v-analyzer binary in development mode.
// In this mode, additional development features are enabled.
cmd.add_command(cli.Command{
name: 'dev'
name: 'dev'
description: 'Builds the v-analyzer binary in development mode.'
execute: fn (_ cli.Command) ! {
execute: fn (_ cli.Command) ! {
build(.dev, false)
}
})
Expand All @@ -128,9 +128,9 @@ cmd.add_command(cli.Command{
// This is the recommended mode for production use.
// It is about 30-40% faster than debug mode.
cmd.add_command(cli.Command{
name: 'release'
name: 'release'
description: 'Builds the v-analyzer binary in release mode.'
execute: fn (_ cli.Command) ! {
execute: fn (_ cli.Command) ! {
build(.release, false)
}
})
Expand Down
36 changes: 18 additions & 18 deletions install.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ fn run_command(cmd string) !int {
}

mut command := os.Command{
path: cmd
path: cmd
redirect_stdout: true
}

Expand Down Expand Up @@ -481,47 +481,47 @@ pub fn get_release_type(cmd cli.Command) string {
}

mut cmd := cli.Command{
name: 'v-analyzer-installer-updated'
version: installer_version
name: 'v-analyzer-installer-updated'
version: installer_version
description: 'Install and update v-analyzer'
posix_mode: true
execute: fn (cmd cli.Command) ! {
posix_mode: true
execute: fn (cmd cli.Command) ! {
no_interaction := cmd.flags.get_bool('no-interaction') or { os.getenv('GITHUB_JOB') != '' }
release_type := get_release_type(cmd)
install(no_interaction, release_type)!
}
flags: [
cli.Flag{
flag: .bool
name: 'no-interaction' // Used primarily for VS Code extension, to install v-analyzer from sources
flag: .bool
name: 'no-interaction' // Used primarily for VS Code extension, to install v-analyzer from sources
description: 'Do not ask any questions, use default values'
},
]
}

cmd.add_command(cli.Command{
name: 'up'
name: 'up'
description: 'Update v-analyzer to the latest version'
posix_mode: true
execute: fn (cmd cli.Command) ! {
posix_mode: true
execute: fn (cmd cli.Command) ! {
nightly := cmd.flags.get_bool('nightly') or { false }
release_type := get_release_type(cmd)
update(nightly, release_type)!
}
flags: [
cli.Flag{
flag: .bool
name: 'nightly'
flag: .bool
name: 'nightly'
description: 'Install the latest nightly build'
},
]
})

cmd.add_command(cli.Command{
name: 'check-availability'
name: 'check-availability'
description: 'Check if v-analyzer binary is available for the current platform (service command for editors)'
posix_mode: true
execute: fn (cmd cli.Command) ! {
posix_mode: true
execute: fn (cmd cli.Command) ! {
release_type := get_release_type(cmd)
find_latest_asset(release_type) or {
println('Prebuild v-analyzer binary is not available for your platform')
Expand All @@ -533,10 +533,10 @@ cmd.add_command(cli.Command{
})

cmd.add_command(cli.Command{
name: 'check-updates'
name: 'check-updates'
description: 'Checks for v-analyzer updates.'
posix_mode: true
execute: fn (cmd cli.Command) ! {
posix_mode: true
execute: fn (cmd cli.Command) ! {
release_type := get_release_type(cmd)
check_updates(release_type)!
}
Expand Down
36 changes: 18 additions & 18 deletions src/analyzer/index/IndexDeserializer.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub fn (mut d IndexDeserializer) deserialize_index(expected_version string) !Ind
file_indexes := d.deserialize_file_indexes()

return Index{
version: version
version: version
updated_at: time.unix(updated_at_unix)
per_file: PerFileIndex{
per_file: PerFileIndex{
data: file_indexes
}
}
Expand All @@ -53,18 +53,18 @@ pub fn (mut d IndexDeserializer) deserialize_file_index() FileIndex {
stub_index_sink := d.deserialize_stub_index_sink(stub_list, kind)

return FileIndex{
kind: kind
kind: kind
file_last_modified: file_last_modified
stub_list: stub_list
sink: stub_index_sink
stub_list: stub_list
sink: stub_index_sink
}
}

pub fn (mut d IndexDeserializer) deserialize_stub_index_sink(stub_list &psi.StubList, kind IndexingRootKind) &psi.StubIndexSink {
len := d.d.read_int()
mut sink := &psi.StubIndexSink{
stub_list: stub_list
kind: unsafe { psi.StubIndexLocationKind(u8(kind)) }
kind: unsafe { psi.StubIndexLocationKind(u8(kind)) }
}
for _ in 0 .. len {
key := d.d.read_int()
Expand Down Expand Up @@ -156,26 +156,26 @@ pub fn (mut d IndexDeserializer) deserialize_stub() &psi.StubBase {
id := d.d.read_int()

return &psi.StubBase{
text: text
comment: comment
receiver: receiver
additional: additional
name: name
text: text
comment: comment
receiver: receiver
additional: additional
name: name
identifier_text_range: psi.TextRange{
line: identifier_line
column: identifier_column
end_line: identifier_end_line
line: identifier_line
column: identifier_column
end_line: identifier_end_line
end_column: identifier_end_column
}
text_range: psi.TextRange{
line: line
column: column
end_line: end_line
line: line
column: column
end_line: end_line
end_column: end_column
}
parent_id: parent_id
stub_list: unsafe { nil } // will be set later
stub_type: stub_type
id: id
id: id
}
}
16 changes: 8 additions & 8 deletions src/analyzer/index/IndexingRoot.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import analyzer.parser

// BuiltIndexStatus describes the status of the built index.
pub enum BuiltIndexStatus {
from_cache // index was loaded from cache
from_cache // index was loaded from cache
from_scratch // index was built from scratch
}

Expand Down Expand Up @@ -41,7 +41,7 @@ pub fn (k IndexingRootKind) readable_name() string {
@[noinit]
pub struct IndexingRoot {
pub:
root string // root that is indexed
root string // root that is indexed
kind IndexingRootKind // type of root that is indexed
pub mut:
cache_dir string // path to the directory where the index is stored
Expand All @@ -56,9 +56,9 @@ pub mut:
pub fn new_indexing_root(root string, kind IndexingRootKind, cache_dir string) &IndexingRoot {
cache_file := 'v_analyzer_index_${md5.hexhash(root)}'
return &IndexingRoot{
root: root
kind: kind
cache_dir: cache_dir
root: root
kind: kind
cache_dir: cache_dir
cache_file: cache_file
}
}
Expand Down Expand Up @@ -185,10 +185,10 @@ pub fn (mut i IndexingRoot) index_file(path string, content string) !FileIndex {
module_fqn := psi.module_qualified_name(psi_file, i.root)

mut cache := FileIndex{
kind: i.kind
kind: i.kind
file_last_modified: last_modified
sink: &psi.StubIndexSink{
kind: unsafe { psi.StubIndexLocationKind(u8(i.kind)) }
sink: &psi.StubIndexSink{
kind: unsafe { psi.StubIndexLocationKind(u8(i.kind)) }
stub_list: unsafe { nil }
}
stub_list: unsafe { nil }
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/index/StubTree.v
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn build_stub_tree_iterative(file &psi.PsiFile, mut nodes []NodeInfo) &StubT

nodes = nodes[..0].clone()
nodes << NodeInfo{
node: root
node: root
parent: stub_root
}

Expand All @@ -122,7 +122,7 @@ pub fn build_stub_tree_iterative(file &psi.PsiFile, mut nodes []NodeInfo) &StubT

for child in node.node.children() {
nodes << NodeInfo{
node: child
node: child
parent: parent_stub
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn parse_code_with_tree(code string, old_tree &bindings.Tree[bindings.NodeTy
raw_tree := if isnil(old_tree) { unsafe { nil } } else { old_tree.raw_tree }
tree := parser.parse_string(source: code, tree: raw_tree)
return ParseResult{
tree: tree
tree: tree
source_text: code
}
}
6 changes: 3 additions & 3 deletions src/analyzer/psi/PsiElement.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pub type ID = int
pub type AstNode = bindings.Node[bindings.NodeType]

pub interface PsiElement {
node AstNode // base node from Tree Sitter
node AstNode // base node from Tree Sitter
containing_file &PsiFile // file where the element is located
stub_id StubId
get_stub() ?&StubBase
stub_list() &StubList
element_type() bindings.NodeType
node() AstNode // return base node from Tree Sitter
containing_file() &PsiFile // return file where the element is located
node() AstNode // return base node from Tree Sitter
containing_file() &PsiFile // return file where the element is located
is_equal(other PsiElement) bool // return true if the element is equal to the other element
// find_element_at returns the leaf node at the specified position relative to the start of the node.
// If the node is not found, none is returned.
Expand Down
16 changes: 8 additions & 8 deletions src/analyzer/psi/PsiElementImpl.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ pub:

pub fn new_psi_node(containing_file &PsiFile, node AstNode) PsiElementImpl {
return PsiElementImpl{
node: node
node: node
containing_file: containing_file
stubs_list: unsafe { nil }
stubs_list: unsafe { nil }
}
}

fn new_psi_node_from_stub(id StubId, stubs_list &StubList) PsiElementImpl {
return PsiElementImpl{
node: AstNode{}
node: AstNode{}
containing_file: new_stub_psi_file(stubs_list.path, stubs_list)
stub_id: id
stubs_list: stubs_list
stub_id: id
stubs_list: stubs_list
}
}

Expand Down Expand Up @@ -422,9 +422,9 @@ pub fn (n &PsiElementImpl) text_range() TextRange {
}

return TextRange{
line: int(n.node.start_point().row)
column: int(n.node.start_point().column)
end_line: int(n.node.end_point().row)
line: int(n.node.start_point().row)
column: int(n.node.start_point().column)
end_line: int(n.node.end_point().row)
end_column: int(n.node.end_point().column)
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/analyzer/psi/PsiFile.v
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ pub mut:

pub fn new_psi_file(path string, tree &bindings.Tree[bindings.NodeType], source_text string) &PsiFile {
mut file := &PsiFile{
path: path
tree: unsafe { tree }
path: path
tree: unsafe { tree }
source_text: source_text
stub_list: unsafe { nil }
root: unsafe { nil }
stub_list: unsafe { nil }
root: unsafe { nil }
}
file.root = create_element(AstNode(tree.root_node()), file)
return file
}

pub fn new_stub_psi_file(path string, stub_list &StubList) &PsiFile {
return &PsiFile{
path: path
tree: unsafe { nil }
path: path
tree: unsafe { nil }
source_text: ''
stub_list: stub_list
root: unsafe { nil }
stub_list: stub_list
root: unsafe { nil }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/psi/PsiTreeWalker.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn (mut tw PsiTreeWalker) next() ?PsiElement {

pub fn new_psi_tree_walker(root_node PsiElement) PsiTreeWalker {
return PsiTreeWalker{
tree_walker: new_tree_walker(root_node.node)
tree_walker: new_tree_walker(root_node.node)
containing_file: root_node.containing_file
}
}
Loading