mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-146946
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -70,7 +70,7 @@ public class DfaUtil {
|
||||
@Override
|
||||
public Result<Map<PsiElement, ValuableInstructionVisitor.PlaceResult>> compute() {
|
||||
final ValuableInstructionVisitor visitor = new ValuableInstructionVisitor();
|
||||
RunnerResult runnerResult = new ValuableDataFlowRunner(codeBlock).analyzeMethod(codeBlock, visitor);
|
||||
RunnerResult runnerResult = new ValuableDataFlowRunner().analyzeMethod(codeBlock, visitor);
|
||||
return Result.create(runnerResult == RunnerResult.OK ? visitor.myResults : null, codeBlock);
|
||||
}
|
||||
});
|
||||
@@ -242,11 +242,11 @@ public class DfaUtil {
|
||||
final ValuableDataFlowRunner.ValuableDfaVariableState curState = (ValuableDataFlowRunner.ValuableDfaVariableState)memState.getVariableState(var);
|
||||
final FList<PsiExpression> curValue = curState.myConcatenation;
|
||||
final FList<PsiExpression> nextValue;
|
||||
if (type == JavaTokenType.PLUSEQ && !prevValue.isEmpty()) {
|
||||
if (type == JavaTokenType.PLUSEQ && !prevValue.isEmpty() && rightValue != null) {
|
||||
nextValue = prevValue.prepend(rightValue);
|
||||
}
|
||||
else {
|
||||
nextValue = curValue.isEmpty() ? curValue.prepend(rightValue) : curValue;
|
||||
nextValue = curValue.isEmpty() && rightValue != null ? curValue.prepend(rightValue) : curValue;
|
||||
}
|
||||
memState.setVariableState(var, curState.withExpression(nextValue));
|
||||
}
|
||||
|
||||
+17
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.codeInspection.dataFlow.value.DfaPsiType;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.util.containers.FList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,33 +30,31 @@ import java.util.Set;
|
||||
/**
|
||||
* @author Gregory.Shrago
|
||||
*/
|
||||
public class ValuableDataFlowRunner extends DataFlowRunner {
|
||||
|
||||
protected ValuableDataFlowRunner(PsiElement block) {
|
||||
super();
|
||||
}
|
||||
|
||||
class ValuableDataFlowRunner extends DataFlowRunner {
|
||||
@NotNull
|
||||
@Override
|
||||
protected DfaMemoryState createMemoryState() {
|
||||
return new MyDfaMemoryState(getFactory());
|
||||
}
|
||||
|
||||
static class MyDfaMemoryState extends DfaMemoryStateImpl {
|
||||
private MyDfaMemoryState(final DfaValueFactory factory) {
|
||||
private MyDfaMemoryState(@NotNull DfaValueFactory factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
MyDfaMemoryState(DfaMemoryStateImpl toCopy) {
|
||||
private MyDfaMemoryState(@NotNull DfaMemoryStateImpl toCopy) {
|
||||
super(toCopy);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DfaMemoryStateImpl createCopy() {
|
||||
return new MyDfaMemoryState(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DfaVariableState createVariableState(DfaVariableValue var) {
|
||||
protected DfaVariableState createVariableState(@NotNull DfaVariableValue var) {
|
||||
return new ValuableDfaVariableState(var);
|
||||
}
|
||||
|
||||
@@ -68,35 +65,38 @@ public class ValuableDataFlowRunner extends DataFlowRunner {
|
||||
}
|
||||
|
||||
static class ValuableDfaVariableState extends DfaVariableState {
|
||||
final DfaValue myValue;
|
||||
private final DfaValue myValue;
|
||||
@NotNull final FList<PsiExpression> myConcatenation;
|
||||
|
||||
private ValuableDfaVariableState(final DfaVariableValue psiVariable) {
|
||||
private ValuableDfaVariableState(@NotNull DfaVariableValue psiVariable) {
|
||||
super(psiVariable);
|
||||
myValue = null;
|
||||
myConcatenation = FList.emptyList();
|
||||
}
|
||||
|
||||
private ValuableDfaVariableState(Set<DfaPsiType> instanceofValues,
|
||||
Set<DfaPsiType> notInstanceofValues,
|
||||
Nullness nullability, DfaValue value, @NotNull FList<PsiExpression> concatenation) {
|
||||
Set<DfaPsiType> notInstanceofValues,
|
||||
Nullness nullability, DfaValue value,
|
||||
@NotNull FList<PsiExpression> concatenation) {
|
||||
super(instanceofValues, notInstanceofValues, nullability);
|
||||
myValue = value;
|
||||
myConcatenation = concatenation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DfaVariableState createCopy(Set<DfaPsiType> instanceofValues, Set<DfaPsiType> notInstanceofValues, Nullness nullability) {
|
||||
protected DfaVariableState createCopy(@NotNull Set<DfaPsiType> instanceofValues, @NotNull Set<DfaPsiType> notInstanceofValues, @NotNull Nullness nullability) {
|
||||
return new ValuableDfaVariableState(instanceofValues, notInstanceofValues, nullability, myValue, myConcatenation);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DfaVariableState withValue(@Nullable final DfaValue value) {
|
||||
if (value == myValue) return this;
|
||||
return new ValuableDfaVariableState(myInstanceofValues, myNotInstanceofValues, myNullability, value, myConcatenation);
|
||||
}
|
||||
|
||||
public ValuableDfaVariableState withExpression(@NotNull final FList<PsiExpression> concatenation) {
|
||||
ValuableDfaVariableState withExpression(@NotNull final FList<PsiExpression> concatenation) {
|
||||
if (concatenation == myConcatenation) return this;
|
||||
return new ValuableDfaVariableState(myInstanceofValues, myNotInstanceofValues, myNullability, myValue, concatenation);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package x;
|
||||
|
||||
class X {
|
||||
void f(Throwable p) {
|
||||
Throwable error = <flown1>null;
|
||||
|
||||
try {
|
||||
f(p);
|
||||
}
|
||||
catch (Throwable <flown21>e) {
|
||||
error = <flown2>e;
|
||||
}
|
||||
finally {
|
||||
f(<caret>error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -17,23 +17,14 @@ package com.intellij.slicer;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
@@ -89,4 +80,5 @@ public class SliceBackwardTest extends SliceTestCase {
|
||||
public void testVarArgsPartial() throws Exception { doTest();}
|
||||
|
||||
public void testListTrackToArray() throws Exception { doTest();}
|
||||
public void testTryCatchFinally() throws Exception { doTest();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user