Skip to content

Overview of architecture

Ivan Veselov edited this page Jul 3, 2018 · 4 revisions

After clicking at 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 user.

Everything that is connected with metrics calculation is taken from another plugin: MetricsReloaded. Each metric is represented by a MetricInstance — actual metric, upper and lower thresholds and enable flag. All MetricInstances are stored in MetricsProfile. Metrics are calculeted by MetricsExecutionContextImpl and the results are stored inside MetricsRun.

Entity is an object extracted from some project (class, method, field). Each of these objects has a vector of features that contains a subset of metrics from MetricsRun. Also each Entity has a list of relevant properties. RelevantProperties is a storage of classes, methods and fields that are somehow related to the original Entity. Each of these properties has a certain weight.

After metrics calculation has been done RefactoringExecutionContext runs EntitySearcher to find entities in a given scope. In order to filter unacceptable objects EntitySearcher uses FinderStrategy. FinderStrategy is also responsible for giving initial weights to properties described in the previous paragraph. As a result EntitySearcher produces EntitySearchResult that stores all found entities with their RelevantProperties.

After all the preparations each Algorithm is run, receives EntitySearchResult as its input and produces refactoring suggests as its output.

Clone this wiki locally