当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Range.create方法代码示例

本文整理汇总了TypeScript中vscode-languageserver.Range.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Range.create方法的具体用法?TypeScript Range.create怎么用?TypeScript Range.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode-languageserver.Range的用法示例。


在下文中一共展示了Range.create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: build

	static build(node: SyntaxNode): DocumentSymbol | DocumentSymbol[] | void {
		const symbolKind = SYMBOLKINDS[node.type];
		if (!symbolKind) return;

		let symbol = new DocumentSymbol();
		symbol.range = Range.create(
			Position.fromTSPosition(node.startPosition).toVSPosition(),
			Position.fromTSPosition(node.endPosition).toVSPosition()
		);
		symbol.kind = symbolKind;

		if (isWrapper(node)) {
			if (!node.childCount) return;
			const identifierNode = node.descendantsOfType(IDENTIFIER_NODES[node.type])[0];
			if (identifierNode) {
				symbol.children = [];
				symbol.name = identifierNode.text;
				if (symbol.name === 'initialize') {
					symbol.kind = SymbolKind.Constructor;
				}

				// detect attr_ method calls
				if (symbol.name.indexOf('attr_') === 0) {
					const argumentList = node.descendantsOfType('argument_list')[0];
					const symbols = [];
					for (const child of argumentList.children) {
						if (!child.isNamed) continue;
						const newSymbol = {
							...symbol,
						};
						newSymbol.name = child.text[0] === ':' ? child.text.substring(1) : child.text;
						newSymbol.selectionRange = Range.create(
							Position.fromTSPosition(child.startPosition).toVSPosition(),
							Position.fromTSPosition(child.endPosition).toVSPosition()
						);

						symbols.push(newSymbol);
					}

					return symbols;
				} else if (node.type !== 'method_call') {
					symbol.selectionRange = Range.create(
						Position.fromTSPosition(identifierNode.startPosition).toVSPosition(),
						Position.fromTSPosition(identifierNode.endPosition).toVSPosition()
					);
				} else {
					return;
				}
			} else {
				return;
			}
		} else {
			symbol.selectionRange = symbol.range;
			symbol.name = node.text;
		}

		return symbol;
	}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:58,代码来源:RubyDocumentSymbol.ts

示例2: createLineReferenceFromSourceMap

  return lodash.flatten(queryResults.map((queryResult) => {
    const lineReference = createLineReferenceFromSourceMap(
      lodash.get(queryResult, refractSymbol.sourceMapPath, []),
      document,
      documentLines
    );

    let results = {};
    const description = lodash.get(queryResult, refractSymbol.descriptionPath, '');

    const lodashChain =
      lodash
        .chain(refractSymbol.childs)
        .map((child) => {
          return extractSymbols(queryResult, document, documentLines, child, description);
        })
        .flatten()

    if (!lodash.isEmpty(lineReference)) {
      results = SymbolInformation.create(
        description,
        refractSymbol.symbol,
        Range.create(lineReference.startRow, lineReference.startIndex, lineReference.endRow, lineReference.endIndex),
        null,
        containerName);

      return lodashChain.concat(results).value();
    }

    return lodashChain.value();

  }));
开发者ID:smizell,项目名称:vscode-apielements,代码行数:32,代码来源:refractUtils.ts

示例3: getFoldingRanges

export function getFoldingRanges(languageModes: LanguageModes, document: TextDocument, maxRanges: number | undefined, _cancellationToken: CancellationToken | null): FoldingRange[] {
	let htmlMode = languageModes.getMode('html');
	let range = Range.create(Position.create(0, 0), Position.create(document.lineCount, 0));
	let result: FoldingRange[] = [];
	if (htmlMode && htmlMode.getFoldingRanges) {
		result.push(...htmlMode.getFoldingRanges(document));
	}

	// cache folding ranges per mode
	let rangesPerMode: { [mode: string]: FoldingRange[] } = Object.create(null);
	let getRangesForMode = (mode: LanguageMode) => {
		if (mode.getFoldingRanges) {
			let ranges = rangesPerMode[mode.getId()];
			if (!Array.isArray(ranges)) {
				ranges = mode.getFoldingRanges(document) || [];
				rangesPerMode[mode.getId()] = ranges;
			}
			return ranges;
		}
		return [];
	};

	let modeRanges = languageModes.getModesInRange(document, range);
	for (let modeRange of modeRanges) {
		let mode = modeRange.mode;
		if (mode && mode !== htmlMode && !modeRange.attributeValue) {
			const ranges = getRangesForMode(mode);
			result.push(...ranges.filter(r => r.startLine >= modeRange.start.line && r.endLine < modeRange.end.line));
		}
	}
	if (maxRanges && result.length > maxRanges) {
		result = limitRanges(result, maxRanges);
	}
	return result;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:35,代码来源:htmlFolding.ts

示例4:

export const createRange = (el: HasLocation): Range => {
  return Range.create(
    (el.startLine || 1) - 1,
    (el.startColumn || 1) - 1,
    (el.endLine || 1) - 1,
    el.endColumn || 1
  );
};
开发者ID:christianvoigt,项目名称:argdown,代码行数:8,代码来源:utils.ts

示例5: it

 it ('should return diagnostics with proper range', () => {
     let ghcModOutput = ['A.hs:5:7:Not in scope: `a`'];
     let range = Range.create(4, 6, 4, 6);
     let logger: ILogger = new TestLogger();
     let ghcMod: IGhcMod = new TestGhcMod(ghcModOutput);
     let provider: IGhcModProvider = new GhcModProvider(ghcMod, '', logger);
     return provider.doCheck(null, null, false).then((diagnostics) => {
         assert.deepEqual(diagnostics[0].range, range);
     });
 });
开发者ID:gdziadkiewicz,项目名称:vscode-ghc-mod,代码行数:10,代码来源:ghcModProvider.spec.ts

示例6: getFoldingRanges

export function getFoldingRanges(languageModes: LanguageModes, document: TextDocument, maxRanges: number | undefined, cancellationToken: CancellationToken | null): FoldingRange[] {
	let htmlMode = languageModes.getMode('html');
	let range = Range.create(Position.create(0, 0), Position.create(document.lineCount, 0));
	let ranges: FoldingRange[] = [];
	if (htmlMode && htmlMode.getFoldingRanges) {
		ranges.push(...htmlMode.getFoldingRanges(document, range));
	}
	let modeRanges = languageModes.getModesInRange(document, range);
	for (let modeRange of modeRanges) {
		let mode = modeRange.mode;
		if (mode && mode !== htmlMode && mode.getFoldingRanges && !modeRange.attributeValue) {
			ranges.push(...mode.getFoldingRanges(document, modeRange));
		}
	}
	if (maxRanges && ranges.length > maxRanges) {
		ranges = limitRanges(ranges, maxRanges);
	}
	return ranges;
}
开发者ID:AllureFer,项目名称:vscode,代码行数:19,代码来源:htmlFolding.ts

示例7: format

	function format(unformatted: string, expected: string, insertSpaces = true) {
		let range: Range = null;
		let uri = 'test://test.json';

		let rangeStart = unformatted.indexOf('|');
		let rangeEnd = unformatted.lastIndexOf('|');
		if (rangeStart !== -1 && rangeEnd !== -1) {
			// remove '|'
			var unformattedDoc = ITextDocument.create(uri, unformatted);
			unformatted = unformatted.substring(0, rangeStart) + unformatted.substring(rangeStart + 1, rangeEnd) + unformatted.substring(rangeEnd + 1);
			let startPos = unformattedDoc.positionAt(rangeStart);
			let endPos = unformattedDoc.positionAt(rangeEnd);
			range = Range.create(startPos, endPos);
		}

		var document = ITextDocument.create(uri, unformatted);
		let edits = Formatter.format(document, range, { tabSize: 2, insertSpaces: insertSpaces });
		let formatted  = applyEdits(document, edits);
		assert.equal(formatted, expected);
	}
开发者ID:1833183060,项目名称:vscode,代码行数:20,代码来源:formatter.test.ts

示例8: constructor

    public constructor(type: ext.le_DefinitionObjectType, name: string, path: string,
                       start: loader.Location, end: loader.Location,
                       defaultCollapsed?: boolean)
    {
        let newRange = lsp.Range.create(start.line - 1, start.column, end.line - 1, end.column + 1);

        this.name = name;
        this.kind = type as lsp.SymbolKind;
        this.defPath = Uri.file(path).toString();

        this.range = newRange;
        this.selectionRange = newRange;

        if (defaultCollapsed !== undefined)
        {
            this.defaultCollapsed = true;
        }

        this.children = [];
    }
开发者ID:legatoproject,项目名称:legato-af,代码行数:20,代码来源:vscTypeConvert.ts

示例9:

      lodash.forEach(annotations, (annotation) => {

        const lineReference = refractUtils.createLineReferenceFromSourceMap(
          annotation.attributes.sourceMap,
          text,
          documentLines,
        );

        diagnostics.push({
          code: annotation.attributes.code,
          message: annotation.content,
          range: Range.create(
            lineReference.startRow,
            lineReference.startIndex,
            lineReference.endRow,
            lineReference.endIndex,
          ),
          severity: ((lodash.head(annotation.meta.classes) === 'warning')
            ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error),
          source: 'fury',
        } as Diagnostic);

      });
开发者ID:XVincentX,项目名称:vscode-apielements,代码行数:23,代码来源:server.ts

示例10:

    lodash.forEach(annotations, (annotation) => {

      const lineReference = refractUtils.createLineReferenceFromSourceMap(
        annotation.attributes.sourceMap,
        text,
        documentLines
      );

      if (!lodash.isEmpty(lineReference)) {
        diagnostics.push({
          severity: ((lodash.head(annotation.meta.classes) === 'warning') ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error),
          code: annotation.attributes.code,
          range: Range.create(
            lineReference.startRow,
            lineReference.startIndex,
            lineReference.endRow,
            lineReference.endIndex
          ),
          message: annotation.content,
          source: parserName
        });
      }
    });
开发者ID:smizell,项目名称:vscode-apielements,代码行数:23,代码来源:server.ts


注:本文中的vscode-languageserver.Range.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。