more tracy calls (#1052)
This commit is contained in:
parent
ff467f9878
commit
c203110555
@ -3046,6 +3046,15 @@ pub fn processMessage(server: *Server, message: Message) Error!void {
|
|||||||
const tracy_zone = tracy.trace(@src());
|
const tracy_zone = tracy.trace(@src());
|
||||||
defer tracy_zone.end();
|
defer tracy_zone.end();
|
||||||
|
|
||||||
|
if (message.method()) |name| {
|
||||||
|
tracy_zone.setName(name);
|
||||||
|
} else if (message.id()) |id| {
|
||||||
|
switch (id) {
|
||||||
|
.integer => {},
|
||||||
|
.string => |name| tracy_zone.setName(name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.RequestMessage => |request| {
|
.RequestMessage => |request| {
|
||||||
if (!requestMethodExists(request.method)) return error.MethodNotFound;
|
if (!requestMethodExists(request.method)) return error.MethodNotFound;
|
||||||
|
@ -6,6 +6,7 @@ const offsets = @import("offsets.zig");
|
|||||||
const URI = @import("uri.zig");
|
const URI = @import("uri.zig");
|
||||||
const log = std.log.scoped(.zls_analysis);
|
const log = std.log.scoped(.zls_analysis);
|
||||||
const ast = @import("ast.zig");
|
const ast = @import("ast.zig");
|
||||||
|
const tracy = @import("tracy.zig");
|
||||||
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
|
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
|
||||||
const InternPool = ComptimeInterpreter.InternPool;
|
const InternPool = ComptimeInterpreter.InternPool;
|
||||||
|
|
||||||
@ -1284,6 +1285,9 @@ pub fn collectImports(allocator: std.mem.Allocator, tree: Ast) error{OutOfMemory
|
|||||||
/// Collects all `@cImport` nodes
|
/// Collects all `@cImport` nodes
|
||||||
/// Caller owns returned memory.
|
/// Caller owns returned memory.
|
||||||
pub fn collectCImportNodes(allocator: std.mem.Allocator, tree: Ast) error{OutOfMemory}![]Ast.Node.Index {
|
pub fn collectCImportNodes(allocator: std.mem.Allocator, tree: Ast) error{OutOfMemory}![]Ast.Node.Index {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var import_nodes = std.ArrayListUnmanaged(Ast.Node.Index){};
|
var import_nodes = std.ArrayListUnmanaged(Ast.Node.Index){};
|
||||||
errdefer import_nodes.deinit(allocator);
|
errdefer import_nodes.deinit(allocator);
|
||||||
|
|
||||||
@ -1621,6 +1625,9 @@ pub fn getPositionContext(
|
|||||||
/// Should we look to the end of the current context? Yes for goto def, no for completions
|
/// Should we look to the end of the current context? Yes for goto def, no for completions
|
||||||
lookahead: bool,
|
lookahead: bool,
|
||||||
) !PositionContext {
|
) !PositionContext {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var new_index = doc_index;
|
var new_index = doc_index;
|
||||||
if (lookahead and new_index < text.len and isSymbolChar(text[new_index])) {
|
if (lookahead and new_index < text.len and isSymbolChar(text[new_index])) {
|
||||||
new_index += 1;
|
new_index += 1;
|
||||||
@ -2612,6 +2619,9 @@ pub const Scope = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn makeDocumentScope(allocator: std.mem.Allocator, tree: Ast) !DocumentScope {
|
pub fn makeDocumentScope(allocator: std.mem.Allocator, tree: Ast) !DocumentScope {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var document_scope = DocumentScope{
|
var document_scope = DocumentScope{
|
||||||
.scopes = .{},
|
.scopes = .{},
|
||||||
.error_completions = .{},
|
.error_completions = .{},
|
||||||
@ -2639,6 +2649,9 @@ const ScopeContext = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn makeInnerScope(allocator: std.mem.Allocator, context: ScopeContext, node_idx: Ast.Node.Index) error{OutOfMemory}!void {
|
fn makeInnerScope(allocator: std.mem.Allocator, context: ScopeContext, node_idx: Ast.Node.Index) error{OutOfMemory}!void {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const scopes = context.scopes;
|
const scopes = context.scopes;
|
||||||
const tree = context.tree;
|
const tree = context.tree;
|
||||||
const tags = tree.nodes.items(.tag);
|
const tags = tree.nodes.items(.tag);
|
||||||
|
10
src/diff.zig
10
src/diff.zig
@ -1,6 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const types = @import("lsp.zig");
|
const types = @import("lsp.zig");
|
||||||
const offsets = @import("offsets.zig");
|
const offsets = @import("offsets.zig");
|
||||||
|
const tracy = @import("tracy.zig");
|
||||||
const DiffMatchPatch = @import("diffz");
|
const DiffMatchPatch = @import("diffz");
|
||||||
|
|
||||||
const dmp = DiffMatchPatch{
|
const dmp = DiffMatchPatch{
|
||||||
@ -15,6 +16,9 @@ pub fn edits(
|
|||||||
after: []const u8,
|
after: []const u8,
|
||||||
encoding: offsets.Encoding,
|
encoding: offsets.Encoding,
|
||||||
) Error!std.ArrayListUnmanaged(types.TextEdit) {
|
) Error!std.ArrayListUnmanaged(types.TextEdit) {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var arena = std.heap.ArenaAllocator.init(allocator);
|
var arena = std.heap.ArenaAllocator.init(allocator);
|
||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
var diffs = try dmp.diff(arena.allocator(), before, after, true);
|
var diffs = try dmp.diff(arena.allocator(), before, after, true);
|
||||||
@ -70,6 +74,9 @@ pub fn applyContentChanges(
|
|||||||
content_changes: []const types.TextDocumentContentChangeEvent,
|
content_changes: []const types.TextDocumentContentChangeEvent,
|
||||||
encoding: offsets.Encoding,
|
encoding: offsets.Encoding,
|
||||||
) ![:0]const u8 {
|
) ![:0]const u8 {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var last_full_text_change: ?usize = null;
|
var last_full_text_change: ?usize = null;
|
||||||
var i: usize = content_changes.len;
|
var i: usize = content_changes.len;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
@ -111,6 +118,9 @@ pub fn applyTextEdits(
|
|||||||
text_edits: []const types.TextEdit,
|
text_edits: []const types.TextEdit,
|
||||||
encoding: offsets.Encoding,
|
encoding: offsets.Encoding,
|
||||||
) ![]const u8 {
|
) ![]const u8 {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var text_edits_sortable = try allocator.alloc(types.TextEdit, text_edits.len);
|
var text_edits_sortable = try allocator.alloc(types.TextEdit, text_edits.len);
|
||||||
defer allocator.free(text_edits_sortable);
|
defer allocator.free(text_edits_sortable);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const std = @import("std");
|
|||||||
const ast = @import("ast.zig");
|
const ast = @import("ast.zig");
|
||||||
const types = @import("lsp.zig");
|
const types = @import("lsp.zig");
|
||||||
const offsets = @import("offsets.zig");
|
const offsets = @import("offsets.zig");
|
||||||
|
const tracy = @import("tracy.zig");
|
||||||
const Ast = std.zig.Ast;
|
const Ast = std.zig.Ast;
|
||||||
|
|
||||||
const FoldingRange = struct {
|
const FoldingRange = struct {
|
||||||
@ -54,6 +55,9 @@ const Builder = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getRanges(builder: Builder) error{OutOfMemory}![]types.FoldingRange {
|
pub fn getRanges(builder: Builder) error{OutOfMemory}![]types.FoldingRange {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var result_locations = try builder.allocator.alloc(types.FoldingRange, builder.locations.items.len);
|
var result_locations = try builder.allocator.alloc(types.FoldingRange, builder.locations.items.len);
|
||||||
errdefer builder.allocator.free(result_locations);
|
errdefer builder.allocator.free(result_locations);
|
||||||
|
|
||||||
@ -121,6 +125,9 @@ const Builder = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn generateFoldingRanges(allocator: std.mem.Allocator, tree: Ast, encoding: offsets.Encoding) error{OutOfMemory}![]types.FoldingRange {
|
pub fn generateFoldingRanges(allocator: std.mem.Allocator, tree: Ast, encoding: offsets.Encoding) error{OutOfMemory}![]types.FoldingRange {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var builder = Builder{
|
var builder = Builder{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.locations = .{},
|
.locations = .{},
|
||||||
|
@ -4,6 +4,7 @@ const DocumentStore = @import("DocumentStore.zig");
|
|||||||
const analysis = @import("analysis.zig");
|
const analysis = @import("analysis.zig");
|
||||||
const types = @import("lsp.zig");
|
const types = @import("lsp.zig");
|
||||||
const offsets = @import("offsets.zig");
|
const offsets = @import("offsets.zig");
|
||||||
|
const tracy = @import("tracy.zig");
|
||||||
const Ast = std.zig.Ast;
|
const Ast = std.zig.Ast;
|
||||||
const log = std.log.scoped(.zls_inlay_hint);
|
const log = std.log.scoped(.zls_inlay_hint);
|
||||||
const ast = @import("ast.zig");
|
const ast = @import("ast.zig");
|
||||||
@ -64,6 +65,9 @@ const Builder = struct {
|
|||||||
/// `decl_handle` should be a function protototype
|
/// `decl_handle` should be a function protototype
|
||||||
/// writes parameter hints into `builder.hints`
|
/// writes parameter hints into `builder.hints`
|
||||||
fn writeCallHint(builder: *Builder, call: Ast.full.Call, decl_handle: analysis.DeclWithHandle) !void {
|
fn writeCallHint(builder: *Builder, call: Ast.full.Call, decl_handle: analysis.DeclWithHandle) !void {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const handle = builder.handle;
|
const handle = builder.handle;
|
||||||
const tree = handle.tree;
|
const tree = handle.tree;
|
||||||
|
|
||||||
@ -127,6 +131,9 @@ fn writeCallHint(builder: *Builder, call: Ast.full.Call, decl_handle: analysis.D
|
|||||||
|
|
||||||
/// takes parameter nodes from the ast and function parameter names from `Builtin.arguments` and writes parameter hints into `builder.hints`
|
/// takes parameter nodes from the ast and function parameter names from `Builtin.arguments` and writes parameter hints into `builder.hints`
|
||||||
fn writeBuiltinHint(builder: *Builder, parameters: []const Ast.Node.Index, arguments: []const []const u8) !void {
|
fn writeBuiltinHint(builder: *Builder, parameters: []const Ast.Node.Index, arguments: []const []const u8) !void {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const handle = builder.handle;
|
const handle = builder.handle;
|
||||||
const tree = handle.tree;
|
const tree = handle.tree;
|
||||||
|
|
||||||
@ -162,6 +169,9 @@ fn writeBuiltinHint(builder: *Builder, parameters: []const Ast.Node.Index, argum
|
|||||||
|
|
||||||
/// takes a Ast.full.Call (a function call), analysis its function expression, finds its declaration and writes parameter hints into `builder.hints`
|
/// takes a Ast.full.Call (a function call), analysis its function expression, finds its declaration and writes parameter hints into `builder.hints`
|
||||||
fn writeCallNodeHint(builder: *Builder, call: Ast.full.Call) !void {
|
fn writeCallNodeHint(builder: *Builder, call: Ast.full.Call) !void {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
if (call.ast.params.len == 0) return;
|
if (call.ast.params.len == 0) return;
|
||||||
if (builder.config.inlay_hints_exclude_single_argument and call.ast.params.len == 1) return;
|
if (builder.config.inlay_hints_exclude_single_argument and call.ast.params.len == 1) return;
|
||||||
|
|
||||||
@ -280,6 +290,9 @@ pub fn writeRangeInlayHint(
|
|||||||
loc: offsets.Loc,
|
loc: offsets.Loc,
|
||||||
hover_kind: types.MarkupKind,
|
hover_kind: types.MarkupKind,
|
||||||
) error{OutOfMemory}![]InlayHint {
|
) error{OutOfMemory}![]InlayHint {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
var builder: Builder = .{
|
var builder: Builder = .{
|
||||||
.arena = arena,
|
.arena = arena,
|
||||||
.store = store,
|
.store = store,
|
||||||
|
@ -3,6 +3,7 @@ const zig_builtin = @import("builtin");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const Config = @import("Config.zig");
|
const Config = @import("Config.zig");
|
||||||
const ast = @import("ast.zig");
|
const ast = @import("ast.zig");
|
||||||
|
const tracy = @import("tracy.zig");
|
||||||
const Ast = std.zig.Ast;
|
const Ast = std.zig.Ast;
|
||||||
const URI = @import("uri.zig");
|
const URI = @import("uri.zig");
|
||||||
const log = std.log.scoped(.zls_translate_c);
|
const log = std.log.scoped(.zls_translate_c);
|
||||||
@ -24,6 +25,9 @@ const log = std.log.scoped(.zls_translate_c);
|
|||||||
/// #include "GLFW/glfw3.h"
|
/// #include "GLFW/glfw3.h"
|
||||||
/// ```
|
/// ```
|
||||||
pub fn convertCInclude(allocator: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) error{ OutOfMemory, Unsupported }![]const u8 {
|
pub fn convertCInclude(allocator: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) error{ OutOfMemory, Unsupported }![]const u8 {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const main_tokens = tree.nodes.items(.main_token);
|
const main_tokens = tree.nodes.items(.main_token);
|
||||||
|
|
||||||
std.debug.assert(ast.isBuiltinCall(tree, node));
|
std.debug.assert(ast.isBuiltinCall(tree, node));
|
||||||
@ -130,6 +134,9 @@ pub const Result = union(enum) {
|
|||||||
/// null indicates a failure which is automatically logged
|
/// null indicates a failure which is automatically logged
|
||||||
/// Caller owns returned memory.
|
/// Caller owns returned memory.
|
||||||
pub fn translate(allocator: std.mem.Allocator, config: Config, include_dirs: []const []const u8, source: []const u8) error{OutOfMemory}!?Result {
|
pub fn translate(allocator: std.mem.Allocator, config: Config, include_dirs: []const []const u8, source: []const u8) error{OutOfMemory}!?Result {
|
||||||
|
const tracy_zone = tracy.trace(@src());
|
||||||
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const file_path = try std.fs.path.join(allocator, &[_][]const u8{ config.global_cache_path.?, "cimport.h" });
|
const file_path = try std.fs.path.join(allocator, &[_][]const u8{ config.global_cache_path.?, "cimport.h" });
|
||||||
defer allocator.free(file_path);
|
defer allocator.free(file_path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user