Fix/suppress warnings (mostly unused assignment)

GitOrigin-RevId: 4852aa09f10af20ef4ec928bfa76b05ef6271686
This commit is contained in:
Tagir Valeev
2024-12-03 14:25:33 +00:00
committed by intellij-monorepo-bot
parent 3592c1fdf3
commit 2cd9f21e7a
18 changed files with 30 additions and 27 deletions
@@ -528,7 +528,8 @@ public class IndexTest extends JavaCodeInsightFixtureTestCase {
FileDocumentManager.getInstance().saveAllDocuments();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
//noinspection GroovyUnusedAssignment
//Let's help GC, even in interpreter mode
//noinspection UnusedAssignment
psiFile = null;
GCWatcher.tracking(getPsiManager().getFileManager().getCachedPsiFile(vFile))
.ensureCollected(() -> UIUtil.dispatchAllInvocationEvents());
@@ -693,7 +693,7 @@ public final class JavacMain {
static {
Method getterMethod = null;
Method clearMethod = null;
Method clearMethod;
try {
//trying JDK 6
clearMethod = Class.forName("com.sun.tools.javac.zip.ZipFileIndex").getDeclaredMethod("clearCache");
@@ -34,7 +34,7 @@ import org.jetbrains.jps.cmdline.ClasspathBootstrap;
import org.jetbrains.jps.incremental.GlobalContextKey;
import org.jetbrains.jps.javac.rpc.JavacRemoteProto;
import javax.tools.Diagnostic;
import javax.tools.*;
import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -599,7 +599,7 @@ public class ExternalJavacManager extends ProcessAdapter {
}
private Channel lookupChannel(UUID processId) {
Channel channel = null;
Channel channel;
synchronized (myConnections) {
channel = myConnections.get(processId);
debug(channel, ch-> "lookupChannel: channel for " + processId + " is " + ch);
@@ -8,7 +8,7 @@ import org.jetbrains.jps.model.ex.JpsElementBase;
import java.util.Objects;
public class JavaResourceRootProperties extends JpsElementBase<JavaResourceRootProperties> {
private String myRelativeOutputPath = "";
private String myRelativeOutputPath;
private boolean myForGeneratedSources;
public JavaResourceRootProperties(@NotNull String relativeOutputPath, boolean forGeneratedSources) {
@@ -8,7 +8,7 @@ import org.jetbrains.jps.model.ex.JpsElementBase;
import java.util.Objects;
public class JavaSourceRootProperties extends JpsElementBase<JavaSourceRootProperties> {
private String myPackagePrefix = "";
private String myPackagePrefix;
private boolean myForGeneratedSources;
@ApiStatus.Internal
@@ -15,7 +15,7 @@ public class StoppableLexerAdapter extends DelegateLexer {
}
private final StoppingCondition myCondition;
private boolean myStopped = false;
private boolean myStopped;
public StoppableLexerAdapter(final StoppingCondition condition, final Lexer original) {
super(original);
@@ -17,7 +17,7 @@ import java.util.Objects;
public final class TestEditorSplitter {
private final HashMap<String, TestEditorTabGroup> myTabGroups = new HashMap<>();
private static final String Default = "Default";
private String myActiveTabGroupName = Default;
private String myActiveTabGroupName;
public TestEditorSplitter() {
myTabGroups.put(Default, new TestEditorTabGroup(Default));
@@ -116,7 +116,6 @@ public final class ExtractCodeStyleAction extends AnAction implements DumbAware
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
boolean apply = "apply".equals(e.getDescription());
ExtractedSettingsDialog myDialog = null;
if (!apply) {
final List<Value> values = calculatedValues.getValues();
Language language = file.getLanguage();
@@ -126,7 +125,7 @@ public final class ExtractCodeStyleAction extends AnAction implements DumbAware
if (target.equals(language)) {
//this is our language
nameProvider.addSettings(provider);
myDialog = new ExtractedSettingsDialog(project, nameProvider, values);
ExtractedSettingsDialog myDialog = new ExtractedSettingsDialog(project, nameProvider, values);
apply = myDialog.showAndGet();
break;
}
@@ -13,9 +13,9 @@ import javax.swing.border.TitledBorder;
import java.awt.*;
public final class DocCommentPanel extends JPanel {
private JRadioButton myRbJavaDocAsIs = null;
private JRadioButton myRbJavaDocMove = null;
private JRadioButton myRbJavaDocCopy = null;
private final JRadioButton myRbJavaDocAsIs;
private final JRadioButton myRbJavaDocMove;
private final JRadioButton myRbJavaDocCopy;
private final TitledBorder myBorder;
public DocCommentPanel(@NlsContexts.BorderTitle String title) {
@@ -188,19 +188,19 @@ implements ClassGenerator
protected Object create(Object key) {
try {
Class gen = null;
Class<?> gen = null;
synchronized (source) {
ClassLoader loader = getClassLoader();
Map cache2 = null;
cache2 = (Map)source.cache.get(loader);
Map<Object, Object> cache2;
cache2 = (Map<Object, Object>)source.cache.get(loader);
if (cache2 == null) {
cache2 = new HashMap<>();
cache2.put(NAME_KEY, new HashSet<>());
source.cache.put(loader, cache2);
} else if (useCache) {
Reference ref = (Reference)cache2.get(key);
gen = ref == null ? null : (Class) ref.get();
gen = ref == null ? null : (Class<?>) ref.get();
}
if (gen == null) {
AbstractClassGenerator save = CURRENT.get();
@@ -9,7 +9,7 @@ public final class TimedDeadzone {
public static final Length DEFAULT = new Length(150);
public static final Length NULL = new Length(-1);
private Length myLength = NULL;
private Length myLength;
private boolean myMouseWithin;
private long myTimeEntered = -1;
@@ -51,7 +51,7 @@ public class TestFileStructure {
@NotNull
public PsiFile addTestFile(@NotNull String name, @NotNull String content) {
PsiFile createdFile = null;
PsiFile createdFile;
try {
createdFile = createFile(myModule, myCurrentLevelDirectory.getVirtualFile(), name, content);
}
@@ -1470,6 +1470,8 @@ public class RangeMarkerTest extends LightPlatformTestCase {
if (t.isTimedOut() && d != null) {
int hashCode = System.identityHashCode(d);
Class<?> aClass = d.getClass();
//Help GC, even in interpreter mode
//noinspection UnusedAssignment
d = null;
LeakHunter.checkLeak(LeakHunter.allRoots(), aClass, leakedDoc -> System.identityHashCode(leakedDoc) == hashCode);
fail("Unable to gc the document");
@@ -212,6 +212,8 @@ public class ContainerUtilCollectionsTest extends Assert {
Reference<Object> ref = new SoftReference<>(value);
map.put(1, value);
assertEquals(1, map.size());
//Help GC, even in interpreter mode
//noinspection UnusedAssignment
value = null;
do {
@@ -343,7 +343,7 @@ public class ConcurrentWeakKeySoftValueHashMap<K, V> implements ConcurrentMap<K,
@Override
public boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue) {
HardKey<K, V> oldKeyReference = createHardKey(key);
ValueReference<K, V> oldValueReference = null;
ValueReference<K, V> oldValueReference;
try {
oldValueReference = createValueReference(oldValue, myValueQueue);
ValueReference<K, V> newValueReference = createValueReference(newValue, myValueQueue);
@@ -13,10 +13,9 @@ import java.util.StringTokenizer;
public final class CommandLineTokenizer extends StringTokenizer {
private static final String DEFAULT_DELIMITERS = " \t\n\r\f";
// keep source level 1.4
private final List myTokens = new ArrayList();
private final List<String> myTokens = new ArrayList<>();
private int myCurrentToken = 0;
private boolean myHandleEscapedWhitespaces = false;
private final boolean myHandleEscapedWhitespaces;
public CommandLineTokenizer(String str) {
this(str, false);
@@ -35,11 +34,11 @@ public final class CommandLineTokenizer extends StringTokenizer {
@Override
public String nextToken() {
return (String) myTokens.get(myCurrentToken++);
return myTokens.get(myCurrentToken++);
}
public String peekNextToken() {
return (String) myTokens.get(myCurrentToken);
return myTokens.get(myCurrentToken);
}
@Override
@@ -317,7 +317,7 @@ public class CompressedAppendableFile {
private void saveNextChunkIfNeeded() throws IOException {
if (myBufferPosition == myNextChunkBuffer.length) {
int dataWrittenCount = 0;
int dataWrittenCount;
try (DataOutputStream stream = getChunkAppendStream()) {
compress(stream, myNextChunkBuffer);
dataWrittenCount = stream.getWrittenBytesCount();
@@ -82,7 +82,7 @@ public class MavenIndices implements Disposable {
@NotNull
private static List<MavenIndexUtils.IndexPropertyHolder> readCurrentIndexFileProperty(@NotNull Path indicesDir) {
Path[] indices = null;
Path[] indices;
try {
indices = Files.list(indicesDir).toArray(Path[]::new);
}