source insight 也可以編譯php

Source Insight(以下簡稱SI)是非常強勁的代碼閱讀工具,安裝後也就才3M大小,但在閱讀別人的代碼的時候實在是太方便了,尤其在查找類,函數的相關定義的時候。

SI標準內置的語言主要在c/c++/Java/C#等,但就是沒有PHP。這次有個比較大的PHP的項目代碼需要接手,用UE看了一段,裏面的函數跳來跳去,實在是麻煩。後來g了以下,發現SI官方網站自己帶了PHP的語言定義文件,按照網站上的說明,倒入,配置了以下。類,函數等關聯操作都已經可以了,就是語法的高亮沒有。基本上就只有幾個流程控制if,else高亮顯示,看起來累就一個字。

從SI的language中導出的PHP語言定義,發現只配置了很少的流程控制字爲keyword,所以只有這些是高亮的。這下好辦了,從UltraEdit的wordfile.txt中把php的高亮配置導出,做了一些處理,分成內置function,keyword,control,operator四類,寫成一個新的文本,然後再倒入進語言定義。

接着在顏色style中配置了對這四類的顏色顯示,一切就OK了。

爲了方便大家,我把自己做好的PHP語言定義文件和style文件上傳,方便大家使用。

使用方法:
==》》解壓縮,裏面有兩個文件:PHP Script.CLF,PHP-Styles.CF3

==》》語言文件:PHP Script.CLF
按照這個頁面的提示:http://www.sourceinsight.com/public/index.html

Custom Language files for adding new language support to Source Insight.
To import a custom language file into Source Insight

1. Select Options > Preferences. Click the Languages tab.

2. Click the Import button. Select and load the custom language file (.CLF)

3. You should now see the new language in the list of languages.

4. Click the Document Types button to open the Document Options dialog box.

5. If you don't have a document type already created for the type of language file, you will need to create one now. If you already have a document type created, select it in the list and go to step 7.

6. Click the Add Type button to create a new document type.  Give it a name that describes the type of file. For example, "Ant File". Click OK and then fill in the file filter text box with a wildcard.  For example, "*.ant".

7. In the Parsing section of the Document Options dialog box, select the newly imported language in the language drop-down list. This is what associates your document type with the custom language.

8. Click the Close button to close Document Options. Then click OK to close the Preferences dialog box.

==》》style文件:PHP-Styles.CF3

菜單“options”-》“Style Properties”,在彈出窗口中,選擇“load”,選中style文件:PHP-Styles.CF3。確定後,你可以在左側的“Style Name”列表中看見增加了四個新的php-function,php-keyword,php-control,php-operator。在點擊“Done”確定後,就好了。

以上沒什麼技術含量,就是體力活。用過SI,你會更喜歡它,沒有用過,推薦你用。
  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章