Warnings fixed (mostly redundant cast)

GitOrigin-RevId: 63bdb7f359a1a2cd37cb6a691b3d94db8ba3ce02
This commit is contained in:
Tagir Valeev
2024-10-10 13:26:12 +02:00
committed by intellij-monorepo-bot
parent 8719731a84
commit feb2ee9625
17 changed files with 41 additions and 47 deletions

View File

@@ -276,12 +276,12 @@ public final class JavaSourceInference {
private static InferenceMode getInferenceMode(@NotNull PsiMethodImpl method) { private static InferenceMode getInferenceMode(@NotNull PsiMethodImpl method) {
if (isLibraryCode(method) || if (isLibraryCode(method) ||
((PsiMethod)method).hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.ABSTRACT) ||
((PsiMethod)method).hasModifierProperty(PsiModifier.NATIVE)) { method.hasModifierProperty(PsiModifier.NATIVE)) {
return InferenceMode.DISABLED; return InferenceMode.DISABLED;
} }
if (((PsiMethod)method).hasModifierProperty(PsiModifier.STATIC)) return InferenceMode.ENABLED; if (method.hasModifierProperty(PsiModifier.STATIC)) return InferenceMode.ENABLED;
if (PsiUtil.canBeOverridden(method)) { if (PsiUtil.canBeOverridden(method)) {
PsiClass containingClass = method.getContainingClass(); PsiClass containingClass = method.getContainingClass();
if (containingClass != null && (PsiUtil.isLocalClass(containingClass) || if (containingClass != null && (PsiUtil.isLocalClass(containingClass) ||

View File

@@ -74,7 +74,7 @@ public final class BasicJavaParserUtil {
@Nullable @Nullable
public static IElementType exprType(@Nullable final PsiBuilder.Marker marker) { public static IElementType exprType(@Nullable final PsiBuilder.Marker marker) {
return marker != null ? ((LighterASTNode)marker).getTokenType() : null; return marker != null ? marker.getTokenType() : null;
} }
// used instead of PsiBuilder.error() as it keeps all subsequent error messages // used instead of PsiBuilder.error() as it keeps all subsequent error messages

View File

@@ -263,7 +263,7 @@ public final class PsiCodeBlockImpl extends LazyParseablePsiElement implements P
} }
if (child == null) { if (child == null) {
child = ((PsiElement)this).getLastChild(); child = this.getLastChild();
} }
while (child != null) { while (child != null) {

View File

@@ -265,7 +265,7 @@ public final class BuildDataManager {
finally { finally {
SourceToOutputMappingWrapper sourceToOutput = buildTargetToSourceToOutputMapping.remove(target); SourceToOutputMappingWrapper sourceToOutput = buildTargetToSourceToOutputMapping.remove(target);
if (sourceToOutput != null && sourceToOutput.myDelegate != null) { if (sourceToOutput != null && sourceToOutput.myDelegate != null) {
((StorageOwner)sourceToOutput.myDelegate).close(); sourceToOutput.myDelegate.close();
} }
if (newDataManager != null) { if (newDataManager != null) {

View File

@@ -1,7 +1,6 @@
// Copyright 2000-2020 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. // Copyright 2000-2020 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 com.intellij.lang.pratt; package com.intellij.lang.pratt;
import com.intellij.lang.LighterASTNode;
import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiBuilder;
import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsContexts;
import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.IElementType;
@@ -22,7 +21,7 @@ public class MutableMarker {
myPath = path; myPath = path;
myStartMarker = startMarker; myStartMarker = startMarker;
myInitialPathLength = initialPathLength; myInitialPathLength = initialPathLength;
myMode = startMarker instanceof LighterASTNode && ((LighterASTNode)startMarker).getTokenType() != null? Mode.COMMITTED : Mode.READY; myMode = startMarker != null && startMarker.getTokenType() != null ? Mode.COMMITTED : Mode.READY;
} }
// for easier transition only // for easier transition only
@@ -30,7 +29,7 @@ public class MutableMarker {
myPath = path; myPath = path;
myStartMarker = (PsiBuilder.Marker)builder.getLatestDoneMarker(); myStartMarker = (PsiBuilder.Marker)builder.getLatestDoneMarker();
myInitialPathLength = path.size(); myInitialPathLength = path.size();
myResultType = myStartMarker != null ? ((LighterASTNode)myStartMarker).getTokenType() : null; myResultType = myStartMarker != null ? myStartMarker.getTokenType() : null;
myMode = myResultType != null ? Mode.COMMITTED : Mode.READY; myMode = myResultType != null ? Mode.COMMITTED : Mode.READY;
} }

View File

@@ -17,7 +17,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.ByteArraySequence; import com.intellij.openapi.util.io.ByteArraySequence;
import com.intellij.openapi.util.io.ByteSequence;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
@@ -546,7 +545,7 @@ final class FileTypeDetectionService implements Disposable {
file, true, true, file, true, true,
PlainTextFileType.INSTANCE, (@Nullable CharSequence text) -> { PlainTextFileType.INSTANCE, (@Nullable CharSequence text) -> {
if (toLog()) { if (toLog()) {
log("F: detectFromContentAndCache.processFirstBytes(" + file.getName() + "): bytes length=" + ((ByteSequence)bytes).length() + log("F: detectFromContentAndCache.processFirstBytes(" + file.getName() + "): bytes length=" + bytes.length() +
"; isText=" + (text != null) + "; text='" + (text == null ? null : StringUtil.first(text, 100, true)) + "'" + "; isText=" + (text != null) + "; text='" + (text == null ? null : StringUtil.first(text, 100, true)) + "'" +
", detectors=" + detectors); ", detectors=" + detectors);
} }

View File

@@ -2,7 +2,6 @@
package com.intellij.openapi.roots.ui.util; package com.intellij.openapi.roots.ui.util;
import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.ide.highlighter.ArchiveFileType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
@@ -17,7 +16,7 @@ public final class JarSubfileCellAppearance extends ValidFileCellAppearance {
@Override @Override
protected Icon getIcon() { protected Icon getIcon() {
return ((FileType)ArchiveFileType.INSTANCE).getIcon(); return ArchiveFileType.INSTANCE.getIcon();
} }
@Override @Override

View File

@@ -1,15 +1,14 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.vfs.newvfs.persistent.dev.content; package com.intellij.openapi.vfs.newvfs.persistent.dev.content;
import com.intellij.platform.util.io.storages.DataExternalizerEx;
import com.intellij.platform.util.io.storages.KeyDescriptorEx;
import com.intellij.platform.util.io.storages.appendonlylog.AppendOnlyLogFactory; import com.intellij.platform.util.io.storages.appendonlylog.AppendOnlyLogFactory;
import com.intellij.platform.util.io.storages.appendonlylog.AppendOnlyLogOverMMappedFile; import com.intellij.platform.util.io.storages.appendonlylog.AppendOnlyLogOverMMappedFile;
import com.intellij.platform.util.io.storages.DataExternalizerEx;
import com.intellij.platform.util.io.storages.enumerator.DurableEnumerator; import com.intellij.platform.util.io.storages.enumerator.DurableEnumerator;
import com.intellij.platform.util.io.storages.enumerator.DurableEnumeratorFactory; import com.intellij.platform.util.io.storages.enumerator.DurableEnumeratorFactory;
import com.intellij.platform.util.io.storages.KeyDescriptorEx;
import com.intellij.util.hash.ContentHashEnumerator; import com.intellij.util.hash.ContentHashEnumerator;
import com.intellij.util.io.CleanableStorage; import com.intellij.util.io.CleanableStorage;
import com.intellij.util.io.ScannableDataEnumeratorEx;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -96,14 +95,14 @@ public class ContentHashEnumeratorOverDurableEnumerator implements ContentHashEn
@Override @Override
public boolean forEach(@NotNull ValueReader<? super byte[]> reader) throws IOException { public boolean forEach(@NotNull ValueReader<? super byte[]> reader) throws IOException {
return ((ScannableDataEnumeratorEx<byte[]>)enumerator).forEach( return enumerator.forEach(
(enumeratorId, hash) -> reader.read(enumeratorIdToHashId(enumeratorId), hash) (enumeratorId, hash) -> reader.read(enumeratorIdToHashId(enumeratorId), hash)
); );
} }
@Override @Override
public int recordsCount() throws IOException { public int recordsCount() throws IOException {
return ((ScannableDataEnumeratorEx<byte[]>)enumerator).recordsCount(); return enumerator.recordsCount();
} }
@Override @Override
@@ -204,7 +203,7 @@ public class ContentHashEnumeratorOverDurableEnumerator implements ContentHashEn
} }
@Override @Override
public KnownSizeRecordWriter writerFor(byte @NotNull [] hash) throws IOException { public KnownSizeRecordWriter writerFor(byte @NotNull [] hash) {
return DataExternalizerEx.fromBytes(hash); return DataExternalizerEx.fromBytes(hash);
} }

View File

@@ -152,7 +152,7 @@ abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObject
@NotNull @NotNull
private Iterator<Entry<V>> entriesIterator() { private Iterator<Entry<V>> entriesIterator() {
final Iterator<Entry<IntReference<V>>> entryIterator = ((Iterable<Entry<IntReference<V>>>)myMap.entrySet()).iterator(); final Iterator<Entry<IntReference<V>>> entryIterator = myMap.entrySet().iterator();
return new Iterator<>() { return new Iterator<>() {
private Entry<V> nextVEntry; private Entry<V> nextVEntry;
private Entry<IntReference<V>> nextReferenceEntry; private Entry<IntReference<V>> nextReferenceEntry;

View File

@@ -59,6 +59,8 @@ package org.jdom.filter;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.Namespace; import org.jdom.Namespace;
import java.util.Objects;
/** /**
* @deprecated Use {@link org.jdom.filter2.ElementFilter} * @deprecated Use {@link org.jdom.filter2.ElementFilter}
*/ */
@@ -139,12 +141,7 @@ public final class ElementFilter extends AbstractFilter<Element> {
if (!(obj instanceof ElementFilter)) return false; if (!(obj instanceof ElementFilter)) return false;
final ElementFilter filter = (ElementFilter)obj; final ElementFilter filter = (ElementFilter)obj;
return Objects.equals(name, filter.name) && Objects.equals(namespace, filter.namespace);
//noinspection StringEquality
if (!((name == filter.name) || (name != null && ((Object)name).equals(filter.name)))) return false;
if (!((namespace == filter.namespace) || (namespace != null && ((Object)namespace).equals(filter.namespace)))) return false;
return true;
} }
public int hashCode() { public int hashCode() {

View File

@@ -143,7 +143,7 @@ abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObject
} }
private @NotNull Iterator<Entry<V>> entriesIterator() { private @NotNull Iterator<Entry<V>> entriesIterator() {
Iterator<Entry<IntReference<V>>> entryIterator = ((Iterable<Entry<IntReference<V>>>)myMap.entrySet()).iterator(); Iterator<Entry<IntReference<V>>> entryIterator = myMap.entrySet().iterator();
return new Iterator<Entry<V>>() { return new Iterator<Entry<V>>() {
private Entry<V> nextVEntry; private Entry<V> nextVEntry;
private Entry<IntReference<V>> nextReferenceEntry; private Entry<IntReference<V>> nextReferenceEntry;

View File

@@ -108,7 +108,7 @@ public final class MavenKeymapExtension implements ExternalSystemKeymapExtension
return result; return result;
} }
static void updateActions(Project project, List<? extends MavenProject> mavenProjects) { static void updateActions(Project project, List<MavenProject> mavenProjects) {
clearActions(project, mavenProjects); clearActions(project, mavenProjects);
createActions(project, mavenProjects); createActions(project, mavenProjects);
} }
@@ -124,7 +124,7 @@ public final class MavenKeymapExtension implements ExternalSystemKeymapExtension
return mavenGoalAction; return mavenGoalAction;
} }
private static void createActions(Project project, List<? extends MavenProject> mavenProjects) { private static void createActions(Project project, List<MavenProject> mavenProjects) {
ActionManager actionManager = ActionManager.getInstance(); ActionManager actionManager = ActionManager.getInstance();
MavenShortcutsManager shortcutsManager = MavenShortcutsManager.getInstance(project); MavenShortcutsManager shortcutsManager = MavenShortcutsManager.getInstance(project);
@@ -163,7 +163,7 @@ public final class MavenKeymapExtension implements ExternalSystemKeymapExtension
} }
} }
static void clearActions(Project project, List<? extends MavenProject> mavenProjects) { static void clearActions(Project project, List<MavenProject> mavenProjects) {
ActionManager manager = ActionManager.getInstance(); ActionManager manager = ActionManager.getInstance();
for (MavenProject eachProject : mavenProjects) { for (MavenProject eachProject : mavenProjects) {
for (String eachAction : getActionIdList(project, eachProject)) { for (String eachAction : getActionIdList(project, eachProject)) {
@@ -187,7 +187,7 @@ public final class MavenKeymapExtension implements ExternalSystemKeymapExtension
if (info == null) continue; if (info == null) continue;
for (MavenPluginInfo.Mojo m : info.getMojos()) { for (MavenPluginInfo.Mojo m : info.getMojos()) {
((Set<? super String>)result).add(m.getQualifiedGoal()); result.add(m.getQualifiedGoal());
} }
} }

View File

@@ -155,13 +155,13 @@ public final class MavenShortcutsManager implements Disposable {
} }
@Override @Override
public void projectsIgnoredStateChanged(List<MavenProject> ignored, List<MavenProject> unignored, boolean fromImport) { public void projectsIgnoredStateChanged(@NotNull List<MavenProject> ignored, @NotNull List<MavenProject> unignored, boolean fromImport) {
scheduleKeymapUpdate(unignored, true); scheduleKeymapUpdate(unignored, true);
scheduleKeymapUpdate(ignored, false); scheduleKeymapUpdate(ignored, false);
} }
@Override @Override
public void projectsUpdated(List<? extends Pair<MavenProject, MavenProjectChanges>> updated, List<MavenProject> deleted) { public void projectsUpdated(@NotNull List<? extends Pair<MavenProject, MavenProjectChanges>> updated, @NotNull List<MavenProject> deleted) {
scheduleKeymapUpdate(MavenUtil.collectFirsts(updated), true); scheduleKeymapUpdate(MavenUtil.collectFirsts(updated), true);
scheduleKeymapUpdate(deleted, false); scheduleKeymapUpdate(deleted, false);
} }
@@ -176,7 +176,7 @@ public final class MavenShortcutsManager implements Disposable {
scheduleKeymapUpdate(Collections.singletonList(project), true); scheduleKeymapUpdate(Collections.singletonList(project), true);
} }
private void scheduleKeymapUpdate(List<? extends MavenProject> mavenProjects, boolean forUpdate) { private void scheduleKeymapUpdate(List<MavenProject> mavenProjects, boolean forUpdate) {
synchronized (mySheduledProjects) { synchronized (mySheduledProjects) {
for (MavenProject each : mavenProjects) { for (MavenProject each : mavenProjects) {
mySheduledProjects.put(each, forUpdate); mySheduledProjects.put(each, forUpdate);

View File

@@ -16,7 +16,6 @@ import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope; import com.intellij.psi.search.ProjectScope;
import com.intellij.util.Plow; import com.intellij.util.Plow;
@@ -78,7 +77,7 @@ public class YAMLKeysSearchEverywhereContributor implements SearchEverywhereCont
@Override @Override
public boolean processSelectedItem(@NotNull YAMLKeyNavigationItem selected, int modifiers, @NotNull String searchText) { public boolean processSelectedItem(@NotNull YAMLKeyNavigationItem selected, int modifiers, @NotNull String searchText) {
((Navigatable)selected).navigate(true); selected.navigate(true);
return true; return true;
} }

View File

@@ -25,6 +25,7 @@ import com.intellij.ui.AppUIUtil;
import com.intellij.ui.Gray; import com.intellij.ui.Gray;
import com.intellij.ui.JBColor; import com.intellij.ui.JBColor;
import com.intellij.util.Consumer; import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.NamedColorUtil; import com.intellij.util.ui.NamedColorUtil;
import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebugSession;
@@ -134,7 +135,7 @@ final class PyUnitTestsDebuggingService {
*/ */
public static boolean isErrorInTestSetUpOrTearDown(@NotNull List<PyStackFrameInfo> frames) { public static boolean isErrorInTestSetUpOrTearDown(@NotNull List<PyStackFrameInfo> frames) {
for (PyStackFrameInfo frameInfo : frames) { for (PyStackFrameInfo frameInfo : frames) {
if (SET_UP_AND_TEAR_DOWN_FUNCTIONS_BY_FRAMEWORK.values().stream().anyMatch(names -> names.contains(frameInfo.getName()))) if (ContainerUtil.exists(SET_UP_AND_TEAR_DOWN_FUNCTIONS_BY_FRAMEWORK.values(), names -> names.contains(frameInfo.getName())))
return true; return true;
} }
return false; return false;
@@ -210,7 +211,7 @@ final class PyUnitTestsDebuggingService {
return UIUtil.getFontWithFallback(fontName, Font.PLAIN, fontSize); return UIUtil.getFontWithFallback(fontName, Font.PLAIN, fontSize);
} }
private void drawStringToInlayBox(@NotNull String str, @NotNull Inlay inlay, @NotNull Graphics g, @NotNull Rectangle targetRegion) { private void drawStringToInlayBox(@NotNull String str, @NotNull Inlay<?> inlay, @NotNull Graphics g, @NotNull Rectangle targetRegion) {
g.drawString(str, targetRegion.x + INLAY_TEXT_INDENT, targetRegion.y + inlay.getEditor().getLineHeight() * myCurrentLineNumber); g.drawString(str, targetRegion.x + INLAY_TEXT_INDENT, targetRegion.y + inlay.getEditor().getLineHeight() * myCurrentLineNumber);
myCurrentLineNumber++; myCurrentLineNumber++;
} }
@@ -240,7 +241,7 @@ final class PyUnitTestsDebuggingService {
} }
private static @NotNull Color getInlayBackgroundColor() { private static @NotNull Color getInlayBackgroundColor() {
return UIUtil.isUnderDarcula() ? JBColor.WHITE : new JBColor(Gray._240, Gray._192); return JBColor.isBright() ? new JBColor(Gray._240, Gray._192) : JBColor.WHITE;
} }
private static @Nls String getFailedTestCaption() { private static @Nls String getFailedTestCaption() {
@@ -277,7 +278,7 @@ final class PyUnitTestsDebuggingService {
@Override @Override
public int hashCode() { public int hashCode() {
return ((Object)this).hashCode(); return System.identityHashCode(this);
} }
} }
} }

View File

@@ -73,7 +73,7 @@ public class ExeReader extends Bin.Structure {
long result = 0; long result = 0;
long lastVA = 0; long lastVA = 0;
for (ImageSectionHeader header : mySectionHeaders) { for (ImageSectionHeader header : mySectionHeaders) {
long va = ((Value)header.getVirtualAddress()).getValue(); long va = header.getVirtualAddress().getValue();
if (lastVA < va) { if (lastVA < va) {
result = header.getVirtualSize().getValue() + va; result = header.getVirtualSize().getValue() + va;
} }

View File

@@ -170,6 +170,7 @@ public class ProxyTest extends TestCase {
}, false, ArrayUtilRt.EMPTY_OBJECT_ARRAY); }, false, ArrayUtilRt.EMPTY_OBJECT_ARRAY);
assertEquals("a", proxy.sayA()); assertEquals("a", proxy.sayA());
assertEquals("a", ((CovariantFromBaseClassTest.Base)proxy).sayA()); assertEquals("a", ((CovariantFromBaseClassTest.Base)proxy).sayA());
//noinspection RedundantCast
assertEquals("a", ((CovariantFromBaseClassTest.Intf)proxy).sayA()); assertEquals("a", ((CovariantFromBaseClassTest.Intf)proxy).sayA());
} }