Changeset View
Changeset View
Standalone View
Standalone View
scripts/symbols/generate_ctags_symbols.php
| Show All 29 Lines | foreach ($input as $file) { | ||||
| $futures[$file] = ctags_get_parser_future($file); | $futures[$file] = ctags_get_parser_future($file); | ||||
| } | } | ||||
| foreach (Futures($futures)->limit(8) as $file => $future) { | foreach (Futures($futures)->limit(8) as $file => $future) { | ||||
| $tags = $future->resolve(); | $tags = $future->resolve(); | ||||
| $tags = explode("\n", $tags[1]); | $tags = explode("\n", $tags[1]); | ||||
| foreach ($tags as $tag) { | foreach ($tags as $tag) { | ||||
| $parts = explode(";", $tag); | $parts = explode(';', $tag); | ||||
| // skip lines that we can not parse | // skip lines that we can not parse | ||||
| if (count($parts) < 2) { | if (count($parts) < 2) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| // split ctags information | // split ctags information | ||||
| $tag_info = explode("\t", $parts[0]); | $tag_info = explode("\t", $parts[0]); | ||||
| // split exuberant ctags "extension fields" (additional information) | // split exuberant ctags "extension fields" (additional information) | ||||
| Show All 15 Lines | if (strpos($token, ' ') !== false) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| // strip "language:" | // strip "language:" | ||||
| $language = substr($language, 9); | $language = substr($language, 9); | ||||
| // To keep consistent with "Separate with commas, for example: php, py" | // To keep consistent with "Separate with commas, for example: php, py" | ||||
| // in Arcanist Project edit form. | // in Arcanist Project edit form. | ||||
| $language = str_ireplace("python", "py", $language); | $language = str_ireplace('python', 'py', $language); | ||||
| // also, "normalize" c++ and c# | // also, "normalize" c++ and c# | ||||
| $language = str_ireplace("c++", "cpp", $language); | $language = str_ireplace('c++', 'cpp', $language); | ||||
| $language = str_ireplace("c#", "cs", $language); | $language = str_ireplace('c#', 'cs', $language); | ||||
| // Ruby has "singleton method", for example | // Ruby has "singleton method", for example | ||||
| $type = substr(str_replace(' ', '_', $type), 0, 12); | $type = substr(str_replace(' ', '_', $type), 0, 12); | ||||
| // class:foo, struct:foo, union:foo, enum:foo, ... | // class:foo, struct:foo, union:foo, enum:foo, ... | ||||
| $context = last(explode(':', $context, 2)); | $context = last(explode(':', $context, 2)); | ||||
| $ignore = array( | $ignore = array( | ||||
| 'variable' => true, | 'variable' => true, | ||||
| Show All 19 Lines | function ctags_check_executable() { | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| function print_symbol($file, $line_num, $type, $token, $context, $language) { | function print_symbol($file, $line_num, $type, $token, $context, $language) { | ||||
| // get rid of relative path | // get rid of relative path | ||||
| $file = explode('/', $file); | $file = explode('/', $file); | ||||
| if ($file[0] == '.' || $file[0] == "..") { | if ($file[0] == '.' || $file[0] == '..') { | ||||
| array_shift($file); | array_shift($file); | ||||
| } | } | ||||
| $file = '/' . implode('/', $file); | $file = '/' . implode('/', $file); | ||||
| $parts = array( | $parts = array( | ||||
| $context, | $context, | ||||
| $token, | $token, | ||||
| $type, | $type, | ||||
| strtolower($language), | strtolower($language), | ||||
| $line_num, | $line_num, | ||||
| $file, | $file, | ||||
| ); | ); | ||||
| echo implode(' ', $parts)."\n"; | echo implode(' ', $parts)."\n"; | ||||
| } | } | ||||