more tracy calls (#1052)

This commit is contained in:
Techatrix 2023-03-11 18:43:14 +00:00 committed by GitHub
parent ff467f9878
commit c203110555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 0 deletions

View File

@ -3046,6 +3046,15 @@ pub fn processMessage(server: *Server, message: Message) Error!void {
const tracy_zone = tracy.trace(@src());
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) {
.RequestMessage => |request| {
if (!requestMethodExists(request.method)) return error.MethodNotFound;

View File

@ -6,6 +6,7 @@ const offsets = @import("offsets.zig");
const URI = @import("uri.zig");
const log = std.log.scoped(.zls_analysis);
const ast = @import("ast.zig");
const tracy = @import("tracy.zig");
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
const InternPool = ComptimeInterpreter.InternPool;
@ -1284,6 +1285,9 @@ pub fn collectImports(allocator: std.mem.Allocator, tree: Ast) error{OutOfMemory
/// Collects all `@cImport` nodes
/// Caller owns returned memory.
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){};
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
lookahead: bool,
) !PositionContext {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var new_index = doc_index;
if (lookahead and new_index < text.len and isSymbolChar(text[new_index])) {
new_index += 1;
@ -2612,6 +2619,9 @@ pub const Scope = struct {
};
pub fn makeDocumentScope(allocator: std.mem.Allocator, tree: Ast) !DocumentScope {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var document_scope = DocumentScope{
.scopes = .{},
.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 {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
const scopes = context.scopes;
const tree = context.tree;
const tags = tree.nodes.items(.tag);

View File

@ -1,6 +1,7 @@
const std = @import("std");
const types = @import("lsp.zig");
const offsets = @import("offsets.zig");
const tracy = @import("tracy.zig");
const DiffMatchPatch = @import("diffz");
const dmp = DiffMatchPatch{
@ -15,6 +16,9 @@ pub fn edits(
after: []const u8,
encoding: offsets.Encoding,
) Error!std.ArrayListUnmanaged(types.TextEdit) {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
var diffs = try dmp.diff(arena.allocator(), before, after, true);
@ -70,6 +74,9 @@ pub fn applyContentChanges(
content_changes: []const types.TextDocumentContentChangeEvent,
encoding: offsets.Encoding,
) ![:0]const u8 {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var last_full_text_change: ?usize = null;
var i: usize = content_changes.len;
while (i > 0) {
@ -111,6 +118,9 @@ pub fn applyTextEdits(
text_edits: []const types.TextEdit,
encoding: offsets.Encoding,
) ![]const u8 {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var text_edits_sortable = try allocator.alloc(types.TextEdit, text_edits.len);
defer allocator.free(text_edits_sortable);

View File

@ -2,6 +2,7 @@ const std = @import("std");
const ast = @import("ast.zig");
const types = @import("lsp.zig");
const offsets = @import("offsets.zig");
const tracy = @import("tracy.zig");
const Ast = std.zig.Ast;
const FoldingRange = struct {
@ -54,6 +55,9 @@ const Builder = struct {
}
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);
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 {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var builder = Builder{
.allocator = allocator,
.locations = .{},

View File

@ -4,6 +4,7 @@ const DocumentStore = @import("DocumentStore.zig");
const analysis = @import("analysis.zig");
const types = @import("lsp.zig");
const offsets = @import("offsets.zig");
const tracy = @import("tracy.zig");
const Ast = std.zig.Ast;
const log = std.log.scoped(.zls_inlay_hint);
const ast = @import("ast.zig");
@ -64,6 +65,9 @@ const Builder = struct {
/// `decl_handle` should be a function protototype
/// writes parameter hints into `builder.hints`
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 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`
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 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`
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 (builder.config.inlay_hints_exclude_single_argument and call.ast.params.len == 1) return;
@ -280,6 +290,9 @@ pub fn writeRangeInlayHint(
loc: offsets.Loc,
hover_kind: types.MarkupKind,
) error{OutOfMemory}![]InlayHint {
const tracy_zone = tracy.trace(@src());
defer tracy_zone.end();
var builder: Builder = .{
.arena = arena,
.store = store,

View File

@ -3,6 +3,7 @@ const zig_builtin = @import("builtin");
const builtin = @import("builtin");
const Config = @import("Config.zig");
const ast = @import("ast.zig");
const tracy = @import("tracy.zig");
const Ast = std.zig.Ast;
const URI = @import("uri.zig");
const log = std.log.scoped(.zls_translate_c);
@ -24,6 +25,9 @@ const log = std.log.scoped(.zls_translate_c);
/// #include "GLFW/glfw3.h"
/// ```
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);
std.debug.assert(ast.isBuiltinCall(tree, node));
@ -130,6 +134,9 @@ pub const Result = union(enum) {
/// null indicates a failure which is automatically logged
/// Caller owns returned memory.
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" });
defer allocator.free(file_path);