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


TypeScript TextEditor.scan方法代码示例

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


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

示例1: findIssueTags

// HOVER LISTENER GH40
// TODO #40

// ISSUE TAG FINDER GH33
// search for issue tags in a TextBuffer and apply markers to them
function findIssueTags(
  textToSearch: TextEditor,
  issuetaglayer: DisplayMarkerLayer
) {
  textToSearch.scan(regex1_gh, scanResult => {
    var issue_number: number = parseInt(scanResult.match[1]);
    // console.log("Found issue tag: " + scanResult.matchText);
    // check if there already exists a marker on this layer:
    var existing_markers = issuetaglayer.findMarkers({
      intersectsBufferRange: scanResult.range
    });
    for (var marker_to_check of existing_markers) {
      if (marker_to_check.isValid() == true) {
        // still is valid? don't bother
        // console.log(
        //   "Issue tag #" +
        //     issue_number +
        //     " already known: " +
        //     marker_to_check.getBufferRange()
        // );
        return;
      } else {
        // destroy the invalid marker:
        marker_to_check.destroy();
      }
    }
    // console.log("Creating marker on " + scanResult.range);
    var new_marker = issuetaglayer.markBufferRange(scanResult.range, {
      invalidate: "touch"
    });
    new_marker.setProperties({
      minsky: issue_number
    });
    console.log(
      "Created marker for issue #" +
        issue_number +
        ": " +
        new_marker.getStartBufferPosition
    );
  });

  console.log(
    "issuetaglayer currently has " + issuetaglayer.getMarkerCount() + " items!"
  );
}
开发者ID:utk-cs,项目名称:team-minsky,代码行数:50,代码来源:minskylink.ts


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