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

TypeScript atom.TextBuffer类代码示例

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

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



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

示例1: registerCompletionBuffer

  /*
  registerCompletionBuffer(buffer)
  Every buffer that would be used with autocompletion functions has to
  be registered with this function.

  buffer: TextBuffer, buffer to be used in autocompletion

  Returns: Disposable, which will remove buffer from autocompletion
  */
  public registerCompletionBuffer(buffer: TextBuffer) {
    if (!this.isActive) { throw new Error('Backend inactive') }

    if (this.bufferMap.has(buffer)) {
      return new Disposable(() => { /* void */ })
    }

    this.bufferMap.set(buffer, new BufferInfo(buffer))

    const file = buffer.getUri()
    buffer.onDidSave(async (_event) => {
      const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
      if (buf) {
        delete buf.completions
      }
      const contents: string = buffer.getText()
      await this.process.backend.setFileContents(file, contents)
      await this.process.backend.scanFile({ file, scanProject: false, scanDeps: false })
    })

    setImmediate(async () => {
      this.process.backend.scanFile({ file })
    })

    return new Disposable(() =>
      this.unregisterCompletionBuffer(buffer))
  }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:36,代码来源:index.ts


示例2: resolve

  const buffer = await new Promise<TextBuffer.ITextBuffer>(resolve => {
    const buffer = new Atom.TextBuffer({
      filePath,
      load: true,
    })

    buffer.onDidReload(() => {
      resolve(buffer)
    })
  })
开发者ID:GavinJoyce,项目名称:dotfiles,代码行数:10,代码来源:atomts.ts


示例3: getCompletionsForSymbolInModule

  /*
  getCompletionsForSymbolInModule(buffer,prefix,position,{module})
  Used in import hiding/list completions

  buffer: TextBuffer, current buffer
  prefix: String, completion prefix
  position: Point, current cursor position
  module: String, module name (optional). If undefined, function
          will attempt to infer module name from position and buffer.

  Returns: Promise([symbol])
  symbol: Object, symbol in given module
    name: String, symbol name
    typeSignature: String, type signature
    symbolType: String, one of ['type', 'class', 'function']
  */
  public async getCompletionsForSymbolInModule(
    buffer: TextBuffer, prefix: string, position: Point,
    opts?: { module: string },
  ): Promise<CB.ISymbol[]> {
    if (!this.isActive) { throw new Error('Backend inactive') }
    let moduleName = opts ? opts.module : undefined
    if (!moduleName) {
      const lineRange = new Range([0, position.row], position)
      buffer.backwardsScanInRange(
        /^import\s+([\w.]+)/,
        lineRange, ({ match }) => moduleName = match[1],
      )
    }

    return [] // TODO: Implement
    // tslint:enable: no-null-keyword
    // return FZ.filter(symbols, prefix, { key: 'name' })
  }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:34,代码来源:index.ts


示例4: getCompletionsForModule

  /*
  getCompletionsForModule(buffer,prefix,position)
  buffer: TextBuffer, current buffer
  prefix: String, completion prefix
  position: Point, current cursor position

  Returns: Promise([module])
  module: String, module name
  */
  public async getCompletionsForModule(
    buffer: TextBuffer, prefix: string, _position: Point,
  ): Promise<string[]> {
    if (!this.isActive) { throw new Error('Backend inactive') }
    const modules = await this.process.backend.scopeModules({
      query: prefix,
      searchType: 'prefix',
      file: buffer.getUri(),
    })
    const parts: number = prefix.split('.').length
    const names: string[] = []
    for (const m of modules) {
      if (m.name.split('.').length == parts) {
        names.push(m.name)
      }
    }
    return names
  }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:27,代码来源:index.ts


示例5: whoat

  public async whoat(
    buffer: TextBuffer, crange: Range
  ) {
    const file = buffer.getUri()
    const line = crange.start.row + 1
    const column = crange.start.column + 1
    const symbols: any[] = await this.backend.whoat(file, line, column)
    if (symbols.length == 0) {
      Util.debug(`No info found for symbol at ${file} ${line} ${column}`)
      throw Error(`No info found for symbol at ${file} ${line} ${column}`)
    }
    else {
      const sym = symbols[0]
      const what = sym.info.what
      const lines = []
      switch (what) {
        case 'function':
        case 'method':
        case 'constructor':
          lines.push(`${sym.id.name} :: ${sym.info.type ? sym.info.type : '?'}`)
          break
        case 'data':
        case 'type':
        case 'class':
        case 'newtype':
          lines.push(`${what} ${sym.id.name}`)
          break
        default:
          lines.push(`${sym.id.name}`)
      }

      if (sym.docs) {
        lines.push('', `{- ${sym.docs} -}`)
      }

      if (sym.id.module.location.file && sym.pos) {
        lines.push('', `-- Defined in ${sym.id.module.location.file}:${sym.pos.line}:${sym.pos.column}`)
      }
      return {range: crange, info: lines.join('\n')}
    }
  }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:41,代码来源:index.ts


示例6: getCompletionsForBuffer

  private async getCompletionsForBuffer(
    buffer: TextBuffer, symbolTypes?: CB.SymbolType[],
  ): Promise<CB.ISymbol[]> {
    let symbols: CB.ISymbol[] = []

    const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
    if (buf && buf.completions) {
      symbols = buf.completions
    }
    else {
      const comps: any[] = await this.process.backend.complete(
        '',
        buffer.getUri(),
      )
      for (const comp of comps) {
        let symType: CB.SymbolType = 'function'
        switch (comp.info.what) {
          case 'function':
          case 'method':
          case 'selector':
          case 'pat-selector':
          case 'pat-constructor':
          case 'constructor':
            symType = 'function'
            break
          case 'type':
          case 'newtype':
          case 'data':
          case 'type-family':
          case 'data-family':
            symType = 'type'
            break
          case 'class':
            symType = 'class'
            break
          default:
            break
        }
        if (symbolTypes && !(symType in symbolTypes)) {
          continue
        }

        symbols.push({
          qparent: comp.qualifier,
          qname: comp.qualifier ? `${comp.qualifier}.${comp.id.name}` : comp.id.name,
          name: comp.id.name,
          symbolType: symType,
          typeSignature: comp.info.type,
          // FIXME: Use import module
          module: {
            name: comp.id.module.name,
            hiding: false,
            qualified: false,
            alias: null,
            importList: null,
          }
        })
      }
      if (buf) {
        Util.debug(`Caching ${symbols.length} completions for ${buffer.getUri()}`)
        buf.completions = symbols
      }
    }
    if (!symbolTypes) {
      return symbols
    }
    const result: CB.ISymbol[] = []
    for (const sym of symbols) {
      if (sym.symbolType in symbolTypes) {
        result.push(sym)
      }
    }
    return result
  }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:74,代码来源:index.ts


示例7: lint

 public async lint(buffer: TextBuffer) {
   const file = buffer.getUri()
   const messages = await this.backend.lint([file])
   return this.convertMessages(messages)
 }
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:5,代码来源:index.ts


示例8:

 buffer.onDidSave(async (_event) => {
   const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
   if (buf) {
     delete buf.completions
   }
   const contents: string = buffer.getText()
   await this.process.backend.setFileContents(file, contents)
   await this.process.backend.scanFile({ file, scanProject: false, scanDeps: false })
 })
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:9,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript atom.TextEditor类代码示例发布时间:2022-05-25
下一篇:
TypeScript atom.Range类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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