mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
[json] language server & client as extension
This commit is contained in:
37
extensions/json/server/src/jsonLocation.ts
Normal file
37
extensions/json/server/src/jsonLocation.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
export class JSONLocation {
|
||||
private segments: string[];
|
||||
|
||||
constructor(segments: string[]) {
|
||||
this.segments = segments;
|
||||
}
|
||||
|
||||
public append(segment: string): JSONLocation {
|
||||
return new JSONLocation(this.segments.concat(segment));
|
||||
}
|
||||
|
||||
public getSegments() {
|
||||
return this.segments;
|
||||
}
|
||||
|
||||
public matches(segments: string[]) {
|
||||
let k = 0;
|
||||
for (let i = 0; k < segments.length && i < this.segments.length; i++) {
|
||||
if (segments[k] === this.segments[i] || segments[k] === '*') {
|
||||
k++;
|
||||
} else if (segments[k] !== '**') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return k === segments.length;
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
return '[' + this.segments.join('][') + ']';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user