From 0bf65bfe1e3a0c2eabac10ac5d4e87abfc80dd09 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 26 May 2012 12:46:10 +0400 Subject: [PATCH] get rid of JetPseudocodeTrace and JetControlFlowDataTraceFactory --- .../compiler/KotlinToJVMBytecodeCompiler.java | 2 - .../jet/lang/cfg/JetControlFlowBuilder.java | 3 +- .../cfg/JetControlFlowBuilderAdapter.java | 5 +- .../jet/lang/cfg/JetControlFlowProcessor.java | 21 +++- .../lang/cfg/JetFlowInformationProvider.java | 101 ++++-------------- .../JetControlFlowDataTraceFactory.java | 36 ------- .../JetControlFlowInstructionsGenerator.java | 25 ++--- .../cfg/pseudocode/JetPseudocodeTrace.java | 54 ---------- .../lang/cfg/pseudocode/PseudocodeImpl.java | 6 +- .../jet/lang/resolve/AnalyzingUtils.java | 7 -- .../jet/lang/resolve/ControlFlowAnalyzer.java | 21 ++-- .../jet/lang/resolve/TopDownAnalyzer.java | 5 +- .../tests/org/jetbrains/jet/JetTestUtils.java | 5 +- .../jetbrains/jet/cfg/JetControlFlowTest.java | 72 ++++++++----- .../jet/checkers/CheckerTestUtilTest.java | 4 +- .../jet/checkers/JetDiagnosticsTest.java | 5 +- .../jvm/compiler/ReadJavaBinaryClassTest.java | 4 +- .../jet/codegen/CodegenTestCase.java | 4 +- .../jet/codegen/GenerationUtils.java | 4 +- .../jet/resolve/DescriptorRendererTest.java | 4 +- .../jet/resolve/ExpectedResolveData.java | 4 +- .../JetDefaultModalityModifiersTest.java | 2 - .../libraries/JetSourceNavigationHelper.java | 4 +- .../jet/di/AllInjectorsGenerator.java | 2 - 24 files changed, 118 insertions(+), 282 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.java delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.java diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java index 433574fa0ac..f5077050bb4 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java @@ -34,7 +34,6 @@ import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport; import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation; import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.resolve.name.FqName; @@ -246,7 +245,6 @@ public class KotlinToJVMBytecodeCompiler { public AnalyzeExhaust invoke() { return AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration( environment.getProject(), environment.getSourceFiles(), filesToAnalyzeCompletely, - JetControlFlowDataTraceFactory.EMPTY, configuration.getEnvironment().getCompilerDependencies()); } }, environment.getSourceFiles() diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java index 18d4ddfd1c1..b1822200b66 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.cfg; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode; import org.jetbrains.jet.lang.psi.*; import java.util.List; @@ -64,7 +65,7 @@ public interface JetControlFlowBuilder { // Subroutines void enterSubroutine(@NotNull JetDeclaration subroutine); - void exitSubroutine(@NotNull JetDeclaration subroutine); + Pseudocode exitSubroutine(@NotNull JetDeclaration subroutine); @NotNull JetElement getCurrentSubroutine(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java index e3f6d4df970..cb3d67b2b64 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.cfg; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode; import org.jetbrains.jet.lang.psi.*; import java.util.List; @@ -157,9 +158,9 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder { } @Override - public void exitSubroutine(@NotNull JetDeclaration subroutine) { + public Pseudocode exitSubroutine(@NotNull JetDeclaration subroutine) { assert builder != null; - builder.exitSubroutine(subroutine); + return builder.exitSubroutine(subroutine); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index 004e2cc739a..20837493531 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -21,6 +21,9 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode; +import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowInstructionsGenerator; +import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; @@ -45,12 +48,22 @@ public class JetControlFlowProcessor { private final JetControlFlowBuilder builder; private final BindingTrace trace; - public JetControlFlowProcessor(BindingTrace trace, JetControlFlowBuilder builder) { - this.builder = builder; + public JetControlFlowProcessor(BindingTrace trace) { + this.builder = new JetControlFlowInstructionsGenerator(); this.trace = trace; } - public void generate(@NotNull JetDeclaration subroutine) { + //todo + public Pseudocode generatePseudocode(@NotNull JetDeclaration subroutine) { + Pseudocode pseudocode = generate(subroutine); + ((PseudocodeImpl)pseudocode).postProcess(); + for (Pseudocode localPseudocode : pseudocode.getLocalDeclarations()) { + ((PseudocodeImpl)localPseudocode).postProcess(); + } + return pseudocode; + } + + public Pseudocode generate(@NotNull JetDeclaration subroutine) { builder.enterSubroutine(subroutine); if (subroutine instanceof JetDeclarationWithBody) { JetDeclarationWithBody declarationWithBody = (JetDeclarationWithBody) subroutine; @@ -67,7 +80,7 @@ public class JetControlFlowProcessor { else { subroutine.accept(new CFPVisitor(false)); } - builder.exitSubroutine(subroutine); + return builder.exitSubroutine(subroutine); } private void processLocalDeclaration(@NotNull JetDeclaration subroutine) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java index a60398498ff..01558871026 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java @@ -17,7 +17,6 @@ package org.jetbrains.jet.lang.cfg; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; @@ -33,12 +32,14 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.DescriptorUtils; -import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.JetMainDetector; -import java.util.*; +import java.util.Collection; +import java.util.List; +import java.util.Set; import static org.jetbrains.jet.lang.diagnostics.Errors.*; import static org.jetbrains.jet.lang.resolve.BindingContext.CAPTURED_IN_CLOSURE; @@ -49,67 +50,22 @@ import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; */ public class JetFlowInformationProvider { - private final Map pseudocodeMap; - private final Map pseudocodeDataMap; + private final JetDeclaration subroutine; + private final Pseudocode pseudocode; + private final PseudocodeData pseudocodeData; private BindingTrace trace; - public JetFlowInformationProvider(@NotNull JetDeclaration declaration, @NotNull final JetExpression bodyExpression, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory, @NotNull BindingTrace trace) { - this.trace = trace; - final JetPseudocodeTrace pseudocodeTrace = flowDataTraceFactory.createTrace(declaration); - pseudocodeMap = new LinkedHashMap(); - pseudocodeDataMap = new HashMap(); - final Map representativeInstructions = new HashMap(); - final Map loopInfo = Maps.newHashMap(); - JetPseudocodeTrace wrappedTrace = new JetPseudocodeTrace() { - @Override - public void recordControlFlowData(@NotNull JetElement element, @NotNull Pseudocode pseudocode) { - pseudocodeTrace.recordControlFlowData(element, pseudocode); - pseudocodeMap.put(element, pseudocode); - } - - @Override - public void recordRepresentativeInstruction(@NotNull JetElement element, @NotNull Instruction instruction) { - Instruction oldValue = representativeInstructions.put(element, instruction); -// assert oldValue == null : element.getText(); - pseudocodeTrace.recordRepresentativeInstruction(element, instruction); - } - - @Override - public void recordLoopInfo(JetExpression expression, LoopInfo blockInfo) { - loopInfo.put(expression, blockInfo); - pseudocodeTrace.recordLoopInfo(expression, blockInfo); - } - - @Override - public void close() { - pseudocodeTrace.close(); - List values = Lists.newArrayList(pseudocodeMap.values()); - Collections.reverse(values); - for (Pseudocode pseudocode : values) { - pseudocode.postProcess(); - } - } - }; - JetControlFlowInstructionsGenerator instructionsGenerator = new JetControlFlowInstructionsGenerator(wrappedTrace); - new JetControlFlowProcessor(trace, instructionsGenerator).generate(declaration); - wrappedTrace.close(); - } + public JetFlowInformationProvider( + @NotNull JetDeclaration declaration, + @NotNull BindingTrace trace) { - private PseudocodeData getPseudocodeData(@NotNull JetElement element) { - PseudocodeData pseudocodeData = pseudocodeDataMap.get(element); - if (pseudocodeData == null) { - Pseudocode pseudocode = pseudocodeMap.get(element); - assert pseudocode != null; - pseudocodeData = new PseudocodeData(pseudocode, trace); - pseudocodeDataMap.put(element, pseudocodeData); - } - return pseudocodeData; + subroutine = declaration; + this.trace = trace; + pseudocode = new JetControlFlowProcessor(trace).generatePseudocode(declaration); + pseudocodeData = new PseudocodeData(pseudocode, trace); } - private void collectReturnExpressions(@NotNull JetElement subroutine, @NotNull final Collection returnedExpressions) { - Pseudocode pseudocode = pseudocodeMap.get(subroutine); - assert pseudocode != null; - + private void collectReturnExpressions(@NotNull final Collection returnedExpressions) { final Set instructions = Sets.newHashSet(pseudocode.getInstructions()); SubroutineExitInstruction exitInstruction = pseudocode.getExitInstruction(); for (Instruction previousInstruction : exitInstruction.getPreviousInstructions()) { @@ -164,14 +120,16 @@ public class JetFlowInformationProvider { } } - public void checkDefiniteReturn(@NotNull final JetDeclarationWithBody function, final @NotNull JetType expectedReturnType) { + public void checkDefiniteReturn(final @NotNull JetType expectedReturnType) { + assert subroutine instanceof JetDeclarationWithBody; + JetDeclarationWithBody function = (JetDeclarationWithBody) subroutine; assert function instanceof JetDeclaration; JetExpression bodyExpression = function.getBodyExpression(); if (bodyExpression == null) return; List returnedExpressions = Lists.newArrayList(); - collectReturnExpressions(function.asElement(), returnedExpressions); + collectReturnExpressions(returnedExpressions); boolean nothingReturned = returnedExpressions.isEmpty(); @@ -211,9 +169,6 @@ public class JetFlowInformationProvider { } private Set collectUnreachableCode(@NotNull JetElement subroutine) { - Pseudocode pseudocode = pseudocodeMap.get(subroutine); - assert pseudocode != null; - Collection unreachableElements = Lists.newArrayList(); for (Instruction deadInstruction : pseudocode.getDeadInstructions()) { if (deadInstruction instanceof JetElementInstruction && @@ -228,12 +183,11 @@ public class JetFlowInformationProvider { //////////////////////////////////////////////////////////////////////////////// // Uninitialized variables analysis - public void markUninitializedVariables(@NotNull JetElement subroutine, final boolean processLocalDeclaration) { + public void markUninitializedVariables(final boolean processLocalDeclaration) { final Collection varWithUninitializedErrorGenerated = Sets.newHashSet(); final Collection varWithValReassignErrorGenerated = Sets.newHashSet(); final boolean processClassOrObject = subroutine instanceof JetClassOrObject; - final PseudocodeData pseudocodeData = getPseudocodeData(subroutine); pseudocodeData.traverseInstructionsGraph(true, true, new PseudocodeData.TraverseInstructionGraphStrategy() { @Override public void execute(@NotNull Instruction instruction, @NotNull DeclarationData declarationData, @NotNull InstructionData instructionData) { @@ -447,20 +401,10 @@ public class JetFlowInformationProvider { } } - private void analyzeLocalDeclarations(Pseudocode pseudocode, boolean processLocalDeclaration) { - for (Instruction instruction : pseudocode.getInstructions()) { - if (instruction instanceof LocalDeclarationInstruction) { - JetElement element = ((LocalDeclarationInstruction) instruction).getElement(); - markUninitializedVariables(element, processLocalDeclaration); - } - } - } - //////////////////////////////////////////////////////////////////////////////// // "Unused variable" & "unused value" analyses - public void markUnusedVariables(@NotNull JetElement subroutine) { - final PseudocodeData pseudocodeData = getPseudocodeData(subroutine); + public void markUnusedVariables() { pseudocodeData.traverseInstructionsGraph(true, false, new PseudocodeData.TraverseInstructionGraphStrategy() { @Override public void execute(@NotNull Instruction instruction, @NotNull DeclarationData declarationData, @NotNull InstructionData instructionData) { @@ -541,8 +485,7 @@ public class JetFlowInformationProvider { //////////////////////////////////////////////////////////////////////////////// // "Unused literals" in block - public void markUnusedLiteralsInBlock(@NotNull JetElement subroutine) { - Pseudocode pseudocode = pseudocodeMap.get(subroutine); + public void markUnusedLiteralsInBlock() { assert pseudocode != null; JetControlFlowGraphTraverser traverser = JetControlFlowGraphTraverser.create(pseudocode, true, true); traverser.traverseAndAnalyzeInstructionGraph(new JetControlFlowGraphTraverser.InstructionDataAnalyzeStrategy() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.java deleted file mode 100644 index 3ed5e991022..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowDataTraceFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.cfg.pseudocode; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetElement; - -/** - * @author abreslav - */ -public interface JetControlFlowDataTraceFactory { - JetControlFlowDataTraceFactory EMPTY = new JetControlFlowDataTraceFactory() { - @NotNull - @Override - public JetPseudocodeTrace createTrace(JetElement element) { - return JetPseudocodeTrace.EMPTY; - } - }; - - @NotNull - JetPseudocodeTrace createTrace(JetElement element); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java index db3dcea5ced..f888d1711ef 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java @@ -35,12 +35,6 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd private final Stack allBlocks = new Stack(); - private final JetPseudocodeTrace trace; - - public JetControlFlowInstructionsGenerator(JetPseudocodeTrace trace) { - this.trace = trace; - } - private void pushBuilder(JetElement scopingElement, JetElement subroutine) { JetControlFlowInstructionsGeneratorWorker worker = new JetControlFlowInstructionsGeneratorWorker(scopingElement, subroutine); builders.push(worker); @@ -49,7 +43,6 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd private JetControlFlowInstructionsGeneratorWorker popBuilder(@NotNull JetElement element) { JetControlFlowInstructionsGeneratorWorker worker = builders.pop(); - trace.recordControlFlowData(element, worker.getPseudocode()); if (!builders.isEmpty()) { builder = builders.peek(); } @@ -72,7 +65,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd } @Override - public void exitSubroutine(@NotNull JetDeclaration subroutine) { + public Pseudocode exitSubroutine(@NotNull JetDeclaration subroutine) { super.exitSubroutine(subroutine); JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine); if (!builders.empty()) { @@ -80,32 +73,29 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd LocalDeclarationInstruction instruction = new LocalDeclarationInstruction(subroutine, worker.getPseudocode()); builder.add(instruction); } + return worker.getPseudocode(); } private class JetControlFlowInstructionsGeneratorWorker implements JetControlFlowBuilder { - private final Pseudocode pseudocode; + private final PseudocodeImpl pseudocode; private final Label error; private final Label sink; private final JetElement returnSubroutine; private JetControlFlowInstructionsGeneratorWorker(@NotNull JetElement scopingElement, @NotNull JetElement returnSubroutine) { - this.pseudocode = new Pseudocode(scopingElement); + this.pseudocode = new PseudocodeImpl(scopingElement); this.error = pseudocode.createLabel("error"); this.sink = pseudocode.createLabel("sink"); this.returnSubroutine = returnSubroutine; } - public Pseudocode getPseudocode() { + public PseudocodeImpl getPseudocode() { return pseudocode; } private void add(@NotNull Instruction instruction) { pseudocode.addInstruction(instruction); - if (instruction instanceof JetElementInstruction) { - JetElementInstruction elementInstruction = (JetElementInstruction) instruction; - trace.recordRepresentativeInstruction(elementInstruction.getElement(), instruction); - } } @NotNull @@ -127,7 +117,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd loopInfo.push(blockInfo); elementToBlockInfo.put(expression, blockInfo); allBlocks.push(blockInfo); - trace.recordLoopInfo(expression, blockInfo); + pseudocode.recordLoopInfo(expression, blockInfo); return blockInfo; } @@ -202,7 +192,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd } @Override - public void exitSubroutine(@NotNull JetDeclaration subroutine) { + public Pseudocode exitSubroutine(@NotNull JetDeclaration subroutine) { bindLabel(getExitPoint(subroutine)); pseudocode.addExitInstruction(new SubroutineExitInstruction(subroutine, "")); bindLabel(error); @@ -211,6 +201,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd pseudocode.addSinkInstruction(new SubroutineSinkInstruction(subroutine, "")); elementToBlockInfo.remove(subroutine); allBlocks.pop(); + return null; } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.java deleted file mode 100644 index b3149aa1090..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetPseudocodeTrace.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.cfg.pseudocode; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.cfg.LoopInfo; -import org.jetbrains.jet.lang.psi.JetElement; -import org.jetbrains.jet.lang.psi.JetExpression; - -/** - * @author abreslav - */ -public interface JetPseudocodeTrace { - - JetPseudocodeTrace EMPTY = new JetPseudocodeTrace() { - @Override - public void recordControlFlowData(@NotNull JetElement element, @NotNull Pseudocode pseudocode) { - } - - @Override - public void recordRepresentativeInstruction(@NotNull JetElement element, @NotNull Instruction instruction) { - - } - - @Override - public void close() { - } - - @Override - public void recordLoopInfo(JetExpression expression, LoopInfo blockInfo) { - - } - }; - - void recordControlFlowData(@NotNull JetElement element, @NotNull Pseudocode pseudocode); - void recordRepresentativeInstruction(@NotNull JetElement element, @NotNull Instruction instruction); - void close(); - - void recordLoopInfo(JetExpression expression, LoopInfo blockInfo); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java index bac83677def..c648dcadb03 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java @@ -32,7 +32,7 @@ import java.util.*; * @author abreslav * @author svtk */ -public class PseudocodeImpl implements IPseudocode { +public class PseudocodeImpl implements Pseudocode { public class PseudocodeLabel implements Label { private final String name; @@ -103,8 +103,8 @@ public class PseudocodeImpl implements IPseudocode { @NotNull @Override - public Set getLocalDeclarations() { - Set localDeclarations = Sets.newLinkedHashSet(); + public Set getLocalDeclarations() { + Set localDeclarations = Sets.newLinkedHashSet(); //todo look recursively inside local declarations for (Instruction instruction : instructions) { if (instruction instanceof LocalDeclarationInstruction) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index f2c17c3576b..51358d84152 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -16,22 +16,15 @@ package org.jetbrains.jet.lang.resolve; -import com.google.common.base.Predicate; -import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.ModuleConfiguration; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; -import org.jetbrains.jet.lang.psi.JetFile; import java.util.ArrayList; -import java.util.Collection; import java.util.List; /** diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java index 67efa73f586..8c0d02e74fa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java @@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.resolve; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; @@ -37,7 +36,6 @@ import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; public class ControlFlowAnalyzer { private TopDownAnalysisParameters topDownAnalysisParameters; private BindingTrace trace; - private JetControlFlowDataTraceFactory flowDataTraceFactory; @Inject public void setTopDownAnalysisParameters(TopDownAnalysisParameters topDownAnalysisParameters) { @@ -49,11 +47,6 @@ public class ControlFlowAnalyzer { this.trace = trace; } - @Inject - public void setFlowDataTraceFactory(JetControlFlowDataTraceFactory flowDataTraceFactory) { - this.flowDataTraceFactory = flowDataTraceFactory; - } - public void process(@NotNull BodiesResolveContext bodiesResolveContext) { for (JetClass aClass : bodiesResolveContext.getClasses().keySet()) { if (!bodiesResolveContext.completeAnalysisNeeded(aClass)) continue; @@ -86,8 +79,8 @@ public class ControlFlowAnalyzer { private void checkClassOrObject(JetClassOrObject klass) { // A pseudocode of class initialization corresponds to a class - JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) klass, (JetExpression) klass, flowDataTraceFactory, trace); - flowInformationProvider.markUninitializedVariables((JetElement) klass, topDownAnalysisParameters.isDeclaredLocally()); + JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) klass, trace); + flowInformationProvider.markUninitializedVariables(topDownAnalysisParameters.isDeclaredLocally()); } private void checkProperty(JetProperty property, PropertyDescriptor propertyDescriptor) { @@ -105,16 +98,16 @@ public class ControlFlowAnalyzer { JetExpression bodyExpression = function.getBodyExpression(); if (bodyExpression == null) return; - JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) function, bodyExpression, flowDataTraceFactory, trace); + JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) function, trace); - flowInformationProvider.checkDefiniteReturn(function, expectedReturnType); + flowInformationProvider.checkDefiniteReturn(expectedReturnType); // Property accessor is checked through initialization of a class check (at 'checkClassOrObject') boolean isPropertyAccessor = function instanceof JetPropertyAccessor; - flowInformationProvider.markUninitializedVariables(function.asElement(), topDownAnalysisParameters.isDeclaredLocally() || isPropertyAccessor); + flowInformationProvider.markUninitializedVariables(topDownAnalysisParameters.isDeclaredLocally() || isPropertyAccessor); - flowInformationProvider.markUnusedVariables(function.asElement()); + flowInformationProvider.markUnusedVariables(); - flowInformationProvider.markUnusedLiteralsInBlock(function.asElement()); + flowInformationProvider.markUnusedLiteralsInBlock(); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index 4fbb5f140ac..df69780606e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -23,7 +23,6 @@ import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.di.InjectorForTopDownAnalyzerBasic; import org.jetbrains.jet.lang.ModuleConfiguration; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile; @@ -188,7 +187,7 @@ public class TopDownAnalyzer { TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters(Predicates.alwaysFalse(), true, false); InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic( project, topDownAnalysisParameters, new ObservableBindingTrace(trace), - JetStandardClasses.FAKE_STANDARD_CLASSES_MODULE, null, ModuleConfiguration.EMPTY); + JetStandardClasses.FAKE_STANDARD_CLASSES_MODULE, ModuleConfiguration.EMPTY); injector.getTopDownAnalyzer().doProcessStandardLibraryNamespace(outerScope, standardLibraryNamespace, files); } @@ -220,7 +219,7 @@ public class TopDownAnalyzer { InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic( project, topDownAnalysisParameters, new ObservableBindingTrace(trace), moduleDescriptor, - JetControlFlowDataTraceFactory.EMPTY, ModuleConfiguration.EMPTY); + ModuleConfiguration.EMPTY); injector.getTopDownAnalyzer().doProcess(outerScope, new NamespaceLikeBuilder() { diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index 977b914fb4d..165ef5e7c04 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -33,7 +33,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnosticFactory; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Severity; @@ -170,8 +169,8 @@ public class JetTestUtils { private JetTestUtils() { } - public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { - return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory, + public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace) { + return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true)); } diff --git a/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java b/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java index 1b1c6a00665..17aa231055b 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java +++ b/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java @@ -28,10 +28,16 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestUtils; -import org.jetbrains.jet.lang.cfg.LoopInfo; +import org.jetbrains.jet.analyzer.AnalyzeExhaust; +import org.jetbrains.jet.lang.cfg.JetControlFlowProcessor; import org.jetbrains.jet.lang.cfg.pseudocode.*; +import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode; +import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; +import org.jetbrains.jet.util.slicedmap.WritableSlice; import java.io.File; import java.io.FileNotFoundException; @@ -72,37 +78,46 @@ public class JetControlFlowTest extends JetLiteFixture { JetFile file = loadPsiFile(myName + ".jet"); final Map data = new LinkedHashMap(); - final JetPseudocodeTrace pseudocodeTrace = new JetPseudocodeTrace() { + AnalyzeExhaust analyzeExhaust = JetTestUtils.analyzeFile(file); + List declarations = file.getDeclarations(); + final BindingContext bindingContext = analyzeExhaust.getBindingContext(); + BindingTrace mockTrace = new BindingTrace() { @Override - public void recordControlFlowData(@NotNull JetElement element, @NotNull Pseudocode pseudocode) { - data.put(element, pseudocode); + public BindingContext getBindingContext() { + return bindingContext; } @Override - public void close() { - for (Pseudocode pseudocode : data.values()) { - pseudocode.postProcess(); - } + public void record(WritableSlice slice, K key, V value) { } @Override - public void recordLoopInfo(JetExpression expression, LoopInfo blockInfo) { + public void record(WritableSlice slice, K key) { } @Override - public void recordRepresentativeInstruction(@NotNull JetElement element, @NotNull Instruction instruction) { + public V get(ReadOnlySlice slice, K key) { + return bindingContext.get(slice, key); } - }; - - JetTestUtils.analyzeFile(file, new JetControlFlowDataTraceFactory() { @NotNull @Override - public JetPseudocodeTrace createTrace(JetElement element) { - return pseudocodeTrace; + public Collection getKeys(WritableSlice slice) { + return bindingContext.getKeys(slice); + } + + @Override + public void report(@NotNull Diagnostic diagnostic) { + } + }; + for (JetDeclaration declaration : declarations) { + Pseudocode pseudocode = new JetControlFlowProcessor(mockTrace).generatePseudocode(declaration); + data.put(declaration, pseudocode); + for (Pseudocode localPseudocode : pseudocode.getLocalDeclarations()) { + data.put(localPseudocode.getCorrespondingElement(), localPseudocode); } - }); + } try { processCFData(myName, data); @@ -123,6 +138,7 @@ public class JetControlFlowTest extends JetLiteFixture { StringBuilder instructionDump = new StringBuilder(); int i = 0; for (Pseudocode pseudocode : pseudocodes) { + JetElement correspondingElement = pseudocode.getCorrespondingElement(); String label = ""; assert (correspondingElement instanceof JetNamedDeclaration || correspondingElement instanceof JetSecondaryConstructor || correspondingElement instanceof JetPropertyAccessor) : @@ -146,11 +162,11 @@ public class JetControlFlowTest extends JetLiteFixture { instructionDump.append(correspondingElement.getText()); instructionDump.append("\n---------------------\n"); - dumpInstructions(pseudocode, instructionDump); + dumpInstructions((PseudocodeImpl) pseudocode, instructionDump); instructionDump.append("=====================\n"); //check edges directions - Collection instructions = pseudocode.getMutableInstructionList(); + Collection instructions = ((PseudocodeImpl)pseudocode).getMutableInstructionList(); for (Instruction instruction : instructions) { if (!((InstructionImpl)instruction).isDead()) { for (Instruction nextInstruction : instruction.getNextInstructions()) { @@ -181,7 +197,7 @@ public class JetControlFlowTest extends JetLiteFixture { // } } - public void dfsDump(Pseudocode pseudocode, StringBuilder nodes, StringBuilder edges, Map nodeNames) { + public void dfsDump(PseudocodeImpl pseudocode, StringBuilder nodes, StringBuilder edges, Map nodeNames) { dfsDump(nodes, edges, pseudocode.getMutableInstructionList().get(0), nodeNames); } @@ -243,11 +259,11 @@ public class JetControlFlowTest extends JetLiteFixture { return sb.toString(); } - public void dumpInstructions(Pseudocode pseudocode, @NotNull StringBuilder out) { + public void dumpInstructions(PseudocodeImpl pseudocode, @NotNull StringBuilder out) { List instructions = pseudocode.getMutableInstructionList(); Set remainedAfterPostProcessInstructions = Sets.newHashSet(pseudocode.getInstructions()); - List labels = pseudocode.getLabels(); - List locals = new ArrayList(); + List labels = pseudocode.getLabels(); + List locals = new ArrayList(); int maxLength = 0; int maxNextLength = 0; for (Instruction instruction : instructions) { @@ -276,9 +292,9 @@ public class JetControlFlowTest extends JetLiteFixture { Instruction instruction = instructions.get(i); if (instruction instanceof LocalDeclarationInstruction) { LocalDeclarationInstruction localDeclarationInstruction = (LocalDeclarationInstruction) instruction; - locals.add(localDeclarationInstruction.getBody()); + locals.add((PseudocodeImpl) localDeclarationInstruction.getBody()); } - for (Pseudocode.PseudocodeLabel label: labels) { + for (PseudocodeImpl.PseudocodeLabel label: labels) { if (label.getTargetInstructionIndex() == i) { out.append(label.getName()).append(":\n"); } @@ -288,7 +304,7 @@ public class JetControlFlowTest extends JetLiteFixture { append(" NEXT:").append(String.format("%1$-" + maxNextLength + "s", formatInstructionList(instruction.getNextInstructions()))). append(" PREV:").append(formatInstructionList(instruction.getPreviousInstructions())).append("\n"); } - for (Pseudocode local : locals) { + for (PseudocodeImpl local : locals) { dumpInstructions(local, out); } } @@ -300,7 +316,7 @@ public class JetControlFlowTest extends JetLiteFixture { public void visitLocalDeclarationInstruction(LocalDeclarationInstruction instruction) { int index = count[0]; // instruction.getBody().dumpSubgraph(out, "subgraph cluster_" + index, count, "color=blue;\nlabel = \"f" + index + "\";", nodeToName); - printEdge(out, nodeToName.get(instruction), nodeToName.get(instruction.getBody().getMutableInstructionList().get(0)), null); + printEdge(out, nodeToName.get(instruction), nodeToName.get(((PseudocodeImpl)instruction.getBody()).getMutableInstructionList().get(0)), null); visitInstructionWithNext(instruction); } @@ -415,7 +431,7 @@ public class JetControlFlowTest extends JetLiteFixture { int[] count = new int[1]; Map nodeToName = new HashMap(); for (Pseudocode pseudocode : pseudocodes) { - dumpNodes(pseudocode.getMutableInstructionList(), out, count, nodeToName, Sets.newHashSet(pseudocode.getInstructions())); + dumpNodes(((PseudocodeImpl)pseudocode).getMutableInstructionList(), out, count, nodeToName, Sets.newHashSet(pseudocode.getInstructions())); } int i = 0; for (Pseudocode pseudocode : pseudocodes) { @@ -431,7 +447,7 @@ public class JetControlFlowTest extends JetLiteFixture { out.println("subgraph cluster_" + i + " {\n" + "label=\"" + label + "\";\n" + "color=blue;\n"); - dumpEdges(pseudocode.getMutableInstructionList(), out, count, nodeToName); + dumpEdges(((PseudocodeImpl)pseudocode).getMutableInstructionList(), out, count, nodeToName); out.println("}"); i++; } diff --git a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java index 1a19a747b47..04c98039da6 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java @@ -21,7 +21,6 @@ import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.CompileCompilerDependenciesTest; import org.jetbrains.jet.JetLiteFixture; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -107,8 +106,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { public void test(final @NotNull PsiFile psiFile) { BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration( - (JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY, - CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true)) + (JetFile) psiFile, CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true)) .getBindingContext(); String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, psiFile)).toString(); diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java index 1cf8e9bbc76..41ffe49a171 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java @@ -29,7 +29,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestUtils; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; @@ -172,9 +171,7 @@ public class JetDiagnosticsTest extends JetLiteFixture { } BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration( - getProject(), jetFiles, Predicates.alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY, - myEnvironment.getCompilerDependencies()) - .getBindingContext(); + getProject(), jetFiles, Predicates.alwaysTrue(), myEnvironment.getCompilerDependencies()).getBindingContext(); boolean ok = true; diff --git a/compiler/tests/org/jetbrains/jet/cli/jvm/compiler/ReadJavaBinaryClassTest.java b/compiler/tests/org/jetbrains/jet/cli/jvm/compiler/ReadJavaBinaryClassTest.java index 47f541038ca..c380734a4da 100644 --- a/compiler/tests/org/jetbrains/jet/cli/jvm/compiler/ReadJavaBinaryClassTest.java +++ b/compiler/tests/org/jetbrains/jet/cli/jvm/compiler/ReadJavaBinaryClassTest.java @@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.di.InjectorForJavaSemanticServices; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -87,8 +86,7 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir { JetFile psiFile = (JetFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(jetCoreEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false); BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors( - psiFile, JetControlFlowDataTraceFactory.EMPTY, - jetCoreEnvironment.getCompilerDependencies()) + psiFile, jetCoreEnvironment.getCompilerDependencies()) .getBindingContext(); return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel(Name.identifier("test"))); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java index 1258db8df17..a782ce77563 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java @@ -24,7 +24,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; @@ -186,8 +185,7 @@ public abstract class CodegenTestCase extends UsefulTestCase { private GenerationState generateCommon(ClassBuilderFactory classBuilderFactory) { final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors( - myFile, JetControlFlowDataTraceFactory.EMPTY, - myEnvironment.getCompilerDependencies()); + myFile, myEnvironment.getCompilerDependencies()); analyzeExhaust.throwIfError(); AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext()); GenerationState state = new GenerationState(myEnvironment.getProject(), classBuilderFactory, analyzeExhaust, Collections.singletonList(myFile)); diff --git a/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java b/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java index 6875096cb1c..bfa1b4f5d1c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java +++ b/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java @@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.CompileCompilerDependenciesTest; import org.jetbrains.jet.analyzer.AnalyzeExhaust; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode; @@ -37,8 +36,7 @@ public class GenerationUtils { public static GenerationState compileFileGetGenerationStateForTest(JetFile psiFile, @NotNull CompilerSpecialMode compilerSpecialMode) { final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors( - psiFile, JetControlFlowDataTraceFactory.EMPTY, - CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode, true)); + psiFile, CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode, true)); analyzeExhaust.throwIfError(); GenerationState state = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile)); state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION); diff --git a/compiler/tests/org/jetbrains/jet/resolve/DescriptorRendererTest.java b/compiler/tests/org/jetbrains/jet/resolve/DescriptorRendererTest.java index 839500889d3..f9d1682cbd8 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/DescriptorRendererTest.java +++ b/compiler/tests/org/jetbrains/jet/resolve/DescriptorRendererTest.java @@ -22,7 +22,6 @@ import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.analyzer.AnalyzeExhaust; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetFile; @@ -78,8 +77,7 @@ public class DescriptorRendererTest extends JetLiteFixture { JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName)); AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration( - (JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY, - myEnvironment.getCompilerDependencies()); + (JetFile) psiFile, myEnvironment.getCompilerDependencies()); final BindingContext bindingContext = analyzeExhaust.getBindingContext(); final List descriptors = new ArrayList(); psiFile.acceptChildren(new JetVisitorVoid() { diff --git a/compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java b/compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java index f17692228d6..3e04ae4fa64 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java +++ b/compiler/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java @@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; @@ -154,8 +153,7 @@ public abstract class ExpectedResolveData { JetStandardLibrary lib = JetStandardLibrary.getInstance(); AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, - Predicates.alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY, - jetCoreEnvironment.getCompilerDependencies()); + Predicates.alwaysTrue(), jetCoreEnvironment.getCompilerDependencies()); BindingContext bindingContext = analyzeExhaust.getBindingContext(); for (Diagnostic diagnostic : bindingContext.getDiagnostics()) { if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) { diff --git a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java index b4c70e9637a..70598372894 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java @@ -20,7 +20,6 @@ import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.di.InjectorForTests; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -66,7 +65,6 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture { JetDeclaration aClass = declarations.get(0); assert aClass instanceof JetClass; AnalyzeExhaust bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file, - JetControlFlowDataTraceFactory.EMPTY, myEnvironment.getCompilerDependencies()); DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass); WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING); diff --git a/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java b/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java index f335cb132ee..28896d9b8c1 100644 --- a/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java +++ b/idea/src/org/jetbrains/jet/plugin/libraries/JetSourceNavigationHelper.java @@ -33,7 +33,6 @@ import com.intellij.psi.util.PsiTreeUtil; import jet.Tuple2; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -74,8 +73,7 @@ public class JetSourceNavigationHelper { BindingContext bindingContext = AnalyzerFacadeProvider.getAnalyzerFacadeForProject(project).analyzeFiles( project, libraryFiles, - Predicates.alwaysTrue(), - JetControlFlowDataTraceFactory.EMPTY).getBindingContext(); + Predicates.alwaysTrue()).getBindingContext(); D descriptor = bindingContext.get(slice, fqName); if (descriptor != null) { return new Tuple2(bindingContext, descriptor); diff --git a/injector-generator/src/org/jetbrains/jet/di/AllInjectorsGenerator.java b/injector-generator/src/org/jetbrains/jet/di/AllInjectorsGenerator.java index 662e9f816a7..2c026928cc6 100644 --- a/injector-generator/src/org/jetbrains/jet/di/AllInjectorsGenerator.java +++ b/injector-generator/src/org/jetbrains/jet/di/AllInjectorsGenerator.java @@ -26,7 +26,6 @@ import org.jetbrains.jet.codegen.JetTypeMapper; import org.jetbrains.jet.codegen.ScriptCodegen; import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.jet.lang.ModuleConfiguration; -import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.*; @@ -93,7 +92,6 @@ public class AllInjectorsGenerator { generator.addPublicParameter(TopDownAnalysisParameters.class); generator.addPublicParameter(ObservableBindingTrace.class); generator.addParameter(ModuleDescriptor.class); - generator.addParameter(JetControlFlowDataTraceFactory.class, false); } private static void generateMacroInjector() throws IOException { -- GitLab