-
Notifications
You must be signed in to change notification settings - Fork 3
Overview of architecture
After clicking the Search for refactorings... button AutomaticRefactoringAction
is run by IDEA internal mechanisms. It receives current Project
and AnalysisScope
as its parameters. Project
is just a current project and AnalysisScope
stores all the data (set of files) that should be processed. Both these objects are passed to a RefactoringExecutionContext
which calculates metrics, executes various algorithms and shows the results to the user.
Metrics calculation is performed by another plugin, MetricsReloaded, that we build upon. Each metric is represented by a MetricInstance
— actual metric, upper and lower thresholds and enable flag. All MetricInstance
s are stored in MetricsProfile
. Metrics are calculated by MetricsExecutionContextImpl
and the results are stored in MetricsRun
.
CodeEntity
represents a project entity (class, method or field). Each of these entities has a list of relevant properties. RelevantProperties
is a storage of classes, methods, and fields that are somehow related to the original CodeEntity
. Each of these properties has a certain weight.
After metrics calculation is over RefactoringExecutionContext
runs EntitySearcher
to find entities in a given scope. In order to filter unacceptable entities EntitySearcher
uses FinderStrategy
. FinderStrategy
is also responsible for giving initial weights to properties described above. EntitySearcher
produces EntitySearchResult
that is then converted to EntitiesStorage
which stores all found entities with their RelevantProperties
. EntitySearchResult
is obsolete and should be removed.
Finally, each Algorithm
is being run. As an input it receives AttributesStorage
which stores ElementAttributes
— a sort of a proxy for each CodeEntity
from the original EntityStorage
designed specifically for this particular Algorithm
. Namely, ElementAttributes
has additional vector of features that contains a subset of metrics from MetricsRun
. And this subset is defined by the Algorithm
these attributes were constructed for. As an output Algorithm
produces a list of suggested refactorings.
Algorithm
is a general interface for algorithm wich searches for refactorings. It doesn't represent one single run of an algorithm but it represents an "idea" of algorithm and it is supposed that its execute
method can be run several times. In order to help implement such an interface properly AbstractAlgorithm
class is introduced. It covers some implementation concerns which are thought to be common.