CFA classes rename: remove 'Kotlin' prefix

This commit is contained in:
Mikhail Glukhikh
2015-12-11 15:40:12 +03:00
parent 8db3fb03f9
commit d2fce9b16d
8 changed files with 51 additions and 50 deletions
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import java.util.List;
import java.util.Map;
public interface KotlinControlFlowBuilder {
public interface ControlFlowBuilder {
// Subroutines
void enterSubroutine(@NotNull KtElement subroutine);
@@ -30,10 +30,10 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import java.util.List;
import java.util.Map;
public abstract class KotlinControlFlowBuilderAdapter implements KotlinControlFlowBuilder {
public abstract class ControlFlowBuilderAdapter implements ControlFlowBuilder {
@NotNull
protected abstract KotlinControlFlowBuilder getDelegateBuilder();
protected abstract ControlFlowBuilder getDelegateBuilder();
@Override
public void loadUnit(@NotNull KtExpression expression) {
@@ -73,14 +73,14 @@ import static org.jetbrains.kotlin.resolve.BindingContext.*;
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType;
public class KotlinFlowInformationProvider {
public class ControlFlowInformationProvider {
private final KtElement subroutine;
private final Pseudocode pseudocode;
private final BindingTrace trace;
private PseudocodeVariablesData pseudocodeVariablesData;
private KotlinFlowInformationProvider(
private ControlFlowInformationProvider(
@NotNull KtElement declaration,
@NotNull BindingTrace trace,
@NotNull Pseudocode pseudocode
@@ -90,11 +90,11 @@ public class KotlinFlowInformationProvider {
this.pseudocode = pseudocode;
}
public KotlinFlowInformationProvider(
public ControlFlowInformationProvider(
@NotNull KtElement declaration,
@NotNull BindingTrace trace
) {
this(declaration, trace, new KotlinControlFlowProcessor(trace).generatePseudocode(declaration));
this(declaration, trace, new ControlFlowProcessor(trace).generatePseudocode(declaration));
}
public PseudocodeVariablesData getPseudocodeVariablesData() {
@@ -211,8 +211,8 @@ public class KotlinFlowInformationProvider {
(CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration);
KotlinType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
KotlinFlowInformationProvider providerForLocalDeclaration =
new KotlinFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
ControlFlowInformationProvider providerForLocalDeclaration =
new ControlFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
providerForLocalDeclaration.checkFunction(expectedType);
}
@@ -649,7 +649,7 @@ public class KotlinFlowInformationProvider {
public void markUnusedExpressions() {
final Map<Instruction, DiagnosticFactory<?>> reportedDiagnosticMap = Maps.newHashMap();
PseudocodeTraverserKt.traverse(
pseudocode, TraversalOrder.FORWARD, new KotlinFlowInformationProvider.FunctionVoid1<Instruction>() {
pseudocode, TraversalOrder.FORWARD, new ControlFlowInformationProvider.FunctionVoid1<Instruction>() {
@Override
public void execute(@NotNull Instruction instruction) {
if (!(instruction instanceof KtElementInstruction)) return;
@@ -677,7 +677,7 @@ public class KotlinFlowInformationProvider {
public void markStatements() {
PseudocodeTraverserKt.traverse(
pseudocode, TraversalOrder.FORWARD, new KotlinFlowInformationProvider.FunctionVoid1<Instruction>() {
pseudocode, TraversalOrder.FORWARD, new ControlFlowInformationProvider.FunctionVoid1<Instruction>() {
@Override
public void execute(@NotNull Instruction instruction) {
PseudoValue value = instruction instanceof InstructionWithValue
@@ -695,7 +695,7 @@ public class KotlinFlowInformationProvider {
public void markIfWithoutElse() {
PseudocodeTraverserKt.traverse(
pseudocode, TraversalOrder.FORWARD, new KotlinFlowInformationProvider.FunctionVoid1<Instruction>() {
pseudocode, TraversalOrder.FORWARD, new ControlFlowInformationProvider.FunctionVoid1<Instruction>() {
@Override
public void execute(@NotNull Instruction instruction) {
PseudoValue value = instruction instanceof InstructionWithValue
@@ -717,7 +717,7 @@ public class KotlinFlowInformationProvider {
public void markWhenWithoutElse() {
PseudocodeTraverserKt.traverse(
pseudocode, TraversalOrder.FORWARD, new KotlinFlowInformationProvider.FunctionVoid1<Instruction>() {
pseudocode, TraversalOrder.FORWARD, new ControlFlowInformationProvider.FunctionVoid1<Instruction>() {
@Override
public void execute(@NotNull Instruction instruction) {
PseudoValue value = instruction instanceof InstructionWithValue
@@ -29,7 +29,7 @@ import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.cfg.pseudocode.KotlinControlFlowInstructionsGenerator;
import org.jetbrains.kotlin.cfg.pseudocode.ControlFlowInstructionsGenerator;
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue;
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode;
import org.jetbrains.kotlin.cfg.pseudocode.PseudocodeImpl;
@@ -61,17 +61,17 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import java.util.*;
import static org.jetbrains.kotlin.cfg.KotlinControlFlowBuilder.PredefinedOperation.*;
import static org.jetbrains.kotlin.cfg.ControlFlowBuilder.PredefinedOperation.*;
import static org.jetbrains.kotlin.diagnostics.Errors.*;
import static org.jetbrains.kotlin.lexer.KtTokens.*;
public class KotlinControlFlowProcessor {
public class ControlFlowProcessor {
private final KotlinControlFlowBuilder builder;
private final ControlFlowBuilder builder;
private final BindingTrace trace;
public KotlinControlFlowProcessor(BindingTrace trace) {
this.builder = new KotlinControlFlowInstructionsGenerator();
public ControlFlowProcessor(BindingTrace trace) {
this.builder = new ControlFlowInstructionsGenerator();
this.trace = trace;
}
@@ -127,7 +127,7 @@ public class KotlinControlFlowProcessor {
}
private class CFPVisitor extends KtVisitorVoid {
private final KotlinControlFlowBuilder builder;
private final ControlFlowBuilder builder;
private final KtVisitorVoid conditionVisitor = new KtVisitorVoid() {
@@ -170,11 +170,11 @@ public class KotlinControlFlowProcessor {
@Override
public void visitKtElement(@NotNull KtElement element) {
throw new UnsupportedOperationException("[JetControlFlowProcessor] " + element.toString());
throw new UnsupportedOperationException("[ControlFlowProcessor] " + element.toString());
}
};
private CFPVisitor(@NotNull KotlinControlFlowBuilder builder) {
private CFPVisitor(@NotNull ControlFlowBuilder builder) {
this.builder = builder;
}
@@ -411,7 +411,7 @@ public class KotlinControlFlowProcessor {
generateInstructions(right);
}
builder.bindLabel(resultLabel);
KotlinControlFlowBuilder.PredefinedOperation operation = operationType == ANDAND ? AND : OR;
ControlFlowBuilder.PredefinedOperation operation = operationType == ANDAND ? AND : OR;
builder.predefinedOperation(expression, operation, elementsToValues(Arrays.asList(left, right)));
}
@@ -35,32 +35,32 @@ import org.jetbrains.kotlin.types.KotlinType;
import java.util.*;
public class KotlinControlFlowInstructionsGenerator extends KotlinControlFlowBuilderAdapter {
private KotlinControlFlowBuilder builder = null;
public class ControlFlowInstructionsGenerator extends ControlFlowBuilderAdapter {
private ControlFlowBuilder builder = null;
private final Stack<LoopInfo> loopInfo = new Stack<LoopInfo>();
private final Stack<LexicalScope> lexicalScopes = new Stack<LexicalScope>();
private final Map<KtElement, BreakableBlockInfo> elementToBlockInfo = new HashMap<KtElement, BreakableBlockInfo>();
private int labelCount = 0;
private final Stack<KotlinControlFlowInstructionsGeneratorWorker> builders = new Stack<KotlinControlFlowInstructionsGeneratorWorker>();
private final Stack<ControlFlowInstructionsGeneratorWorker> builders = new Stack<ControlFlowInstructionsGeneratorWorker>();
private final Stack<BlockInfo> allBlocks = new Stack<BlockInfo>();
@NotNull
@Override
protected KotlinControlFlowBuilder getDelegateBuilder() {
protected ControlFlowBuilder getDelegateBuilder() {
return builder;
}
private void pushBuilder(KtElement scopingElement, KtElement subroutine) {
KotlinControlFlowInstructionsGeneratorWorker worker = new KotlinControlFlowInstructionsGeneratorWorker(scopingElement, subroutine);
ControlFlowInstructionsGeneratorWorker worker = new ControlFlowInstructionsGeneratorWorker(scopingElement, subroutine);
builders.push(worker);
builder = worker;
}
private KotlinControlFlowInstructionsGeneratorWorker popBuilder(@NotNull KtElement element) {
KotlinControlFlowInstructionsGeneratorWorker worker = builders.pop();
private ControlFlowInstructionsGeneratorWorker popBuilder(@NotNull KtElement element) {
ControlFlowInstructionsGeneratorWorker worker = builders.pop();
if (!builders.isEmpty()) {
builder = builders.peek();
}
@@ -88,15 +88,15 @@ public class KotlinControlFlowInstructionsGenerator extends KotlinControlFlowBui
public Pseudocode exitSubroutine(@NotNull KtElement subroutine) {
super.exitSubroutine(subroutine);
builder.exitLexicalScope(subroutine);
KotlinControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
ControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
if (!builders.empty()) {
KotlinControlFlowInstructionsGeneratorWorker builder = builders.peek();
ControlFlowInstructionsGeneratorWorker builder = builders.peek();
builder.declareFunction(subroutine, worker.getPseudocode());
}
return worker.getPseudocode();
}
private class KotlinControlFlowInstructionsGeneratorWorker implements KotlinControlFlowBuilder {
private class ControlFlowInstructionsGeneratorWorker implements ControlFlowBuilder {
private final PseudocodeImpl pseudocode;
private final Label error;
@@ -115,7 +115,7 @@ public class KotlinControlFlowInstructionsGenerator extends KotlinControlFlowBui
}
};
private KotlinControlFlowInstructionsGeneratorWorker(@NotNull KtElement scopingElement, @NotNull KtElement returnSubroutine) {
private ControlFlowInstructionsGeneratorWorker(@NotNull KtElement scopingElement, @NotNull KtElement returnSubroutine) {
this.pseudocode = new PseudocodeImpl(scopingElement);
this.error = pseudocode.createLabel("error", null);
this.sink = pseudocode.createLabel("sink", null);
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.cfg.pseudocode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cfg.KotlinControlFlowProcessor;
import org.jetbrains.kotlin.cfg.ControlFlowProcessor;
import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction;
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.AccessTarget;
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.AccessValueInstruction;
@@ -84,7 +84,7 @@ public class PseudocodeUtil {
public void report(@NotNull Diagnostic diagnostic) {
}
};
return new KotlinControlFlowProcessor(mockTrace).generatePseudocode(declaration);
return new ControlFlowProcessor(mockTrace).generatePseudocode(declaration);
}
@Nullable
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.cfg.KotlinFlowInformationProvider;
import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider;
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
@@ -68,20 +68,21 @@ public class ControlFlowAnalyzer {
}
private void checkSecondaryConstructor(@NotNull KtSecondaryConstructor constructor) {
KotlinFlowInformationProvider flowInformationProvider = new KotlinFlowInformationProvider(constructor, trace);
flowInformationProvider.checkDeclaration();
flowInformationProvider.checkFunction(builtIns.getUnitType());
ControlFlowInformationProvider controlFlowInformationProvider = new ControlFlowInformationProvider(constructor, trace);
controlFlowInformationProvider.checkDeclaration();
controlFlowInformationProvider.checkFunction(builtIns.getUnitType());
}
private void checkDeclarationContainer(@NotNull BodiesResolveContext c, KtDeclarationContainer declarationContainer) {
// A pseudocode of class/object initialization corresponds to a class/object
// or initialization of properties corresponds to a package declared in a file
KotlinFlowInformationProvider flowInformationProvider = new KotlinFlowInformationProvider((KtElement) declarationContainer, trace);
ControlFlowInformationProvider
controlFlowInformationProvider = new ControlFlowInformationProvider((KtElement) declarationContainer, trace);
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
flowInformationProvider.checkForLocalClassOrObjectMode();
controlFlowInformationProvider.checkForLocalClassOrObjectMode();
return;
}
flowInformationProvider.checkDeclaration();
controlFlowInformationProvider.checkDeclaration();
}
private void checkProperty(@NotNull BodiesResolveContext c, KtProperty property, PropertyDescriptor propertyDescriptor) {
@@ -97,12 +98,12 @@ public class ControlFlowAnalyzer {
private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType) {
if (!function.hasBody()) return;
KotlinFlowInformationProvider flowInformationProvider = new KotlinFlowInformationProvider(function, trace);
ControlFlowInformationProvider controlFlowInformationProvider = new ControlFlowInformationProvider(function, trace);
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
flowInformationProvider.checkForLocalClassOrObjectMode();
controlFlowInformationProvider.checkForLocalClassOrObjectMode();
return;
}
flowInformationProvider.checkDeclaration();
flowInformationProvider.checkFunction(expectedReturnType);
controlFlowInformationProvider.checkDeclaration();
controlFlowInformationProvider.checkFunction(expectedReturnType);
}
}
@@ -23,7 +23,7 @@ import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.asJava.KotlinCodeBlockModificationListener
import org.jetbrains.kotlin.cfg.KotlinFlowInformationProvider
import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider
import org.jetbrains.kotlin.container.get
import org.jetbrains.kotlin.context.SimpleGlobalContext
import org.jetbrains.kotlin.context.withModule
@@ -300,7 +300,7 @@ public class ResolveElementCache(
}
val controlFlowTrace = DelegatingBindingTrace(trace.getBindingContext(), "Element control flow resolve", resolveElement)
KotlinFlowInformationProvider(resolveElement, controlFlowTrace).checkDeclaration()
ControlFlowInformationProvider(resolveElement, controlFlowTrace).checkDeclaration()
controlFlowTrace.addOwnDataTo(trace, null, false)
return Pair(trace.getBindingContext(), statementFilterUsed)
@@ -430,7 +430,7 @@ public class ResolveElementCache(
forceResolveAnnotationsInside(property)
for (accessor in property.getAccessors()) {
KotlinFlowInformationProvider(accessor, trace).checkDeclaration()
ControlFlowInformationProvider(accessor, trace).checkDeclaration()
}
return trace