Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / symbol / DiffusionPythonExternalSymbolsSource.php
blobdc8be8aa3fecc013e25420bdc8d050feba42c79f
1 <?php
3 final class DiffusionPythonExternalSymbolsSource
4 extends DiffusionExternalSymbolsSource {
6 public function executeQuery(DiffusionExternalSymbolQuery $query) {
7 $symbols = array();
8 if (!$query->matchesAnyLanguage(array('py', 'python'))) {
9 return $symbols;
12 if (!$query->matchesAnyType(array('builtin', 'function'))) {
13 return $symbols;
16 $names = $query->getNames();
18 foreach ($names as $name) {
19 if (idx(self::$python2Builtins, $name)) {
20 $symbols[] = $this->buildExternalSymbol()
21 ->setSymbolName($name)
22 ->setSymbolType('function')
23 ->setSource(pht('Standard Library'))
24 ->setLocation(pht('The Python 2 Standard Library'))
25 ->setSymbolLanguage('py')
26 ->setExternalURI(
27 'https://docs.python.org/2/library/functions.html#'.$name);
29 if (idx(self::$python3Builtins, $name)) {
30 $symbols[] = $this->buildExternalSymbol()
31 ->setSymbolName($name)
32 ->setSymbolType('function')
33 ->setSource(pht('Standard Library'))
34 ->setLocation(pht('The Python 3 Standard Library'))
35 ->setSymbolLanguage('py')
36 ->setExternalURI(
37 'https://docs.python.org/3/library/functions.html#'.$name);
40 return $symbols;
43 private static $python2Builtins = array(
44 '__import__' => true,
45 'abs' => true,
46 'all' => true,
47 'any' => true,
48 'basestring' => true,
49 'bin' => true,
50 'bool' => true,
51 'bytearray' => true,
52 'callable' => true,
53 'chr' => true,
54 'classmethod' => true,
55 'cmp' => true,
56 'compile' => true,
57 'complex' => true,
58 'delattr' => true,
59 'dict' => true,
60 'dir' => true,
61 'divmod' => true,
62 'enumerate' => true,
63 'eval' => true,
64 'execfile' => true,
65 'file' => true,
66 'filter' => true,
67 'float' => true,
68 'format' => true,
69 'frozenset' => true,
70 'getattr' => true,
71 'globals' => true,
72 'hasattr' => true,
73 'hash' => true,
74 'help' => true,
75 'hex' => true,
76 'id' => true,
77 'input' => true,
78 'int' => true,
79 'isinstance' => true,
80 'issubclass' => true,
81 'iter' => true,
82 'len' => true,
83 'list' => true,
84 'locals' => true,
85 'long' => true,
86 'map' => true,
87 'max' => true,
88 'memoryview' => true,
89 'min' => true,
90 'next' => true,
91 'object' => true,
92 'oct' => true,
93 'open' => true,
94 'ord' => true,
95 'pow' => true,
96 'print' => true,
97 'property' => true,
98 'range' => true,
99 'raw_input' => true,
100 'reduce' => true,
101 'reload' => true,
102 'repr' => true,
103 'reversed' => true,
104 'round' => true,
105 'set' => true,
106 'setattr' => true,
107 'slice' => true,
108 'sorted' => true,
109 'staticmethod' => true,
110 'str' => true,
111 'sum' => true,
112 'super' => true,
113 'tuple' => true,
114 'type' => true,
115 'unichr' => true,
116 'unicode' => true,
117 'vars' => true,
118 'xrange' => true,
119 'zip' => true,
122 // This list only contains functions that are new or changed between the
123 // Python versions.
124 private static $python3Builtins = array(
125 'ascii' => true,
126 'bytes' => true,
127 'filter' => true,
128 'map' => true,
129 'next' => true,
130 'range' => true,
131 'super' => true,
132 'zip' => true,