Community
Participate
Working Groups
The TraitUtils.parse() method traverse source modules using an AST visitor with inefficient implementation. This method parses source module to find trait use statements. According to the definition of traits [1], trait use statements are defined directly inside class declaration. The implementation of the AST visitor can be optimized to meet this definition and at the same time to avoid traversing the AST tree deeper than necessary. The TraitUtils.parse() method is used by utilities like TraitUtils.getTraitMethods() and TraitUtils.getTraitFields(), which in turn are used by more generic utilities like PHPModelUtils.getTypeMethods() and PHPModelUtils.getFieldMethods(). So, the impact of the performance of TraitUtils.parse() is pretty widespread. [1] http://php.net/manual/en/language.oop5.traits.php
Changed pushed to Gerrit: https://git.eclipse.org/r/18220
Gerrit change merged: https://git.eclipse.org/r/#/c/18220/ thank you Kaloyan for the contribution!
I found an issue with my change. I wrongly assumed that PHP classes can be declared only in the global scope, while in reality they can appear also in if-then-else, for/while loops and other kinds of blocks. I'll push a correction soon.
Here is the new change in Gerrit: https://git.eclipse.org/r/18484/ There is a new TypeDeclarationVisitor implement that focuses only on visiting classes, interfaces and traits with optimized performance. The main gain comes from the fact that PHP types cannot be nested. The TraitUseStatementVisitor now extends the TypeDeclarationVisitor. Tests added to cover the problematic cases from the initial patch.
Your change merged into master. Great work Kaloyan!
Closing