@@ -2174,7 +2174,7 @@ namespace FourSlash {
2174
2174
}
2175
2175
2176
2176
ts . zipWith ( expected , actual , ( expectedClassification , actualClassification ) => {
2177
- const expectedType : string = ( < any > ts . ClassificationTypeNames ) [ expectedClassification . classificationType ] ;
2177
+ const expectedType = expectedClassification . classificationType ;
2178
2178
if ( expectedType !== actualClassification . classificationType ) {
2179
2179
this . raiseError ( "verifyClassifications failed - expected classifications type to be " +
2180
2180
expectedType + ", but was " +
@@ -3876,7 +3876,7 @@ namespace FourSlashInterface {
3876
3876
/**
3877
3877
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
3878
3878
*/
3879
- public semanticClassificationsAre ( ...classifications : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } [ ] ) {
3879
+ public semanticClassificationsAre ( ...classifications : Classification [ ] ) {
3880
3880
this . state . verifySemanticClassifications ( classifications ) ;
3881
3881
}
3882
3882
@@ -4071,102 +4071,107 @@ namespace FourSlashInterface {
4071
4071
}
4072
4072
}
4073
4073
4074
+ interface Classification {
4075
+ classificationType : ts . ClassificationTypeNames ;
4076
+ text : string ;
4077
+ textSpan ?: FourSlash . TextSpan ;
4078
+ }
4074
4079
export namespace Classification {
4075
- export function comment ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4076
- return getClassification ( " comment" , text , position ) ;
4080
+ export function comment ( text : string , position ?: number ) : Classification {
4081
+ return getClassification ( ts . ClassificationTypeNames . comment , text , position ) ;
4077
4082
}
4078
4083
4079
- export function identifier ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4080
- return getClassification ( " identifier" , text , position ) ;
4084
+ export function identifier ( text : string , position ?: number ) : Classification {
4085
+ return getClassification ( ts . ClassificationTypeNames . identifier , text , position ) ;
4081
4086
}
4082
4087
4083
- export function keyword ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4084
- return getClassification ( " keyword" , text , position ) ;
4088
+ export function keyword ( text : string , position ?: number ) : Classification {
4089
+ return getClassification ( ts . ClassificationTypeNames . keyword , text , position ) ;
4085
4090
}
4086
4091
4087
- export function numericLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4088
- return getClassification ( " numericLiteral" , text , position ) ;
4092
+ export function numericLiteral ( text : string , position ?: number ) : Classification {
4093
+ return getClassification ( ts . ClassificationTypeNames . numericLiteral , text , position ) ;
4089
4094
}
4090
4095
4091
- export function operator ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4092
- return getClassification ( " operator" , text , position ) ;
4096
+ export function operator ( text : string , position ?: number ) : Classification {
4097
+ return getClassification ( ts . ClassificationTypeNames . operator , text , position ) ;
4093
4098
}
4094
4099
4095
- export function stringLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4096
- return getClassification ( " stringLiteral" , text , position ) ;
4100
+ export function stringLiteral ( text : string , position ?: number ) : Classification {
4101
+ return getClassification ( ts . ClassificationTypeNames . stringLiteral , text , position ) ;
4097
4102
}
4098
4103
4099
- export function whiteSpace ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4100
- return getClassification ( " whiteSpace" , text , position ) ;
4104
+ export function whiteSpace ( text : string , position ?: number ) : Classification {
4105
+ return getClassification ( ts . ClassificationTypeNames . whiteSpace , text , position ) ;
4101
4106
}
4102
4107
4103
- export function text ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4104
- return getClassification ( " text" , text , position ) ;
4108
+ export function text ( text : string , position ?: number ) : Classification {
4109
+ return getClassification ( ts . ClassificationTypeNames . text , text , position ) ;
4105
4110
}
4106
4111
4107
- export function punctuation ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4108
- return getClassification ( " punctuation" , text , position ) ;
4112
+ export function punctuation ( text : string , position ?: number ) : Classification {
4113
+ return getClassification ( ts . ClassificationTypeNames . punctuation , text , position ) ;
4109
4114
}
4110
4115
4111
- export function docCommentTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4112
- return getClassification ( " docCommentTagName" , text , position ) ;
4116
+ export function docCommentTagName ( text : string , position ?: number ) : Classification {
4117
+ return getClassification ( ts . ClassificationTypeNames . docCommentTagName , text , position ) ;
4113
4118
}
4114
4119
4115
- export function className ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4116
- return getClassification ( " className" , text , position ) ;
4120
+ export function className ( text : string , position ?: number ) : Classification {
4121
+ return getClassification ( ts . ClassificationTypeNames . className , text , position ) ;
4117
4122
}
4118
4123
4119
- export function enumName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4120
- return getClassification ( " enumName" , text , position ) ;
4124
+ export function enumName ( text : string , position ?: number ) : Classification {
4125
+ return getClassification ( ts . ClassificationTypeNames . enumName , text , position ) ;
4121
4126
}
4122
4127
4123
- export function interfaceName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4124
- return getClassification ( " interfaceName" , text , position ) ;
4128
+ export function interfaceName ( text : string , position ?: number ) : Classification {
4129
+ return getClassification ( ts . ClassificationTypeNames . interfaceName , text , position ) ;
4125
4130
}
4126
4131
4127
- export function moduleName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4128
- return getClassification ( " moduleName" , text , position ) ;
4132
+ export function moduleName ( text : string , position ?: number ) : Classification {
4133
+ return getClassification ( ts . ClassificationTypeNames . moduleName , text , position ) ;
4129
4134
}
4130
4135
4131
- export function typeParameterName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4132
- return getClassification ( " typeParameterName" , text , position ) ;
4136
+ export function typeParameterName ( text : string , position ?: number ) : Classification {
4137
+ return getClassification ( ts . ClassificationTypeNames . typeParameterName , text , position ) ;
4133
4138
}
4134
4139
4135
- export function parameterName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4136
- return getClassification ( " parameterName" , text , position ) ;
4140
+ export function parameterName ( text : string , position ?: number ) : Classification {
4141
+ return getClassification ( ts . ClassificationTypeNames . parameterName , text , position ) ;
4137
4142
}
4138
4143
4139
- export function typeAliasName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4140
- return getClassification ( " typeAliasName" , text , position ) ;
4144
+ export function typeAliasName ( text : string , position ?: number ) : Classification {
4145
+ return getClassification ( ts . ClassificationTypeNames . typeAliasName , text , position ) ;
4141
4146
}
4142
4147
4143
- export function jsxOpenTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4144
- return getClassification ( " jsxOpenTagName" , text , position ) ;
4148
+ export function jsxOpenTagName ( text : string , position ?: number ) : Classification {
4149
+ return getClassification ( ts . ClassificationTypeNames . jsxOpenTagName , text , position ) ;
4145
4150
}
4146
4151
4147
- export function jsxCloseTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4148
- return getClassification ( " jsxCloseTagName" , text , position ) ;
4152
+ export function jsxCloseTagName ( text : string , position ?: number ) : Classification {
4153
+ return getClassification ( ts . ClassificationTypeNames . jsxCloseTagName , text , position ) ;
4149
4154
}
4150
4155
4151
- export function jsxSelfClosingTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4152
- return getClassification ( " jsxSelfClosingTagName" , text , position ) ;
4156
+ export function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
4157
+ return getClassification ( ts . ClassificationTypeNames . jsxSelfClosingTagName , text , position ) ;
4153
4158
}
4154
4159
4155
- export function jsxAttribute ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4156
- return getClassification ( " jsxAttribute" , text , position ) ;
4160
+ export function jsxAttribute ( text : string , position ?: number ) : Classification {
4161
+ return getClassification ( ts . ClassificationTypeNames . jsxAttribute , text , position ) ;
4157
4162
}
4158
4163
4159
- export function jsxText ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4160
- return getClassification ( " jsxText" , text , position ) ;
4164
+ export function jsxText ( text : string , position ?: number ) : Classification {
4165
+ return getClassification ( ts . ClassificationTypeNames . jsxText , text , position ) ;
4161
4166
}
4162
4167
4163
- export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4164
- return getClassification ( " jsxAttributeStringLiteralValue" , text , position ) ;
4168
+ export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
4169
+ return getClassification ( ts . ClassificationTypeNames . jsxAttributeStringLiteralValue , text , position ) ;
4165
4170
}
4166
4171
4167
- function getClassification ( type : string , text : string , position ?: number ) {
4172
+ function getClassification ( classificationType : ts . ClassificationTypeNames , text : string , position ?: number ) : Classification {
4168
4173
return {
4169
- classificationType : type ,
4174
+ classificationType,
4170
4175
text : text ,
4171
4176
textSpan : position === undefined ? undefined : { start : position , end : position + text . length }
4172
4177
} ;
0 commit comments