1
1
2
- import { Position , Range , TextDocument , Uri } from "vscode" ;
2
+ import { CancellationToken , Position , Range , TextDocument , Uri } from "vscode" ;
3
3
import * as cachedEntities from "../features/cachedEntities" ;
4
4
import { getComponent , hasComponent } from "../features/cachedEntities" ;
5
5
import { MySet } from "../utils/collections" ;
@@ -159,23 +159,25 @@ export interface ComponentsByName {
159
159
/**
160
160
* Determines whether the given document is a script-based component
161
161
* @param document The document to check
162
+ * @param _token
162
163
* @returns
163
164
*/
164
- export function isScriptComponent ( document : TextDocument ) : boolean {
165
+ export function isScriptComponent ( document : TextDocument , _token : CancellationToken ) : boolean {
165
166
const componentTagMatch : RegExpExecArray = COMPONENT_TAG_PATTERN . exec ( document . getText ( ) ) ;
166
167
if ( componentTagMatch ) {
167
168
return false ;
168
169
}
169
170
170
- return isCfcFile ( document ) ;
171
+ return isCfcFile ( document , _token ) ;
171
172
}
172
173
173
174
/**
174
175
* Parses a component document and returns an object conforming to the Component interface
175
176
* @param documentStateContext The context information for a TextDocument to be parsed
177
+ * @param _token
176
178
* @returns
177
179
*/
178
- export async function parseComponent ( documentStateContext : DocumentStateContext ) : Promise < Component | undefined > {
180
+ export async function parseComponent ( documentStateContext : DocumentStateContext , _token : CancellationToken ) : Promise < Component | undefined > {
179
181
const document : TextDocument = documentStateContext . document ;
180
182
const documentText : string = document . getText ( ) ;
181
183
const componentIsScript : boolean = documentStateContext . docIsScript ;
@@ -348,8 +350,8 @@ export async function parseComponent(documentStateContext: DocumentStateContext)
348
350
349
351
documentStateContext . component = component ;
350
352
const componentFunctions = new ComponentFunctions ( ) ;
351
- let userFunctions : UserFunction [ ] = parseScriptFunctions ( documentStateContext ) ;
352
- userFunctions = userFunctions . concat ( parseTagFunctions ( documentStateContext ) ) ;
353
+ let userFunctions : UserFunction [ ] = parseScriptFunctions ( documentStateContext , _token ) ;
354
+ userFunctions = userFunctions . concat ( parseTagFunctions ( documentStateContext , _token ) ) ;
353
355
let earliestFunctionRangeStart : Position = document . positionAt ( documentText . length ) ;
354
356
userFunctions . forEach ( ( compFun : UserFunction ) => {
355
357
if ( compFun . location . range . start . isBefore ( earliestFunctionRangeStart ) ) {
@@ -382,7 +384,7 @@ export async function parseComponent(documentStateContext: DocumentStateContext)
382
384
383
385
// Only check before first function definition
384
386
const componentDefinitionRange = new Range ( document . positionAt ( componentMatch . index + head . length ) , earliestFunctionRangeStart ) ;
385
- component . variables = await parseVariableAssignments ( documentStateContext , componentIsScript , componentDefinitionRange ) ;
387
+ component . variables = await parseVariableAssignments ( documentStateContext , componentIsScript , componentDefinitionRange , _token ) ;
386
388
387
389
// TODO: Get imports
388
390
@@ -537,9 +539,10 @@ export function getApplicationUri(baseUri: Uri): Uri | undefined {
537
539
/**
538
540
* Finds the applicable Server file for the given file URI
539
541
* @param baseUri The URI from which the Server file will be searched
542
+ * @param _token
540
543
* @returns
541
544
*/
542
- export function getServerUri ( baseUri : Uri ) : Uri | undefined {
545
+ export function getServerUri ( baseUri : Uri , _token : CancellationToken ) : Uri | undefined {
543
546
let componentUri : Uri ;
544
547
545
548
const fileName = "Server.cfc" ;
@@ -548,7 +551,7 @@ export function getServerUri(baseUri: Uri): Uri | undefined {
548
551
if ( rootPath ) {
549
552
const rootUri : Uri = Uri . file ( rootPath ) ;
550
553
551
- if ( hasComponent ( rootUri ) ) {
554
+ if ( hasComponent ( rootUri , _token ) ) {
552
555
componentUri = rootUri ;
553
556
}
554
557
}
@@ -562,16 +565,17 @@ export function getServerUri(baseUri: Uri): Uri | undefined {
562
565
* Checks whether `checkComponent` is a subcomponent or equal to `baseComponent`
563
566
* @param checkComponent The candidate subcomponent
564
567
* @param baseComponent The candidate base component
568
+ * @param _token
565
569
* @returns
566
570
*/
567
- export function isSubcomponentOrEqual ( checkComponent : Component , baseComponent : Component ) : boolean {
571
+ export function isSubcomponentOrEqual ( checkComponent : Component , baseComponent : Component , _token : CancellationToken ) : boolean {
568
572
while ( checkComponent ) {
569
573
if ( checkComponent . uri . toString ( ) === baseComponent . uri . toString ( ) ) {
570
574
return true ;
571
575
}
572
576
573
577
if ( checkComponent . extends ) {
574
- checkComponent = getComponent ( checkComponent . extends ) ;
578
+ checkComponent = getComponent ( checkComponent . extends , _token ) ;
575
579
} else {
576
580
checkComponent = undefined ;
577
581
}
@@ -584,11 +588,12 @@ export function isSubcomponentOrEqual(checkComponent: Component, baseComponent:
584
588
* Checks whether `checkComponent` is a subcomponent of `baseComponent`
585
589
* @param checkComponent The candidate subcomponent
586
590
* @param baseComponent The candidate base component
591
+ * @param _token
587
592
* @returns
588
593
*/
589
- export function isSubcomponent ( checkComponent : Component , baseComponent : Component ) : boolean {
594
+ export function isSubcomponent ( checkComponent : Component , baseComponent : Component , _token : CancellationToken ) : boolean {
590
595
if ( checkComponent . extends ) {
591
- checkComponent = getComponent ( checkComponent . extends ) ;
596
+ checkComponent = getComponent ( checkComponent . extends , _token ) ;
592
597
} else {
593
598
return false ;
594
599
}
@@ -599,7 +604,7 @@ export function isSubcomponent(checkComponent: Component, baseComponent: Compone
599
604
}
600
605
601
606
if ( checkComponent . extends ) {
602
- checkComponent = getComponent ( checkComponent . extends ) ;
607
+ checkComponent = getComponent ( checkComponent . extends , _token ) ;
603
608
} else {
604
609
checkComponent = undefined ;
605
610
}
0 commit comments