Phalanger Intellisense - It Is the Significant Extension of the Previous Phalanger Language Integration
Total Page:16
File Type:pdf, Size:1020Kb
Univerzita Karlova v Praze Matematicko-fyzikální fakulta DIPLOMOVÁ PRÁCE Jakub Míšek IntelliSense implementation of a dynamic language Katedra softwarového inženýrství Vedoucí diplomové práce: RNDr. Filip Zavoral, Ph.D. Studijní program: Informatika, Softwarové systémy Děkuji Filipu Zavoralovi za jeho odbornou podporu a též za jeho trpělivost při vedení této práce. Prohlašuji, že jsem svou diplomovou práci napsal samostatně a výhradně s použitím citovaných pramenů. Souhlasím se zapůjčováním práce. Jakub Míšek V Praze dne - 2 - 1 Contents 2 INTRODUCTION .............................................................................................................................................. 6 3 LANGUAGE INTEGRATION ............................................................................................................................... 8 3.1 INTELLISENSE ................................................................................................................................................................ 8 3.2 INTEGRATION ARCHITECTURE ........................................................................................................................................... 9 3.3 LANGUAGE INTEGRATION FOR MICROSOFT VISUAL STUDIO IMPLEMENTATION ........................................................................ 11 3.3.1 Visual Studio Language Service architecture ................................................................................................ 11 3.3.2 Visual Studio Language Service features ...................................................................................................... 13 3.3.2.1 Syntax highlighting ................................................................................................................................................ 13 3.3.2.2 Brace matching ...................................................................................................................................................... 13 3.3.2.3 Error underlining ................................................................................................................................................... 13 3.3.2.4 Code collapsing...................................................................................................................................................... 14 3.3.2.5 Navigation bar ....................................................................................................................................................... 14 4 SOURCE CODE PARSER .................................................................................................................................. 15 4.1 PHALANGER PROJECT ................................................................................................................................................... 16 4.2 LEXICAL ANALYSIS ........................................................................................................................................................ 17 4.2.1 Optimizing lexicalization ............................................................................................................................... 17 4.2.2 Syntax highlighting ....................................................................................................................................... 18 4.2.3 Brace matching ............................................................................................................................................. 18 4.3 SYNTACTIC ANALYSIS .................................................................................................................................................... 19 4.3.1 Syntax tree .................................................................................................................................................... 20 4.3.2 Syntax errors ................................................................................................................................................. 20 4.3.3 Code collapsing ............................................................................................................................................. 21 4.4 LOCAL AST ................................................................................................................................................................ 22 4.5 BACKUS-NAUR FORM ................................................................................................................................................... 23 5 CODE ANALYSIS ............................................................................................................................................ 24 5.1 INTELLISENSE TREE ARCHITECTURE .................................................................................................................................. 26 5.1.1 Scope node .................................................................................................................................................... 27 5.1.2 Declaration node........................................................................................................................................... 28 5.1.2.1 Declaration node implementation ........................................................................................................................ 30 5.1.3 Analyzers ....................................................................................................................................................... 31 5.2 DYNAMIC INFORMATION ............................................................................................................................................... 33 5.2.1 Type resolving ............................................................................................................................................... 34 5.2.2 Expression patterns....................................................................................................................................... 34 5.2.3 Dynamic members ........................................................................................................................................ 36 5.2.4 Dynamic evaluation ...................................................................................................................................... 36 5.3 LINKING TREES ............................................................................................................................................................ 36 5.3.1 Reference cycling .......................................................................................................................................... 37 5.3.2 Memory leaks ............................................................................................................................................... 38 5.4 TREE CACHE................................................................................................................................................................ 38 - 3 - 5.4.1 Trees updating .............................................................................................................................................. 38 6 MAPPING INTO INTELLISENSE TREE ............................................................................................................... 39 6.1 PHP SOURCE FILE ........................................................................................................................................................ 40 6.1.1 Static information ......................................................................................................................................... 40 6.1.2 Dynamic information .................................................................................................................................... 42 6.1.3 Documentary comments ............................................................................................................................... 43 6.1.4 Error underlining ........................................................................................................................................... 43 6.2 .NET ASSEMBLY .......................................................................................................................................................... 44 6.2.1 Assembly processing ..................................................................................................................................... 45 6.2.2 XML documentation...................................................................................................................................... 46 6.3 NATIVE PHP SYMBOLS ................................................................................................................................................. 46 6.3.1 Native symbols definition ............................................................................................................................. 46 6.4 OPTIMIZING ............................................................................................................................................................... 47 6.4.1 Lazy mapping ................................................................................................................................................ 48 6.4.2 Multi-threading ............................................................................................................................................. 48 6.4.3 Disk cache ....................................................................................................................................................