-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathBscPlugin.ts
More file actions
68 lines (57 loc) · 2.68 KB
/
Copy pathBscPlugin.ts
File metadata and controls
68 lines (57 loc) · 2.68 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
import { isBrsFile, isXmlFile } from '../astUtils/reflection';
import type { BeforeFileTranspileEvent, CompilerPlugin, OnFileValidateEvent, OnGetCodeActionsEvent, ProvideHoverEvent, OnGetSemanticTokensEvent, OnScopeValidateEvent, ProvideCompletionsEvent, ProvideReferencesEvent } from '../interfaces';
import type { Program } from '../Program';
import { CodeActionsProcessor } from './codeActions/CodeActionsProcessor';
import { CompletionsProcessor } from './completions/CompletionsProcessor';
import { HoverProcessor } from './hover/HoverProcessor';
import { ReferencesProcessor } from './references/ReferencesProcessor';
import { BrsFileSemanticTokensProcessor } from './semanticTokens/BrsFileSemanticTokensProcessor';
import { BrsFilePreTranspileProcessor } from './transpile/BrsFilePreTranspileProcessor';
import { BrsFileValidator } from './validation/BrsFileValidator';
import { ProgramValidator } from './validation/ProgramValidator';
import { ScopeValidator } from './validation/ScopeValidator';
import { XmlFileValidator } from './validation/XmlFileValidator';
export class BscPlugin implements CompilerPlugin {
public name = 'BscPlugin';
public onGetCodeActions(event: OnGetCodeActionsEvent) {
new CodeActionsProcessor(event).process();
}
public provideHover(event: ProvideHoverEvent) {
return new HoverProcessor(event).process();
}
public provideCompletions(event: ProvideCompletionsEvent) {
new CompletionsProcessor(event).process();
}
/**
* Handle the "find all references" event
*/
public provideReferences(event: ProvideReferencesEvent) {
new ReferencesProcessor(event).process();
}
public onGetSemanticTokens(event: OnGetSemanticTokensEvent) {
if (isBrsFile(event.file)) {
return new BrsFileSemanticTokensProcessor(event as any).process();
}
}
public onFileValidate(event: OnFileValidateEvent) {
if (isBrsFile(event.file)) {
return new BrsFileValidator(event as any).process();
} else if (isXmlFile(event.file)) {
return new XmlFileValidator(event as any).process();
}
}
private scopeValidator = new ScopeValidator();
public onScopeValidate(event: OnScopeValidateEvent) {
this.scopeValidator.processEvent(event);
}
public afterProgramValidate(program: Program) {
new ProgramValidator(program).process();
//release memory once the validation cycle has finished
this.scopeValidator.reset();
}
public beforeFileTranspile(event: BeforeFileTranspileEvent) {
if (isBrsFile(event.file)) {
return new BrsFilePreTranspileProcessor(event as any).process();
}
}
}