Search in sources :

Example 1 with Result

use of com.intellij.refactoring.typeCook.deductive.builder.Result in project intellij-community by JetBrains.

the class TypeCookProcessor method findUsages.

@NotNull
protected UsageInfo[] findUsages() {
    final SystemBuilder systemBuilder = new SystemBuilder(myProject, mySettings);
    final ReductionSystem commonSystem = systemBuilder.build(myElements);
    myResult = new Result(commonSystem);
    final ReductionSystem[] systems = commonSystem.isolate();
    for (final ReductionSystem system : systems) {
        if (system != null) {
            final ResolverTree tree = new ResolverTree(system);
            tree.resolve();
            final Binding solution = tree.getBestSolution();
            if (solution != null) {
                myResult.incorporateSolution(solution);
            }
        }
    }
    final Set<PsiElement> changedItems = myResult.getCookedElements();
    final UsageInfo[] usages = new UsageInfo[changedItems.size()];
    int i = 0;
    for (final PsiElement element : changedItems) {
        if (!(element instanceof PsiTypeCastExpression)) {
            usages[i++] = new UsageInfo(element) {

                public String getTooltipText() {
                    return myResult.getCookedType(element).getCanonicalText();
                }
            };
        } else {
            usages[i++] = new UsageInfo(element);
        }
    }
    return usages;
}
Also used : ReductionSystem(com.intellij.refactoring.typeCook.deductive.builder.ReductionSystem) Binding(com.intellij.refactoring.typeCook.deductive.resolver.Binding) PsiTypeCastExpression(com.intellij.psi.PsiTypeCastExpression) Result(com.intellij.refactoring.typeCook.deductive.builder.Result) ResolverTree(com.intellij.refactoring.typeCook.deductive.resolver.ResolverTree) SystemBuilder(com.intellij.refactoring.typeCook.deductive.builder.SystemBuilder) PsiElement(com.intellij.psi.PsiElement) UsageInfo(com.intellij.usageView.UsageInfo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiTypeCastExpression (com.intellij.psi.PsiTypeCastExpression)1 ReductionSystem (com.intellij.refactoring.typeCook.deductive.builder.ReductionSystem)1 Result (com.intellij.refactoring.typeCook.deductive.builder.Result)1 SystemBuilder (com.intellij.refactoring.typeCook.deductive.builder.SystemBuilder)1 Binding (com.intellij.refactoring.typeCook.deductive.resolver.Binding)1 ResolverTree (com.intellij.refactoring.typeCook.deductive.resolver.ResolverTree)1 UsageInfo (com.intellij.usageView.UsageInfo)1 NotNull (org.jetbrains.annotations.NotNull)1