dummy-provider.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const { Point } = require('atom');
  2. function last (arr) {
  3. return arr[arr.length - 1];
  4. }
  5. const ICONS = [
  6. 'icon-package',
  7. 'icon-key',
  8. 'icon-gear',
  9. 'icon-tag',
  10. null
  11. ];
  12. module.exports = {
  13. packageName: 'symbol-provider-dummy',
  14. name: 'Dummy',
  15. isExclusive: true,
  16. canProvideSymbols () {
  17. return true;
  18. },
  19. getSymbols (meta) {
  20. let { editor, type } = meta;
  21. let results = [];
  22. if (type === 'file') {
  23. let count = editor.getLineCount();
  24. // Put a symbol on every third line.
  25. for (let i = 0; i < count; i += 3) {
  26. results.push({
  27. position: new Point(i, 0),
  28. name: `Symbol on Row ${i + 1}`,
  29. icon: ICONS[(i / 3) % (ICONS.length + 1)]
  30. });
  31. }
  32. } else if (type === 'project') {
  33. let root = last(atom.project.getPaths());
  34. let count = editor.getLineCount();
  35. // Put a symbol on every third line.
  36. for (let i = 0; i < count; i += 3) {
  37. results.push({
  38. position: new Point(i, 0),
  39. name: `Symbol on Row ${i + 1}`,
  40. directory: root,
  41. file: 'other-file.js',
  42. icon: ICONS[i % (ICONS.length + 1)]
  43. });
  44. }
  45. }
  46. return results;
  47. }
  48. };