Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 10x 10x 7x 7x 3x 15x 15x 3x 3x 5x 5x 5x 5x 5x 5x 4x 3x | import * as vscode from "vscode";
import { Uri } from '@faubulous/mentor-rdf';
import { IToken, RdfToken } from '@faubulous/mentor-rdf-parsers';
import { getTokenPosition } from "@src/utilities";
/**
* Base class of feature providers for Turtle documents.
*/
export class TurtleFeatureProvider {
/**
* Gets the range of a token that contains an editable prefix.
* @param token A token.
* @returns The range of the prefix.
*/
protected getPrefixEditRange(token: IToken) {
const { start } = getTokenPosition(token);
switch (token.tokenType.name) {
case RdfToken.PNAME_NS.name:
case RdfToken.PNAME_LN.name: {
const i = token.image.indexOf(":");
return new vscode.Range(
new vscode.Position(start.line, start.character),
new vscode.Position(start.line, start.character + i)
);
}
default: {
return null;
}
}
}
/**
* Gets the range of a token that contains an editable resource label.
* @param token A token.
* @returns The range of the label.
*/
protected getLabelEditRange(token: IToken) {
const { start, end } = getTokenPosition(token);
switch (token.tokenType.name) {
case RdfToken.PNAME_LN.name: {
const i = token.image.indexOf(":");
return new vscode.Range(
new vscode.Position(start.line, start.character + i + 1),
new vscode.Position(end.line, end.character)
);
}
case RdfToken.IRIREF.name: {
let uri = token.image.trim();
uri = uri.substring(1, uri.length - 1)
const namespace = Uri.getNamespaceIri(uri);
const label = uri.substring(namespace.length);
const i = token.image.indexOf(label);
return new vscode.Range(
new vscode.Position(start.line, start.character + i),
new vscode.Position(end.line, start.character + i + label.length)
);
}
case RdfToken.VAR1.name: {
return new vscode.Range(
new vscode.Position(start.line, start.character + 1),
new vscode.Position(end.line, end.character)
);
}
default: {
return null;
}
}
}
} |