• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode-languageserver.TextDocuments类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode-languageserver.TextDocuments的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDocuments类的具体用法?TypeScript TextDocuments怎么用?TypeScript TextDocuments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: createDiagnostics

function createDiagnostics(files: { [filePath: string]: string }, path: string) {
    const docs: { [path: string]: TextDocument } = {};
    Object.keys(files).reduce((prev, path: string) => {
        prev[path] = TextDocument.create('/' + path, 'css', 0, files[path]);
        return prev;
    }, docs);

    const documents: TextDocuments = {
        get: filePath => {
            return docs[filePath];
        },
        keys: () => {
            return Object.keys(docs);
        }
    } as TextDocuments;
    // const fs =  new LocalSyncFs('');
    const fs = new MemoryFileSystem('/', { content: files });
    const docsFs = createDocFs(fs, documents);

    const doc = documents.get(path);
    return doc
        ? createDiagnosis(
              doc,
              Stylable.create({
                  fileSystem: createFs(docsFs),
                  projectRoot: '/'
              }).fileProcessor,
              require
          )
        : null;
}
开发者ID:wix,项目名称:stylable-intelligence,代码行数:31,代码来源:diagnostics.spec.ts


示例2: constructor

	constructor() {
		this.documents = new TextDocuments();
		this.subject = new Subject<DocumentEvent>();

		this.documents.onDidOpen(this.emitDocumentEvent(DocumentEventKind.OPEN));
		this.documents.onDidChangeContent(this.emitDocumentEvent(DocumentEventKind.CHANGE_CONTENT));
		this.documents.onDidClose(this.emitDocumentEvent(DocumentEventKind.CLOSE));
	}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:8,代码来源:DocumentManager.ts


示例3: constructor

  constructor(
      connection: IConnection, documents: TextDocuments, baseDir: string,
      converter: AnalyzerLSPConverter, logger: Logger) {
    super();
    const fileLoader = new FsUrlLoader(baseDir);
    const inMemoryOverlayLoader = new InMemoryOverlayUrlLoader(fileLoader);
    this.inMemoryDocuments = inMemoryOverlayLoader.urlContentsMap;
    this.urlLoader = inMemoryOverlayLoader;

    const {fire, stream} = EventStream.create<FileEvent[]>();
    this.fileChanges = stream;
    documents.onDidOpen((change) => {
      logger.log(`Opened: ${change.document.uri}`);
    });
    this.disposables.push(documents.onDidChangeContent((change) => {
      logger.log(`Changed in memory: ${change.document.uri}`);
      // A document has changed in memory!
      const url = converter.getAnalyzerUrl(change.document);
      if (!url) {
        return;  // don't care
      }
      this.inMemoryDocuments.set(url, change.document.getText());

      // Publish document change so other parts of the system can react.
      fire([{type: FileChangeType.Changed, uri: change.document.uri}]);
    }));

    this.disposables.push(documents.onDidClose((event) => {
      logger.log(`Closed: ${event.document.uri}`);
      // The file is no longer managed in memory, so we should delete it from
      // the in-memory map.
      const url = converter.getAnalyzerUrl(event.document);
      if (url === undefined) {
        return;  // don't care
      }
      this.inMemoryDocuments.delete(url);
      fire([{type: FileChangeType.Changed, uri: event.document.uri}]);
    }));

    connection.onDidChangeWatchedFiles((req) => {
      for (const change of req.changes) {
        logger.log(`Changed on disk: ${change.uri}`);
      }
      const inMemoryURIs = new Set(documents.keys());
      // We will get documents.onDidChangeContent events for changes of
      // in-memory buffers, so we filter them out to avoid sending duplicate
      // events for those changes.
      const diskBackedChanges =
          req.changes.filter((ch) => !inMemoryURIs.has(ch.uri));
      fire(diskBackedChanges);
    });
  }
开发者ID:MehdiRaash,项目名称:tools,代码行数:52,代码来源:file-synchronizer.ts


示例4:

connection.onRequest(ColorPresentationRequest.type, params => {
  const document = documents.get(params.textDocument.uri);
  if (document) {
    return vls.getColorPresentations(document, params.color, params.range);
  }
  return [];
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:7,代码来源:pcServerMain.ts


示例5: getLanguageModes

connection.onInitialize((params: InitializeParams): InitializeResult => {
	let initializationOptions = params.initializationOptions;

	workspacePath = params.rootPath;

	languageModes = getLanguageModes(initializationOptions ? initializationOptions.embeddedLanguages : { css: true, javascript: true });
	documents.onDidClose(e => {
		languageModes.getAllModes().forEach(m => m.onDocumentRemoved(e.document));
	});
	connection.onShutdown(() => {
		languageModes.getAllModes().forEach(m => m.dispose());
	});

	return {
		capabilities: {
			// Tell the client that the server works in FULL text document sync mode
			textDocumentSync: documents.syncKind,
			completionProvider: { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/'] },
			hoverProvider: true,
			documentHighlightProvider: true,
			documentRangeFormattingProvider: initializationOptions && initializationOptions['format.enable'],
			documentLinkProvider: true,
			definitionProvider: true,
			signatureHelpProvider: { triggerCharacters: ['('] },
			referencesProvider: true
		}
	};
});
开发者ID:,项目名称:,代码行数:28,代码来源:


示例6: if

connection.onDidChangeConfiguration((change) => {
	globalSettings = change.settings;

	documentSettings = {}; // reset all document settings
	languageModes.getAllModes().forEach(m => {
		if (m.configure) {
			m.configure(change.settings);
		}
	});
	documents.all().forEach(triggerValidation);

	// dynamically enable & disable the formatter
	if (clientDynamicRegisterSupport) {
		let enableFormatter = globalSettings && globalSettings.html && globalSettings.html.format && globalSettings.html.format.enable;
		if (enableFormatter) {
			if (!formatterRegistration) {
				let documentSelector: DocumentSelector = [{ language: 'html' }, { language: 'handlebars' }]; // don't register razor, the formatter does more harm than good
				formatterRegistration = connection.client.register(DocumentRangeFormattingRequest.type, { documentSelector });
			}
		} else if (formatterRegistration) {
			formatterRegistration.then(r => r.dispose());
			formatterRegistration = null;
		}
	}

});
开发者ID:armanio123,项目名称:vscode,代码行数:26,代码来源:htmlServerMain.ts


示例7: async

 async (request: ImageInfoRequest, cancellationToken: CancellationToken): Promise<ImageInfoResponse> => {
     try {
         let document = documents.get(request.uri);
         if (document) {
             const cancellation = new Promise<ImageInfo[]>((res, rej) => {
                 cancellationToken.onCancellationRequested(() => {
                     res([]);
                 });
             });
             return Promise.race([collectEntries(document, request, cancellationToken), cancellation])
                 .then(values => values.filter(p => !!p))
                 .then(entries => {
                     return {
                         images: entries.filter(p => !!p)
                     };
                 })
                 .catch(e => {
                     console.error(e);
                     return {
                         images: []
                     };
                 });
         } else {
             return {
                 images: []
             };
         }
     } catch (e) {
         console.error(e);
         return {
             images: []
         };
     }
 }
开发者ID:kisstkondoros,项目名称:gutter-preview,代码行数:34,代码来源:server.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap