-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLspHook.ff
155 lines (147 loc) · 3.99 KB
/
LspHook.ff
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
import Syntax
import Unification
import Environment
class LspHook(
at: Location
definedAt: Location
insertIdentifier: Bool
stackOfResults: Stack[ResultHook]
)
disabled(): LspHook {
make(None, None, False)
}
make(at: Option[Location], definedAt: Option[Location], insertIdentifier: Bool): LspHook {
LspHook( // Default dummy values instead of Option[Location] to speed up location hit check
at = at.else {Location("^lsp", -7, -7)}
definedAt = definedAt.else {Location("^lsp", -7, -7)}
insertIdentifier = insertIdentifier
stackOfResults = [].toStack()
)
}
extend self: LspHook {
isEnabled(): Bool {
self.at.line != -7 ||
self.definedAt.line != -7
}
isAt(at: Location): Bool {
self.at.line == at.line &&
self.at.column == at.column &&
self.at.file == at.file
}
isDefinedAt(at: Location): Bool {
self.definedAt.line == at.line &&
self.definedAt.column == at.column &&
self.definedAt.file == at.file
}
emit(result: ResultHook) {
self.stackOfResults.push(result)
}
results(): List[ResultHook] {
self.stackOfResults.toList()
}
}
strictlyBetween(afterAt: Location, beforeAt: Location, at: Location, extraColumns: Int): Bool {
at.file == afterAt.file && (
(at.line == afterAt.line && at.column > afterAt.column) ||
at.line > afterAt.line
) && (
(at.line == beforeAt.line && at.column < beforeAt.column + extraColumns) ||
at.line < beforeAt.line
)
}
data SymbolHook(
qualifiedName: String
usageAt: Location
definedAt: Location
)
class Box[T](mutable value: T)
class ResultHook {
ParseArgumentHook(
callAt: Location
argumentIndex: Int
parameterName: Option[String]
)
ResolveSymbolHook(
symbol: SymbolHook
annotation: Option[Type]
)
ResolveTypeHook(
types: Map[String, String]
typeGenerics: Map[String, List[String]]
symbol: SymbolHook
explicitType: Type
)
ResolveConstraintHook(
symbol: SymbolHook
constrant: Constraint
)
ResolveSignatureHook(
signature: Signature
)
ResolveVariantFieldHook(
symbol: SymbolHook
type: Type
commonField: Bool
)
InferTermHook(
unification: Unification
environment: Environment
expected: Type
term: Term
recordType: Box[Option[Type]]
missing: StringMap[Pair[Instantiated, Option[List[Argument]]]]
)
InferLambdaStartHook(
unification: Unification
environment: Environment
lambdaType: Type
)
InferSequentialStartHook(
unification: Unification
term: Term
missing: StringMap[Pair[Instantiated, Option[List[Argument]]]]
)
InferFunctionDefinitionHook(
unification: Unification
environment: Environment
definition: DFunction
missing: StringMap[Pair[Instantiated, Option[List[Argument]]]]
)
InferPatternHook(
unification: Unification
environment: Environment
expected: Type
pattern: MatchPattern
)
InferParameterHook(
unification: Unification
environment: Environment
parameter: Parameter
missing: StringMap[Pair[Instantiated, Option[List[Argument]]]]
)
InferArgumentHook(
unification: Unification
environment: Environment
isCopy: Bool
callAt: Location
callName: String
parameters: List[Parameter]
arguments: List[Argument]
argumentIndex: Int
)
InferLookupHook(
unification: Unification
environment: Environment
expected: Type
selfVariable: Option[String]
symbol: Box[SymbolHook]
instantiated: Box[Option[Instantiated]]
)
InferRecordFieldHook(
unification: Unification
environment: Environment
expected: Type
recordType: Type
fieldName: String
)
}