當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DisplayMarkerLayer.findMarkers方法代碼示例

本文整理匯總了TypeScript中atom.DisplayMarkerLayer.findMarkers方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DisplayMarkerLayer.findMarkers方法的具體用法?TypeScript DisplayMarkerLayer.findMarkers怎麽用?TypeScript DisplayMarkerLayer.findMarkers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在atom.DisplayMarkerLayer的用法示例。


在下文中一共展示了DisplayMarkerLayer.findMarkers方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: findIssueTags

 editor.onDidStopChanging(event_editorchanged => {
   // event_editorchanged.changes.forEach(text_change => {
   for (var text_change of event_editorchanged.changes) {
     // console.log('Deleted: "' + text_change.oldText + '"');
     // console.log('Added: "' + text_change.newText + '"');
     // check if the change range is in any of our issue tags.
     if (
       text_change.newText.length > 0 || // if text was added, we need to rescan
       issuetaglayer.findMarkers({
         intersectsBufferRange: text_change.oldRange
       }).length > 0
     ) {
       // then we should re-scan
       console.log("Re-scanning for issue tags...");
       findIssueTags(editor, issuetaglayer);
       break;
     }
     // else {
     //   // no need to re-scan
     //   console.log("No need to re-scan change: " + text_change.oldRange);
     // }
   } //);
 })
開發者ID:utk-cs,項目名稱:team-minsky,代碼行數:23,代碼來源:minskylink.ts

示例2: parseInt

 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
   );
 });
開發者ID:utk-cs,項目名稱:team-minsky,代碼行數:36,代碼來源:minskylink.ts

示例3: openIssueishFromCursorPosition

export function openIssueishFromCursorPosition(): void {
  var current_editor = atom.workspace.getActiveTextEditor();

  if (current_editor == undefined) {
    console.log("No editor in focus.");
    atom.notifications.addError("Minsky Link: No editor in focus!", {
      description: "Please focus a text editor pane and tag, then try again.",
      dismissable: true
    });
    return;
  }
  if (current_editor.hasMultipleCursors()) {
    console.log("Dunno how to handle hasMultipleCursors!");
    atom.notifications.addError("Minsky Link cannot handle multiple cursors!", {
      description: "This may later be implemented.",
      dismissable: true
    });
    return;
  }

  var current_minsky_marker_layer:
    | DisplayMarkerLayer
    | undefined = current_editor.getMarkerLayer(
    map_TextEditors_DisplayMarkerLayerIds[current_editor.id]
  );
  if (current_minsky_marker_layer == undefined) {
    console.log("Could not retrieve the marker layer!");
    atom.notifications.addFatalError(
      "Minsky Link encountered an unknown error.",
      {
        description: "Error: undefined current_minsky_marker_layer",
        dismissable: true
      }
    );
    return;
  }

  var current_cursor = current_editor.getLastCursor();
  console.log("Current cursor position: " + current_cursor.getBufferPosition());

  var potential_markers: DisplayMarker[] = current_minsky_marker_layer.findMarkers(
    {
      containsBufferPosition: current_cursor.getBufferPosition()
    }
  );

  console.log("Found " + potential_markers.length + " potential_markers");

  var target_marker: DisplayMarker | undefined;
  for (var potential_marker of potential_markers) {
    console.log(
      "potential_marker has properties " +
        Object.keys(potential_marker.getProperties())
    );
    if (potential_marker.getProperties().hasOwnProperty("minsky")) {
      target_marker = potential_marker;
      break;
    }
  }
  if (target_marker == undefined) {
    console.log("No minsky-link markers found under the cursor.");
    atom.notifications.addWarning("Couldn't parse tag.", {
      detail:
        "Please place the text cursor on the issue tag and try again.\n\
You may need to change the Issue Tag Regex in the plugin settings if your tags are not being recognized.",
      dismissable: false
    });
    return;
  }

  console.log("Found issue under cursor: " + target_marker.getBufferRange());

  var target_properties = target_marker.getProperties() as any;
  console.log("Lookup issue #" + target_properties["minsky"]);

  var loading_notif = atom.notifications.addSuccess(
    "Minsky-Link: Loading Issue #" + target_properties["minsky"],
    {
      description: "Opening pane for issue #" + target_properties["minsky"],
      dismissable: false // will disappear on it's own
    }
  );

  // XXX new idea: hijack github views
  // for now since GH84 is in the way, let's just assume it's here

  var reposlug = getRepoNames();

  var current_repo = atom.project.getRepositories()[0];
  var git_workdir = current_repo.getWorkingDirectory();

  var new_uri_to_open =
    "atom-github://issueish/" +
    encodeURIComponent("https://api.github.com") +
    "/" +
    reposlug[0] +
    "/" +
    reposlug[1] +
    "/" +
    target_properties["minsky"] +
//.........這裏部分代碼省略.........
開發者ID:utk-cs,項目名稱:team-minsky,代碼行數:101,代碼來源:minskylink.ts


注:本文中的atom.DisplayMarkerLayer.findMarkers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。