forked from pulsar-edit/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pulsar-edit#1133 from savetheclocktower/symbols-vi…
…ew-project-symbol-nonexclusivity [symbols-view] Allow project-wide symbol searches to consider multiple providers
- Loading branch information
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/symbols-view/spec/fixtures/providers/second-dummy-provider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const { Point } = require('atom'); | ||
|
||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
|
||
const ICONS = [ | ||
'icon-package', | ||
'icon-key', | ||
'icon-gear', | ||
'icon-tag', | ||
null | ||
]; | ||
|
||
module.exports = { | ||
packageName: 'symbol-provider-dummy-second', | ||
name: 'Dummy (Second)', | ||
isExclusive: true, | ||
canProvideSymbols() { | ||
return true; | ||
}, | ||
getSymbols(meta) { | ||
let { editor, type } = meta; | ||
let results = []; | ||
if (type === 'file') { | ||
let count = editor.getLineCount(); | ||
// Put a symbol on every third line. | ||
for (let i = 0; i < count; i += 3) { | ||
results.push({ | ||
position: new Point(i, 0), | ||
name: `(Second) Symbol on Row ${i + 1}`, | ||
icon: ICONS[(i / 3) % (ICONS.length + 1)] | ||
}); | ||
} | ||
} else if (type === 'project') { | ||
let root = last(atom.project.getPaths()); | ||
let count = editor.getLineCount(); | ||
// Put a symbol on every third line. | ||
for (let i = 0; i < count; i += 3) { | ||
results.push({ | ||
position: new Point(i, 0), | ||
name: `(Second) Symbol on Row ${i + 1}`, | ||
directory: root, | ||
file: 'other-file.js', | ||
icon: ICONS[i % (ICONS.length + 1)] | ||
}); | ||
} | ||
} | ||
return results; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters