<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          神器!GitHub上的命令行工具

          共 8926字,需瀏覽 18分鐘

           ·

          2021-07-15 02:04

            Java大聯(lián)盟

            幫助萬千Java學(xué)習(xí)者持續(xù)成長

          關(guān)注



          作者:開源最前線(ID:OpenSourceTop) 猿妹編譯 

          https://github.com/github/semantic


          B 站搜索:楠哥教你學(xué)Java

          獲取更多優(yōu)質(zhì)視頻教程


          GitHub上的實(shí)用工具還是挺多的,這不,又讓我找到了一個(gè)堪稱神器的支持多語言的命令行工具——Semantic,Semantic是一個(gè)解析,分析和比較多種語言源代碼的命令行工具,也是一個(gè)Haskell庫。


          平常解析源代碼也算是程序員的家常便飯了,如果有個(gè)工具幫你一把那是最好不過的了,Semantic具體如何使用,猿妹下面一說你就明白了:


          首先呢,運(yùn)行semantic --help獲取最新的完整選項(xiàng)列表:


          解析


          Usage: semantic parse ([--sexpression] | [--json] | [--json-graph] | [--symbols]
                                | [--dot] | [--show] | [--quiet]) [FILES...]
            Generate parse trees for path(s)

          Available options:
            --sexpression            Output s-expression parse trees (default)
            --json                   Output JSON parse trees
            --json-graph             Output JSON adjacency list
            --symbols                Output JSON symbol list
            --dot                    Output DOT graph parse trees
            --show                   Output using the Show instance (debug only, format
                                     subject to change without notice)
            --quiet                  Don't produce output, but show timing stats


          Semantic使用樹形圖來生成解析樹,現(xiàn)在我們拿一個(gè)簡單的程序來解析你會(huì)看的更明了,打開test.A.py文件,粘貼如下:


          def Foo(x):
              return x
          print Foo("hi")


          現(xiàn)在,讓我們生成一個(gè)抽象語法樹(AST)


          $ semantic parse test.A.py
          (Statements
            (Annotation
              (Function
                (Identifier)
                (Identifier)
                (Return
                  (Identifier))
          )
              (Empty))
            (Call
              (Identifier)
              (Call
                (Identifier)
                (TextElement)
                (Empty))

              (Empty))
          )


          默認(rèn)的s-expression輸出是一種很好的格式,可以快速可視化代碼結(jié)構(gòu)。我們可以看到有一個(gè)聲明的函數(shù),然后有一個(gè)調(diào)用表達(dá)式,嵌套在另一個(gè)調(diào)用表達(dá)式中,它與函數(shù)調(diào)用print和Foo。你還可以使用其他的輸出格式。



          DIFF(比較)


          Usage: semantic diff ([--sexpression] | [--json] | [--json-graph] | [--toc] |
                               [--dot] | [--show]) [FILE_A] [FILE_B]
            Compute changes between paths

          Available options:
            --sexpression            Output s-expression diff tree (default)
            --json                   Output JSON diff trees
            --json-graph             Output JSON diff trees
            --toc                    Output JSON table of contents diff summary
            --dot                    Output the diff as a DOT graph
            --show                   Output using the Show instance (debug only, format
                                     subject to change without notice)



          Graph(圖)


          Usage: semantic graph ([--imports] | [--calls]) [--packages] ([--dot] | [--json]
                                | [--show]) ([--root DIR] [--exclude-dir DIR]
                                DIR:LANGUAGE | FILE | --language ARG (FILES... | --stdin))
            Compute a graph for a directory or from a top-level entry point module

          Available options:
            --imports                Compute an import graph (default)
            --calls                  Compute a call graph
            --packages               Include a vertex for the package, with edges from it
                                     to each module
            --dot                    Output in DOT graph format (default)
            --json                   Output JSON graph
            --show                   Output using the Show instance (debug only, format
                                     subject to change without notice)
            --root DIR               Root directory of project. Optional, defaults to
                                     entry file/directory.
            --exclude-dir DIR        Exclude a directory (e.g. vendor)
            --language ARG           The language for the analysis.
            --stdin                  Read a list of newline-separated paths to analyze
                                     from stdin.



          語言支持


          多語言支持是Semantic的一大優(yōu)勢,目前支持Ruby、JavaScript、typescript、Python、Go、PHP、Java等主流編程語言都支持



          Semantic最低要求GHC 8.6.4和Cabal 2.4,建議使用ghcup沙箱GHC版本,為通過操作系統(tǒng)的軟件包管理器安裝的GHC軟件包可能無法安裝靜態(tài)鏈接版本的GHC啟動(dòng)庫。


          git clone [email protected]:github/semantic.git
          cd semantic
          script/bootstrap
          cabal new-build
          cabal new-test
          cabal new-run semantic -- --help


          創(chuàng)建者使用cabal的Nix風(fēng)格的本地版本進(jìn)行開發(fā)。要快速入門,可以按照以上操作。



          目前,semantic已經(jīng)在GitHub上獲得 8000 個(gè)Star,450 個(gè)Fork,感興趣的可以到GitHub上查閱更多詳情。


          GitHub地址:

          https://github.com/github/semantic


          推薦閱讀

          1、Spring Boot+Vue項(xiàng)目實(shí)戰(zhàn)

          2、B站:4小時(shí)上手MyBatis Plus

          3、一文搞懂前后端分離

          4、快速上手Spring Boot+Vue前后端分離


          楠哥簡介

          資深 Java 工程師,微信號(hào) southwindss

          《Java零基礎(chǔ)實(shí)戰(zhàn)》一書作者

          騰訊課程官方 Java 面試官,今日頭條認(rèn)證大V

          GitChat認(rèn)證作者,B站認(rèn)證UP主(楠哥教你學(xué)Java)

          致力于幫助萬千 Java 學(xué)習(xí)者持續(xù)成長。




          有收獲,就點(diǎn)個(gè)在看 
          瀏覽 34
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  在线观看免费黄片 | 无码青青青 | 欧美亚韩一区二区三区 | A片的视频 | 伊人久久影院 |