-
Notifications
You must be signed in to change notification settings - Fork 689
/
Copy pathprotocol.ts
992 lines (825 loc) · 24.6 KB
/
protocol.ts
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import {
CompletionTriggerKind,
CompletionItemKind,
CompletionItemTag,
InsertTextFormat,
} from 'vscode-languageserver-protocol';
import {
findNetCoreTargetFramework,
findNetFrameworkTargetFramework,
findNetStandardTargetFramework,
} from '../shared/utils';
export namespace Requests {
export const AddToProject = '/addtoproject';
export const CodeCheck = '/codecheck';
export const CodeFormat = '/codeformat';
export const ChangeBuffer = '/changebuffer';
export const FilesChanged = '/filesChanged';
export const FindSymbols = '/findsymbols';
export const FindUsages = '/findusages';
export const FormatAfterKeystroke = '/formatAfterKeystroke';
export const FormatRange = '/formatRange';
export const GetCodeActions = '/getcodeactions';
export const GoToTypeDefinition = '/gototypedefinition';
export const FindImplementations = '/findimplementations';
export const Project = '/project';
export const Projects = '/projects';
export const RemoveFromProject = '/removefromproject';
export const Rename = '/rename';
export const RunCodeAction = '/runcodeaction';
export const SignatureHelp = '/signatureHelp';
export const TypeLookup = '/typelookup';
export const UpdateBuffer = '/updatebuffer';
export const Metadata = '/metadata';
export const RunFixAll = '/runfixall';
export const GetFixAll = '/getfixall';
export const ReAnalyze = '/reanalyze';
export const QuickInfo = '/quickinfo';
export const Completion = '/completion';
export const CompletionResolve = '/completion/resolve';
export const CompletionAfterInsert = '/completion/afterInsert';
export const SourceGeneratedFile = '/sourcegeneratedfile';
export const UpdateSourceGeneratedFile = '/updatesourcegeneratedfile';
export const SourceGeneratedFileClosed = '/sourcegeneratedfileclosed';
export const InlayHint = '/inlayHint';
export const InlayHintResolve = '/inlayHint/resolve';
export const FileOpen = '/open';
export const FileClose = '/close';
}
export namespace WireProtocol {
export interface Packet {
Type: string;
Seq: number;
}
export interface RequestPacket extends Packet {
Command: string;
Arguments: any;
}
export interface ResponsePacket extends Packet {
Command: string;
Request_seq: number;
Running: boolean;
Success: boolean;
Message: string;
Body: any;
}
export interface EventPacket extends Packet {
Event: string;
Body: any;
}
}
export interface FileBasedRequest {
FileName?: string;
}
export interface Request extends FileBasedRequest {
Line?: number;
Column?: number;
Buffer?: string;
Changes?: LinePositionSpanTextChange[];
ApplyChangesTogether?: boolean;
}
export type FindImplementationsRequest = Request;
export interface LinePositionSpanTextChange {
NewText: string;
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
}
export interface MetadataSource {
AssemblyName: string;
ProjectName: string;
VersionNumber: string;
Language: string;
TypeName: string;
}
export interface MetadataRequest extends MetadataSource {
Timeout?: number;
}
export interface MetadataResponse {
SourceName: string;
Source: string;
}
export interface UpdateBufferRequest extends Request {
FromDisk?: boolean;
}
export interface ChangeBufferRequest {
FileName: string;
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
NewText: string;
}
export type AddToProjectRequest = Request;
export type RemoveFromProjectRequest = Request;
export interface FindUsagesRequest extends Request {
// MaxWidth: number; ?
OnlyThisFile: boolean;
ExcludeDefinition: boolean;
}
export interface FindSymbolsRequest extends Request {
Filter: string;
MaxItemsToReturn?: number;
}
export interface FormatRequest extends Request {
ExpandTab: boolean;
}
export interface CodeActionRequest extends Request {
CodeAction: number;
WantsTextChanges?: boolean;
SelectionStartColumn?: number;
SelectionStartLine?: number;
SelectionEndColumn?: number;
SelectionEndLine?: number;
}
export interface FormatResponse {
Buffer: string;
}
export interface TextChange {
NewText: string;
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
}
export interface FormatAfterKeystrokeRequest extends Request {
Character: string;
}
export interface FormatRangeRequest extends Request {
EndLine: number;
EndColumn: number;
}
export interface FormatRangeResponse {
Changes: TextChange[];
}
export interface ResourceLocation {
FileName: string;
Line: number;
Column: number;
}
export interface Error {
Message: string;
Line: number;
Column: number;
EndLine: number;
EndColumn: number;
FileName: string;
}
export interface ErrorResponse {
Errors: Error[];
}
export interface QuickFix {
LogLevel: string;
FileName: string;
Line: number;
Column: number;
EndLine: number;
EndColumn: number;
Text: string;
Projects: string[];
Tags: string[];
Id: string;
}
export interface SymbolLocation extends QuickFix {
Kind: string;
ContainingSymbolName?: string;
GeneratedFileInfo?: SourceGeneratedFileInfo;
}
export interface QuickFixResponse {
QuickFixes: QuickFix[];
}
export interface FindSymbolsResponse {
QuickFixes: SymbolLocation[];
}
export interface DocumentationItem {
Name: string;
Documentation: string;
}
export interface DocumentationComment {
SummaryText: string;
TypeParamElements: DocumentationItem[];
ParamElements: DocumentationItem[];
ReturnsText: string;
RemarksText: string;
ExampleText: string;
ValueText: string;
Exception: DocumentationItem[];
}
export interface TypeLookupRequest extends Request {
IncludeDocumentation: boolean;
}
export interface TypeLookupResponse {
Type: string;
Documentation: string;
StructuredDocumentation: DocumentationComment;
}
export interface RunCodeActionResponse {
Text: string;
Changes: TextChange[];
}
export interface GetCodeActionsResponse {
CodeActions: string[];
}
export interface RunFixAllActionResponse {
Text: string;
Changes: FileOperationResponse[];
}
export interface FixAllItem {
Id: string;
Message: string;
}
export interface GetFixAllResponse {
Items: FixAllItem[];
}
export interface SyntaxFeature {
Name: string;
Data: string;
}
export interface ProjectInformationResponse {
MsBuildProject: MSBuildProject;
}
export enum BackgroundDiagnosticStatus {
Started = 0,
Progress = 1,
Finished = 2,
}
export interface BackgroundDiagnosticStatusMessage {
Status: BackgroundDiagnosticStatus;
NumberProjects: number;
NumberFilesTotal: number;
NumberFilesRemaining: number;
}
export interface WorkspaceInformationResponse {
MsBuild?: MsBuildWorkspaceInformation;
DotNet?: DotNetWorkspaceInformation;
ScriptCs?: ScriptCsContext;
Cake?: CakeContext;
}
export interface MsBuildWorkspaceInformation {
SolutionPath: string;
Projects: MSBuildProject[];
}
export interface ScriptCsContext {
CsxFiles: { [n: string]: string };
References: { [n: string]: string };
Usings: { [n: string]: string };
ScriptPacks: { [n: string]: string };
Path: string;
}
export interface CakeContext {
Path: string;
}
export interface MSBuildProject {
ProjectGuid: string;
/** Absolute path to the csproj file. */
Path: string;
AssemblyName: string;
/** Absolute path to the output assembly DLL. */
TargetPath: string;
TargetFramework: string;
SourceFiles: string[];
TargetFrameworks: TargetFramework[];
/** Absolute path to the output directory. */
OutputPath: string;
IsExe: boolean;
IsUnityProject: boolean;
IsWebProject: boolean;
IsBlazorWebAssemblyStandalone: boolean;
IsBlazorWebAssemblyHosted: boolean;
}
export interface TargetFramework {
Name: string;
FriendlyName: string;
ShortName: string;
}
export interface DotNetWorkspaceInformation {
Projects: DotNetProject[];
RuntimePath: string;
}
export interface DotNetProject {
Path: string;
Name: string;
ProjectSearchPaths: string[];
Configurations: DotNetConfiguration[];
Frameworks: DotNetFramework[];
SourceFiles: string[];
}
export interface DotNetConfiguration {
Name: string;
CompilationOutputPath: string;
CompilationOutputAssemblyFile: string;
CompilationOutputPdbFile: string;
EmitEntryPoint?: boolean;
}
export interface DotNetFramework {
Name: string;
FriendlyName: string;
ShortName: string;
}
export interface RenameRequest extends Request {
RenameTo: string;
WantsTextChanges?: boolean;
ApplyTextChanges: boolean;
}
export interface FileOperationResponse {
FileName: string;
ModificationType: FileModificationType;
}
export interface ModifiedFileResponse extends FileOperationResponse {
Buffer: string;
Changes: TextChange[];
}
export interface RenamedFileResponse extends FileOperationResponse {
NewFileName: string;
}
export type OpenFileResponse = FileOperationResponse;
export enum FileModificationType {
Modified,
Opened,
Renamed,
}
export interface RenameResponse {
Changes: ModifiedFileResponse[];
}
export interface SignatureHelp {
Signatures: SignatureHelpItem[];
ActiveSignature: number;
ActiveParameter: number;
}
export interface SignatureHelpItem {
Name: string;
Label: string;
Documentation: string;
Parameters: SignatureHelpParameter[];
StructuredDocumentation: DocumentationComment;
}
export interface SignatureHelpParameter {
Name: string;
Label: string;
Documentation: string;
}
export interface MSBuildProjectDiagnostics {
FileName: string;
Warnings: MSBuildDiagnosticsMessage[];
Errors: MSBuildDiagnosticsMessage[];
}
export interface MSBuildDiagnosticsMessage {
LogLevel: string;
FileName: string;
Text: string;
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
}
export interface ErrorMessage {
Text: string;
FileName: string;
Line: number;
Column: number;
}
export interface PackageRestoreMessage {
FileName: string;
Succeeded: boolean;
}
export interface UnresolvedDependenciesMessage {
FileName: string;
UnresolvedDependencies: PackageDependency[];
}
export interface PackageDependency {
Name: string;
Version: string;
}
export interface FilesChangedRequest extends Request {
ChangeType: FileChangeType;
}
export enum FileChangeType {
Change = 'Change',
Create = 'Create',
Delete = 'Delete',
DirectoryDelete = 'DirectoryDelete',
}
export enum FixAllScope {
Document = 'Document',
Project = 'Project',
Solution = 'Solution',
}
export interface GetFixAllRequest extends FileBasedRequest {
Scope: FixAllScope;
FixAllFilter?: FixAllItem[];
}
export interface RunFixAllRequest extends FileBasedRequest {
Scope: FixAllScope;
FixAllFilter?: FixAllItem[];
WantsTextChanges: boolean;
WantsAllCodeActionOperations: boolean;
ApplyChanges: boolean;
}
export type ReAnalyzeRequest = FileBasedRequest;
export type QuickInfoRequest = Request;
export interface QuickInfoResponse {
Markdown?: string;
}
export interface CompletionRequest extends Request {
CompletionTrigger: CompletionTriggerKind;
TriggerCharacter?: string;
}
export interface CompletionResponse {
IsIncomplete: boolean;
Items: OmnisharpCompletionItem[];
}
export interface CompletionResolveRequest {
Item: OmnisharpCompletionItem;
}
export interface CompletionResolveResponse {
Item: OmnisharpCompletionItem;
}
export interface CompletionAfterInsertionRequest {
Item: OmnisharpCompletionItem;
}
export interface CompletionAfterInsertResponse {
Changes?: LinePositionSpanTextChange[];
Line?: number;
Column?: number;
}
export interface OmnisharpCompletionItem {
Label: string;
Kind: CompletionItemKind;
Tags?: CompletionItemTag[];
Detail?: string;
Documentation?: string;
Preselect: boolean;
SortText?: string;
FilterText?: string;
InsertText?: string;
InsertTextFormat?: InsertTextFormat;
TextEdit?: LinePositionSpanTextChange;
CommitCharacters?: string[];
AdditionalTextEdits?: LinePositionSpanTextChange[];
Data: any;
HasAfterInsertStep: boolean;
}
export interface SourceGeneratedFileInfo {
ProjectGuid: string;
DocumentGuid: string;
}
export type SourceGeneratedFileRequest = SourceGeneratedFileInfo;
export interface SourceGeneratedFileResponse {
Source: string;
SourceName: string;
}
export type UpdateSourceGeneratedFileRequest = SourceGeneratedFileInfo;
interface UpdateSourceGeneratedFileNotModifiedResponse {
UpdateType: Exclude<UpdateType, UpdateType.Modified>;
}
interface UpdateSourceGeneratedFileModifiedResponse {
UpdateType: UpdateType.Modified;
Source: string;
}
export type UpdateSourceGeneratedFileResponse =
| UpdateSourceGeneratedFileNotModifiedResponse
| UpdateSourceGeneratedFileModifiedResponse;
export enum UpdateType {
Unchanged,
Deleted,
Modified,
}
export type SourceGeneratedFileClosedRequest = SourceGeneratedFileInfo;
export interface InlayHintRequest {
Location: V2.Location;
}
export interface InlayHint {
Position: V2.Point;
Label: string;
Tooltip?: string;
Data: any;
TextEdits?: LinePositionSpanTextChange[];
}
export interface InlayHintResponse {
InlayHints: InlayHint[];
}
export interface InlayHintResolve {
Hint: InlayHint;
}
export interface Definition {
Location: V2.Location;
MetadataSource?: MetadataSource;
SourceGeneratedFileInfo?: SourceGeneratedFileInfo;
}
export interface GoToTypeDefinitionRequest extends Request {
WantMetadata?: boolean;
}
export interface GoToTypeDefinitionResponse {
Definitions?: Definition[];
}
export namespace V2 {
export namespace Requests {
export const GetCodeActions = '/v2/getcodeactions';
export const RunCodeAction = '/v2/runcodeaction';
export const GetTestStartInfo = '/v2/getteststartinfo';
export const RunTest = '/v2/runtest';
export const RunAllTestsInClass = '/v2/runtestsinclass';
export const RunTestsInContext = '/v2/runtestsincontext';
export const DebugTestGetStartInfo = '/v2/debugtest/getstartinfo';
export const DebugTestsInClassGetStartInfo = '/v2/debugtestsinclass/getstartinfo';
export const DebugTestsInContextGetStartInfo = '/v2/debugtestsincontext/getstartinfo';
export const DebugTestLaunch = '/v2/debugtest/launch';
export const DebugTestStop = '/v2/debugtest/stop';
export const DiscoverTests = '/v2/discovertests';
export const BlockStructure = '/v2/blockstructure';
export const CodeStructure = '/v2/codestructure';
export const Highlight = '/v2/highlight';
export const GoToDefinition = '/v2/gotodefinition';
}
export interface SemanticHighlightSpan {
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
Type: number;
Modifiers: number[];
}
export interface SemanticHighlightRequest extends Request {
Range?: Range;
VersionedText?: string;
}
export interface SemanticHighlightResponse {
Spans: SemanticHighlightSpan[];
}
export interface Point {
Line: number;
Column: number;
}
export interface Range {
Start: Point;
End: Point;
}
export interface Location {
FileName: string;
Range: Range;
}
export interface GetCodeActionsRequest extends Request {
Selection?: Range;
}
export interface OmniSharpCodeAction {
Identifier: string;
Name: string;
CodeActionKind?: string;
}
export interface GetCodeActionsResponse {
CodeActions: OmniSharpCodeAction[];
}
export interface RunCodeActionRequest extends Request {
Identifier: string;
Selection?: Range;
WantsTextChanges: boolean;
WantsAllCodeActionOperations: boolean;
ApplyTextChanges: boolean;
}
export interface RunCodeActionResponse {
Changes: FileOperationResponse[];
}
export interface MSBuildProjectDiagnostics {
FileName: string;
Warnings: MSBuildDiagnosticsMessage[];
Errors: MSBuildDiagnosticsMessage[];
}
export interface MSBuildDiagnosticsMessage {
LogLevel: string;
FileName: string;
Text: string;
StartLine: number;
StartColumn: number;
EndLine: number;
EndColumn: number;
}
export interface ErrorMessage {
Text: string;
FileName: string;
Line: number;
Column: number;
}
export interface PackageRestoreMessage {
FileName: string;
Succeeded: boolean;
}
export interface UnresolvedDependenciesMessage {
FileName: string;
UnresolvedDependencies: PackageDependency[];
}
export interface PackageDependency {
Name: string;
Version: string;
}
// dotnet-test endpoints
interface BaseTestRequest extends Request {
RunSettings?: string;
TestFrameworkName: string;
TargetFrameworkVersion?: string;
NoBuild?: boolean;
}
interface SingleTestRequest extends BaseTestRequest {
MethodName: string;
}
interface MultiTestRequest extends BaseTestRequest {
MethodNames: string[];
}
interface TestsInContextRequest extends Request {
RunSettings?: string;
TargetFrameworkVersion?: string;
}
export type DebugTestGetStartInfoRequest = SingleTestRequest;
export type DebugTestClassGetStartInfoRequest = MultiTestRequest;
export interface DebugTestGetStartInfoResponse {
FileName: string;
Arguments: string;
WorkingDirectory: string;
EnvironmentVariables: Map<string, string>;
Succeeded: boolean;
ContextHadNoTests: boolean;
FailureReason?: string;
}
export interface DebugTestLaunchRequest extends Request {
TargetProcessId: number;
}
export type DebugTestStopRequest = Request;
export type DiscoverTestsRequest = BaseTestRequest;
export interface TestInfo {
FullyQualifiedName: string;
DisplayName: string;
Source: string;
CodeFilePath: string;
LineNumber: number;
}
export interface DiscoverTestsResponse {
Tests: TestInfo[];
}
export type GetTestStartInfoRequest = SingleTestRequest;
export interface GetTestStartInfoResponse {
Executable: string;
Argument: string;
WorkingDirectory: string;
}
export type RunTestRequest = SingleTestRequest;
export type RunTestsInClassRequest = MultiTestRequest;
export type RunTestsInContextRequest = TestsInContextRequest;
export type DebugTestsInContextGetStartInfoRequest = TestsInContextRequest;
export namespace TestOutcomes {
export const None = 'none';
export const Passed = 'passed';
export const Failed = 'failed';
export const Skipped = 'skipped';
export const NotFound = 'notfound';
}
export interface DotNetTestResult {
MethodName: string;
Outcome: string;
ErrorMessage: string;
ErrorStackTrace: string;
StandardOutput: string[];
StandardError: string[];
}
export interface RunTestResponse {
Failure: string;
Pass: boolean;
Results: DotNetTestResult[];
ContextHadNoTests: boolean;
}
export interface TestMessageEvent {
MessageLevel: string;
Message: string;
}
export interface BlockStructureRequest {
FileName: string;
}
export interface BlockStructureResponse {
Spans: CodeFoldingBlock[];
}
export interface CodeFoldingBlock {
Range: Range;
Kind: string;
}
export namespace SymbolKinds {
// types
export const Class = 'class';
export const Delegate = 'delegate';
export const Enum = 'enum';
export const Interface = 'interface';
export const Struct = 'struct';
// members
export const Constant = 'constant';
export const Constructor = 'constructor';
export const Destructor = 'destructor';
export const EnumMember = 'enummember';
export const Event = 'event';
export const Field = 'field';
export const Indexer = 'indexer';
export const Method = 'method';
export const Operator = 'operator';
export const Property = 'property';
// other
export const Namespace = 'namespace';
export const Unknown = 'unknown';
}
export namespace SymbolAccessibilities {
export const Internal = 'internal';
export const Private = 'private';
export const PrivateProtected = 'private protected';
export const Protected = 'protected';
export const ProtectedInternal = 'protected internal';
export const Public = 'public';
}
export namespace SymbolPropertyNames {
export const Accessibility = 'accessibility';
export const Static = 'static';
export const TestFramework = 'testFramework';
export const TestMethodName = 'testMethodName';
}
export namespace SymbolRangeNames {
export const Attributes = 'attributes';
export const Full = 'full';
export const Name = 'name';
}
export namespace Structure {
export interface CodeElement {
Kind: string;
Name: string;
DisplayName: string;
Children?: CodeElement[];
Ranges: { [name: string]: Range };
Properties?: { [name: string]: any };
}
export type CodeStructureRequest = FileBasedRequest;
export interface CodeStructureResponse {
Elements?: CodeElement[];
}
export function walkCodeElements(
elements: CodeElement[],
action: (element: CodeElement, parentElement?: CodeElement) => void
) {
function walker(elements: CodeElement[], parentElement?: CodeElement) {
for (const element of elements) {
action(element, parentElement);
if (element.Children) {
walker(element.Children, element);
}
}
}
walker(elements);
}
}
export interface GoToDefinitionRequest extends Request {
WantMetadata?: boolean;
}
export interface GoToDefinitionResponse {
Definitions?: Definition[];
}
export interface Definition {
Location: Location;
MetadataSource?: MetadataSource;
SourceGeneratedFileInfo?: SourceGeneratedFileInfo;
}
}
export function isDotNetCoreProject(project: MSBuildProject): boolean {
const tfms = project.TargetFrameworks.map((tf) => tf.ShortName);
return (
findNetCoreTargetFramework(tfms) !== undefined ||
findNetStandardTargetFramework(tfms) !== undefined ||
findNetFrameworkTargetFramework(tfms) !== undefined
);
}
export interface ProjectDescriptor {
Name: string;
Directory: string;
FilePath: string;
}
export function getDotNetCoreProjectDescriptors(info: WorkspaceInformationResponse): ProjectDescriptor[] {
const result = [];
if (info.DotNet && info.DotNet.Projects.length > 0) {
for (const project of info.DotNet.Projects) {
result.push({
Name: project.Name,
Directory: project.Path,
FilePath: path.join(project.Path, 'project.json'),
});
}
}
if (info.MsBuild && info.MsBuild.Projects.length > 0) {
for (const project of info.MsBuild.Projects) {
if (isDotNetCoreProject(project)) {
result.push({
Name: path.basename(project.Path),
Directory: path.dirname(project.Path),
FilePath: project.Path,
});
}
}
}
return result;
}