[groovy] dfa: add default Semilattice#eq implementation

This commit is contained in:
Daniil Ovchinnikov
2019-04-17 15:14:02 +03:00
parent d38bf62ea3
commit 27ef431d6a
4 changed files with 6 additions and 50 deletions
@@ -5,9 +5,9 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.VariableDescriptor;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.VariableDescriptor;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.VariableDescriptorFactory;
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.DFAEngine;
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.DfaInstance;
@@ -84,11 +84,6 @@ public class InvalidWriteAccessSearcher {
public MyData join(@NotNull List<? extends MyData> ins) {
return new MyData(ins);
}
@Override
public boolean eq(@NotNull MyData e1, @NotNull MyData e2) {
return e1.equals(e2);
}
}
private static class MyData {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.codeInspection.dataflow;
import gnu.trove.TObjectIntHashMap;
@@ -46,9 +32,4 @@ public class WritesCounterSemilattice<T> implements Semilattice<TObjectIntHashMa
}
return result;
}
@Override
public boolean eq(@NotNull TObjectIntHashMap<T> e1, @NotNull TObjectIntHashMap<T> e2) {
return e1.equals(e2);
}
}
@@ -780,11 +780,6 @@ public class ControlFlowUtils {
}
return result;
}
@Override
public boolean eq(@NotNull BitSet e1, @NotNull BitSet e2) {
return e1.equals(e2);
}
};
DfaInstance<BitSet> dfa = new DfaInstance<BitSet>() {
@@ -1,31 +1,16 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.psi.dataFlow;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author ven
*/
public interface Semilattice<E> {
@NotNull
E join(@NotNull List<? extends E> ins);
boolean eq(@NotNull E e1, @NotNull E e2);
default boolean eq(@NotNull E e1, @NotNull E e2) {
return e1.equals(e2);
}
}