Changeset View
Standalone View
src/applications/diffusion/symbol/PythonExternalSymbolsSource.php
- This file was added.
<?php | |||||
final class PythonExternalSymbolsSource extends ExternalSymbolsSource { | |||||
public function lookupSymbol(array $params) { | |||||
if (idx($params, 'lang') != 'py') { | |||||
return null; | |||||
} | |||||
$name = idx($params, 'name'); | |||||
if (!$name) { | |||||
return null; | |||||
} | |||||
if (idx($params, 'type') == 'builtin') { | |||||
if (idx(self::$pyhonBuiltins, $name)) { | |||||
joshuaspence: Typo | |||||
return 'https://docs.python.org/2/library/functions.html#'.$name; | |||||
joshuaspenceUnsubmitted Done Inline ActionsDoes the "2" here mean Python 2? If so, do we need to allow for other versions? joshuaspence: Does the "2" here mean Python 2? If so, do we need to allow for other versions? | |||||
aviveyAuthorUnsubmitted Not Done Inline ActionsYes. I was thinking to use priority to solve this, but with the new suggested design, I'll just make this class return both links (Or maybe one link in cases where the docs are the same). avivey: Yes. I was thinking to use priority to solve this, but with the new suggested design, I'll just… | |||||
Done Inline ActionsNaively, I'd expect these to be function, not builtin? Is this just a python-ism? Today, I think it doesn't matter. In the future, we might eventually care about having fewer distinct symbol types, maybe. epriestley: Naively, I'd expect these to be `function`, not `builtin`? Is this just a python-ism?
Today, I… | |||||
Not Done Inline ActionsI think I've invented builtin in the ctrl-click diff. The python lexer marks all of these as nb (Name.Builtin), and under the existing state we can't search for them. We do the Python lexing ourselves, so we can just say they are all nf and stop worrying about it. avivey: I think I've invented `builtin` in the ctrl-click diff. The python lexer marks all of these as… | |||||
Not Done Inline Actionsjust support both for now :) avivey: just support both for now :) | |||||
} | |||||
} | |||||
} | |||||
private static $pyhonBuiltins = array( | |||||
joshuaspenceUnsubmitted Not Done Inline ActionsTypo. Also, maybe move this to a JSON file for consistency with PHP symbols. joshuaspence: Typo. Also, maybe move this to a JSON file for consistency with PHP symbols. | |||||
'__import__' => true, | |||||
'abs' => true, | |||||
Not Done Inline ActionsFixed the typo (I hope), but haven't moved the content to a file yet. avivey: Fixed the typo (I hope), but haven't moved the content to a file yet. | |||||
'all' => true, | |||||
'any' => true, | |||||
'basestring' => true, | |||||
'bin' => true, | |||||
'bool' => true, | |||||
'bytearray' => true, | |||||
'callable' => true, | |||||
'chr' => true, | |||||
'classmethod' => true, | |||||
'cmp' => true, | |||||
'compile' => true, | |||||
'complex' => true, | |||||
'delattr' => true, | |||||
'dict' => true, | |||||
'dir' => true, | |||||
'divmod' => true, | |||||
'enumerate' => true, | |||||
'eval' => true, | |||||
'execfile' => true, | |||||
'file' => true, | |||||
'filter' => true, | |||||
'float' => true, | |||||
'format' => true, | |||||
'frozenset' => true, | |||||
'getattr' => true, | |||||
'globals' => true, | |||||
'hasattr' => true, | |||||
'hash' => true, | |||||
'help' => true, | |||||
'hex' => true, | |||||
'id' => true, | |||||
'input' => true, | |||||
'int' => true, | |||||
'isinstance' => true, | |||||
'issubclass' => true, | |||||
'iter' => true, | |||||
'len' => true, | |||||
'list' => true, | |||||
'locals' => true, | |||||
'long' => true, | |||||
'map' => true, | |||||
'max' => true, | |||||
'memoryview' => true, | |||||
'min' => true, | |||||
'next' => true, | |||||
'object' => true, | |||||
'oct' => true, | |||||
'open' => true, | |||||
'ord' => true, | |||||
'pow' => true, | |||||
'print' => true, | |||||
'property' => true, | |||||
'range' => true, | |||||
'raw_input' => true, | |||||
'reduce' => true, | |||||
'reload' => true, | |||||
'repr' => true, | |||||
'reversed' => true, | |||||
'round' => true, | |||||
'set' => true, | |||||
'setattr' => true, | |||||
'slice' => true, | |||||
'sorted' => true, | |||||
'staticmethod' => true, | |||||
'str' => true, | |||||
'sum' => true, | |||||
'super' => true, | |||||
'tuple' => true, | |||||
'type' => true, | |||||
'unichr' => true, | |||||
'unicode' => true, | |||||
'vars' => true, | |||||
'xrange' => true, | |||||
'zip' => true, | |||||
); | |||||
} |
Typo