summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-language-server-ast-lookup.h
blob: 6d9d3be6cafa1023960b5091b19307d9b504b279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include "slang-ast-all.h"
#include "slang-workspace-version.h"

namespace Slang
{
struct ASTLookupResult
{
    List<SyntaxNode*> path;
};
enum class ASTLookupType
{
    Decl,
    Invoke,
    CompletionRequest,
};

struct Loc
{
    Int line;
    Int col;
    bool operator<(const Loc& other)
    {
        return line < other.line || line == other.line && col < other.col;
    }
    bool operator<=(const Loc& other)
    {
        return line < other.line || line == other.line && col <= other.col;
    }
    static Loc fromSourceLoc(SourceManager* manager, SourceLoc loc, String* outFileName = nullptr);
};
List<ASTLookupResult> findASTNodesAt(
    DocumentVersion* doc,
    SourceManager* sourceManager,
    ModuleDecl* moduleDecl,
    ASTLookupType findType,
    UnownedStringSlice fileName,
    Int line,
    Int col);

} // namespace Slang