This repository was archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathspec.ts
More file actions
168 lines (144 loc) · 4.19 KB
/
spec.ts
File metadata and controls
168 lines (144 loc) · 4.19 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
* The specification used to provide search-based code intelligence for a
* particular language. This includes things like file extensions, comment
* patterns and delimiters, and logic for filtering out obviously wrong
* search results for definitions.
*/
export interface LanguageSpec {
/**
* Used to label markdown code blocks.
*/
languageID: string
/**
* Languages that the extension should be activated for in addition to
* its main language.
*
* @example ["javascript"] for the TypeScript extension.
*/
additionalLanguages?: string[]
/**
* The name of the generated extension.
*/
stylized: string
/**
* The part of the filename after the `.` (e.g. `cpp` in `main.cpp`). This
* used to restrict the definition and reference searches to filenames within
* the same "ecosystem".
*/
fileExts: string[]
/**
* Non-glob filenames that match this language. For example, ["Dockerfile"].
*/
verbatimFilenames?: string[]
/**
* Regex that matches individual characters in an identifier.
*/
identCharPattern?: RegExp
/**
* Instructions on how to parse comments in order to extract docstrings.
*/
commentStyles: CommentStyle[]
/**
* Callback that filters the given symbol search results (e.g. to drop
* results from non-imported files).
*/
filterDefinitions?: FilterDefinitions
/**
* Affects messaging about adding LSIF indexing when hovering over symbols
* from this language.
*/
lsifSupport?: LSIFSupport
/**
* Supports textDocument/implementation Requests
*/
textDocumentImplemenationSupport?: boolean
}
export enum LSIFSupport {
None = 'none',
Experimental = 'experimental',
Robust = 'robust',
}
/**
* Comment patterns and delimiters for a particular language.
*/
export interface CommentStyle {
/**
* Identifies a single-line comment. Also used to prevent jump-to-definition
* into comments (except when the token appears to refer to code).
*
* Python example: `/#\s?/`
*/
lineRegex?: RegExp
/**
* The style of block comments.
*/
block?: BlockCommentStyle
/**
* Specifies where documentation is placed relative to the definition.
* Defaults to `'above the definition'`. In Python, documentation is placed
* `'below the definition'`.
*/
docPlacement?: TextDocumentPlacement
/**
* Regex that matches lines between a definition and the docstring that
* should be ignored. Java example: `/^\s*@/` for class/method annotations.
*/
docstringIgnore?: RegExp
}
/**
* Where a docstring is located relative to a definition.
*/
export type TextDocumentPlacement = 'above the definition' | 'below the definition'
/**
* Block comment delimiter patterns for a particular language.
*/
export interface BlockCommentStyle {
/**
* Matches the start of a block comment. C++ example: `/\/\*\*?/`
*/
startRegex: RegExp
/**
* Matches the end of a block comment. C++ example: `/\*\//`
*/
endRegex: RegExp
/**
* Matches the noise at the beginning of each line in a block comment after
* the start, end, and leading indentation have been stripped. C++ example:
* `/(\s\*\s?)?/`
*/
lineNoiseRegex?: RegExp
}
/**
* A filter function that prunes imprecise definitions from search results.
*/
export type FilterDefinitions = <T extends Result>(results: T[], context: FilterContext) => T[]
/**
* Additional context supplied when filtering search results.
*/
export interface FilterContext {
/**
* The name of the repository containing of the current file.
*/
repo: string
/**
* The path to the current file relative to the repository root.
*/
filePath: string
/**
* The full text content of the current file.
*/
fileContent: string
}
/**
* Result represents a search result returned from the Sourcegraph API.
*/
export interface Result {
/**
* The name of the repository containing the result.
*/
repo: string
/**
* The path to the result file relative to the repository root.
*/
file: string
}