UP | HOME

gun global使用备注

Table of Contents

安装

由于我使用的是debian系统

sudo apt-get install global

使用

生成文件

$ cd source_dir
$ gtags -v #目录下会多了三个文件 GTAGS(定义数据库),GRTAGS(引用数据库),GPATH(路径名数据库)

常用参数

//不带参数
$ global fromString
src/Email.php
vendor/phar-io/manifest/src/ManifestLoader.php
vendor/phar-io/manifest/src/xml/ManifestDocument.php


// -r 获取对tag的引用
$ global -r fromString
tests/EmailTest.php
vendor/phar-io/manifest/src/ManifestLoader.php
vendor/phar-io/manifest/src/xml/ManifestDocument.php
vendor/phar-io/manifest/tests/ManifestLoaderTest.php
vendor/phar-io/manifest/tests/ManifestSerializerTest.php
vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php


// -o 搜索tag的定义
$ global -xo fromString
fromString         15 src/Email.php        public static function fromString(string $email): self
fromString         53 vendor/phar-io/manifest/src/ManifestLoader.php     public static function fromString($manifest) {
fromString         47 vendor/phar-io/manifest/src/xml/ManifestDocument.php     public static function fromString($xmlString) {


// -x 显示更多详细
$ global -rx fromString
fromString         12 tests/EmailTest.php             Email::fromString('user@example.com')
fromString         20 tests/EmailTest.php         Email::fromString('invalid');
fromString         27 tests/EmailTest.php             Email::fromString('user@example.com')
fromString         56 vendor/phar-io/manifest/src/ManifestLoader.php                 ManifestDocument::fromString($manifest)
fromString         42 vendor/phar-io/manifest/src/xml/ManifestDocument.php         return self::fromString(
fromString         56 vendor/phar-io/manifest/tests/ManifestLoaderTest.php             ManifestLoader::fromString(
fromString         80 vendor/phar-io/manifest/tests/ManifestLoaderTest.php         ManifestLoader::fromString('<?xml version="1.0" ?><broken>');
fromString         59 vendor/phar-io/manifest/tests/ManifestSerializerTest.php         $manifest = ManifestLoader::fromString($expected);
fromString         22 vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php             ManifestDocument::fromString($content)
fromString         28 vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php         ManifestDocument::fromString('<?xml version="1.0" ?><root>');
fromString         33 vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php         ManifestDocument::fromString('<?xml version="1.0" ?><root />');
fromString         38 vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php         ManifestDocument::fromString('<?xml version="1.0" ?><phar xmlns="foo:bar" />');
fromString        106 vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.php         return ManifestDocument::fromString(


// -a 绝对路径
$ global -a fromString
/mnt/f/work/todo/projects/test/src/Email.php
/mnt/f/work/todo/projects/test/vendor/phar-io/manifest/src/ManifestLoader.php
/mnt/f/work/todo/projects/test/vendor/phar-io/manifest/src/xml/ManifestDocument.php


// -g 正则匹配
$ global -xg "fromSt*"
fromSt*            15 src/Email.php        public static function fromString(string $email): self
fromSt*            12 tests/EmailTest.php             Email::fromString('user@example.com')
fromSt*            20 tests/EmailTest.php         Email::fromString('invalid');
fromSt*            27 tests/EmailTest.php             Email::fromString('user@example.com')
fromSt*            15 vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php     public static function fromSerializationTriggeredExceptio                                fromSt*            56 vendor/sebastian/diff/src/MemoryEfficientLongestCommonSubsequenceCalculator.php             $this->calculate($fromStart, $toStart),
fromSt*           169 vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php         $toStart     = $fromStart = 1;
fromSt*           174 vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php                     ++$fromStart;
fromSt*           205 vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php                         $fromStart - $contextStartOffset,
fromSt*           212 vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php                     $fromStart += $fromRange;
...........


// -f 命令显示指定文件的所有tag
$ global -f src/Email.php
Email               4 src/Email.php    final class Email
__construct         8 src/Email.php        private function __construct(string $email)
fromString         15 src/Email.php        public static function fromString(string $email): self
__toString         20 src/Email.php        public function __toString(): string
ensureIsValidEmail   25 src/Email.php        private function ensureIsValidEmail(string $email): void


// -l 本目录搜索
$ global fromString
Email.php
../vendor/phar-io/manifest/src/ManifestLoader.php
../vendor/phar-io/manifest/src/xml/ManifestDocument.php
$ global -l fromString
Email.php

gtags-cscope

$ gtags-cscope

Text string: String

  File                                           Line
0 Email.php                                        15 public static function fromString(string $email): self
1 Email.php                                        20 public function __toString(): string
.....................


Find this symbol:
Find this global definition:
Find functions called by this function (N/A):
Find references of this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
Find assignments to this symbol:

TAB             Swap positions between input and output areas.
RETURN          Move to the next input field.
^N              Move to the next input field.
^P              Move to the previous input field.
^Y / ^A         Search with the last pattern typed.
^B              Recall previous input field and search pattern.
^F              Recall next input field and search pattern.
^C              Toggle ignore/use letter case when searching (USE).
^R              Rebuild the cross-reference.
!               Start an interactive shell (type ^D to return to cscope).
^L              Redraw the screen.
?               Display this list of commands.
^D              Exit cscope.
//自行摸索

参考

[GNU GLOBAL source code tagging system](https://www.gnu.org/software/global/global.html)

First created: 2020-03-11 23:48:09
Last updated: 2021-11-25 Thu 23:23
Power by Emacs 27.1 (Org mode 9.4)
© 2017 – 2021 by josephzeng