Warnings fixed

GitOrigin-RevId: 2674a9c13605060c29d641488e76a716c714e495
This commit is contained in:
Tagir Valeev
2023-10-06 12:18:23 +02:00
committed by intellij-monorepo-bot
parent 53a325ebc5
commit 01201752be
21 changed files with 78 additions and 76 deletions

View File

@@ -111,9 +111,10 @@ public final class PsiTypeLookupItem extends LookupItem<Object> implements Typed
}
PsiElement position = context.getFile().findElementAt(context.getStartOffset());
boolean insideVarDeclaration = position.getParent() instanceof PsiTypeElement typeElement &&
typeElement.getParent() instanceof PsiVariable;
boolean insideVarDeclaration = false;
if (position != null) {
insideVarDeclaration = position.getParent() instanceof PsiTypeElement typeElement &&
typeElement.getParent() instanceof PsiVariable;
int genericsStart = context.getTailOffset();
context.getDocument().insertString(genericsStart, JavaCompletionUtil.escapeXmlIfNeeded(context, calcGenerics(position, context)));
JavaCompletionUtil.shortenReference(context.getFile(), genericsStart - 1);

View File

@@ -29,9 +29,9 @@ public final class SimpleProtobufClient<T extends ProtobufResponseHandler> {
}
private final AtomicReference<State> myState = new AtomicReference<>(State.DISCONNECTED);
protected final ChannelInitializer myChannelInitializer;
protected final EventLoopGroup myEventLoopGroup;
protected volatile ChannelFuture myConnectFuture;
private final ChannelInitializer myChannelInitializer;
private final EventLoopGroup myEventLoopGroup;
private volatile ChannelFuture myConnectFuture;
private final ProtobufClientMessageHandler<T> myMessageHandler;
public SimpleProtobufClient(final MessageLite msgDefaultInstance, final Executor asyncExec, final UUIDGetter uuidGetter) {
@@ -49,7 +49,7 @@ public final class SimpleProtobufClient<T extends ProtobufResponseHandler> {
};
}
public final void checkConnected() throws Exception {
public void checkConnected() throws Exception {
if (myState.get() != State.CONNECTED) {
throw new Exception("Client not connected");
}
@@ -83,11 +83,11 @@ public final class SimpleProtobufClient<T extends ProtobufResponseHandler> {
return true;
}
protected void onConnect() {
private void onConnect() {
}
protected void beforeDisconnect() {
private void beforeDisconnect() {
}
protected void onDisconnect() {
private void onDisconnect() {
}
public final void disconnect() {

View File

@@ -20,7 +20,7 @@ public final class JvmModule extends JVMClassNode<JvmModule, JvmModule.Diff>{
myExports = exports;
}
public final String getVersion() {
public String getVersion() {
return myVersion;
}

View File

@@ -122,7 +122,7 @@ public final class CompileContextImpl extends UserDataHolderBase implements Comp
}
@Override
public final @NotNull CanceledStatus getCancelStatus() {
public @NotNull CanceledStatus getCancelStatus() {
return myCancelStatus;
}

View File

@@ -15,18 +15,14 @@ public class SerializationTest extends BasePlatformTestCase {
public void testFileSource() throws IOException {
FileSourceNodeSerializerImpl serializer = new FileSourceNodeSerializerImpl();
FileSource node = new FileSource(Path.of("./src/main/Foo.java"));
FileSource serializedNode;
String serializedData = "";
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutput = new DataOutputStream(byteArrayOutputStream)) {
serializer.write(node, dataOutput);
serializedData = byteArrayOutputStream.toString(StandardCharsets.UTF_8);
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutput = new DataOutputStream(byteArrayOutputStream);
serializer.write(node, dataOutput);
String serializedData = byteArrayOutputStream.toString(StandardCharsets.UTF_8);
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(serializedData.getBytes("UTF-8"));
DataInputStream dataInput = new DataInputStream(byteArrayInputStream)) {
serializedNode = serializer.read(dataInput);
}
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(serializedData.getBytes(StandardCharsets.UTF_8));
DataInputStream dataInput = new DataInputStream(byteArrayInputStream);
FileSource serializedNode = serializer.read(dataInput);
assertEquals(node.getPath(), serializedNode.getPath());
}

View File

@@ -43,7 +43,7 @@ public class LookupManagerImpl extends LookupManager {
connection.subscribe(EditorHintListener.TOPIC, new EditorHintListener() {
@Override
public void hintShown(@NotNull Editor editor, @NotNull LightweightHint hint, int flags, @NotNull HintHint hintInfo) {
if (project == myProject) {
if (editor.getProject() == myProject) {
Lookup lookup = getActiveLookup();
if (lookup != null && BitUtil.isSet(flags, HintManager.HIDE_BY_LOOKUP_ITEM_CHANGE)) {
lookup.addLookupListener(new LookupListener() {

View File

@@ -578,7 +578,6 @@ public final class AppendOnlyLogOverMMappedFile implements AppendOnlyLog, Unmapp
public void closeAndUnsafelyUnmap() throws IOException {
close();
storage.closeAndUnsafelyUnmap();
;
}
/**

View File

@@ -31,7 +31,8 @@ import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Deque;
/**
* StdXMLReader reads the data to be parsed.
@@ -44,7 +45,7 @@ public class StdXMLReader {
/**
* The stack of readers.
*/
private final Stack readers;
private final Deque<StackedReader> readers;
/**
* The current push-back reader.
*/
@@ -78,7 +79,7 @@ public class StdXMLReader {
}
currentReader = new StackedReader();
readers = new Stack();
readers = new ArrayDeque<>();
Reader reader = openStream(publicID, systemIDasURL.toString());
currentReader.lineReader = new LineNumberReader(reader);
currentReader.pbReader = new PushbackReader(currentReader.lineReader, 2);
@@ -92,7 +93,7 @@ public class StdXMLReader {
*/
public StdXMLReader(Reader reader) {
currentReader = new StackedReader();
readers = new Stack();
readers = new ArrayDeque<>();
currentReader.lineReader = new LineNumberReader(reader);
currentReader.pbReader = new PushbackReader(currentReader.lineReader, 2);
currentReader.publicId = "";
@@ -117,7 +118,7 @@ public class StdXMLReader {
StringBuilder charsRead = new StringBuilder();
Reader reader = stream2reader(stream, charsRead);
currentReader = new StackedReader();
readers = new Stack();
readers = new ArrayDeque<>();
currentReader.lineReader = new LineNumberReader(reader);
currentReader.pbReader = new PushbackReader(currentReader.lineReader, 2);
currentReader.publicId = "";
@@ -260,12 +261,12 @@ public class StdXMLReader {
int ch = currentReader.pbReader.read();
while (ch < 0) {
if (readers.empty()) {
if (readers.isEmpty()) {
throw new IOException("Unexpected EOF");
}
currentReader.pbReader.close();
currentReader = (StackedReader)readers.pop();
currentReader = readers.pop();
ch = currentReader.pbReader.read();
}
@@ -281,12 +282,12 @@ public class StdXMLReader {
int ch = currentReader.pbReader.read();
while (ch < 0) {
if (readers.empty()) {
if (readers.isEmpty()) {
return true;
}
currentReader.pbReader.close();
currentReader = (StackedReader)readers.pop();
currentReader = readers.pop();
ch = currentReader.pbReader.read();
}
@@ -397,7 +398,7 @@ public class StdXMLReader {
*/
public int getLineNr() {
if (currentReader.lineReader == null) {
StackedReader sr = (StackedReader)readers.peek();
StackedReader sr = readers.peek();
if (sr.lineReader == null) {
return 0;
@@ -463,8 +464,7 @@ public class StdXMLReader {
StdXMLReader r = new StdXMLReader(new FileInputStream(filename));
r.setSystemID(filename);
for (int i = 0; i < r.readers.size(); i++) {
StackedReader sr = (StackedReader)r.readers.elementAt(i);
for (StackedReader sr : r.readers) {
sr.systemId = r.currentReader.systemId;
}
@@ -477,7 +477,7 @@ public class StdXMLReader {
* @author Marc De Scheemaecker
* @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
*/
private final class StackedReader {
private static final class StackedReader {
PushbackReader pbReader;

View File

@@ -79,7 +79,7 @@ public final class UrlClassLoader extends ClassLoader {
// called via reflection
@SuppressWarnings({"unused", "MethodMayBeStatic"})
@NotNull
public final long[] getLoadingStats() {
public long[] getLoadingStats() {
return new long[]{ClassPath.getTotalTime(), ClassPath.getTotalRequests()};
}
@@ -236,7 +236,7 @@ public final class UrlClassLoader extends ClassLoader {
/** @deprecated adding URLs to a classloader at runtime could lead to hard-to-debug errors */
@Deprecated
public final void addURL(@NotNull URL url) {
public void addURL(@NotNull URL url) {
getClassPath().addURL(url);
myURLs.add(url);
}
@@ -251,7 +251,7 @@ public final class UrlClassLoader extends ClassLoader {
}
@Nullable
private final Class<?> _findClass(@NotNull String name) {
private Class<?> _findClass(@NotNull String name) {
Resource resource = getClassPath().getResource(name.replace('.', '/') + CLASS_EXTENSION);
if (resource == null) {
return null;

View File

@@ -20,7 +20,7 @@ public final class HtmlAddTableColumnAfterAction extends CodeInsightAction {
};
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -21,7 +21,7 @@ public final class HtmlAddTableColumnBeforeAction extends CodeInsightAction {
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -25,7 +25,7 @@ public final class HtmlTableCellNavigateDownAction extends CodeInsightAction {
};
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -25,7 +25,7 @@ public final class HtmlTableCellNavigateLeftAction extends CodeInsightAction {
};
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -25,7 +25,7 @@ public final class HtmlTableCellNavigateRightAction extends CodeInsightAction {
};
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -25,7 +25,7 @@ public final class HtmlTableCellNavigateUpAction extends CodeInsightAction {
};
}
@Override
protected final @NotNull CodeInsightActionHandler getHandler() {
protected @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}

View File

@@ -6,5 +6,5 @@ import org.jetbrains.idea.maven.model.MavenArchetype;
import java.util.Set;
public interface MavenArchetypeContainer {
public Set<MavenArchetype> getArchetypes();
Set<MavenArchetype> getArchetypes();
}

View File

@@ -10,7 +10,7 @@ import java.util.Collection;
import java.util.List;
public interface MavenIndex extends MavenSearchIndex, MavenGAVIndex, MavenArchetypeContainer, MavenUpdatableIndex {
public static final Topic<IndexListener> INDEX_IS_BROKEN =
Topic<IndexListener> INDEX_IS_BROKEN =
new Topic<>("Maven Index Broken Listener", IndexListener.class);
@NotNull List<AddArtifactResponse> tryAddArtifacts(@NotNull Collection<File> artifactFiles);

View File

@@ -790,11 +790,11 @@ public abstract class MavenProjectsManager extends MavenSimpleProjectComponent
@Deprecated
protected abstract List<Module> updateAllMavenProjectsSync(MavenImportSpec spec);
@TestOnly
@Deprecated
/**
* @deprecated Use {@link #scheduleUpdateAllMavenProjects(MavenImportSpec)}} or {@link #updateAllMavenProjects(MavenImportSpec, Continuation)}
*/
@TestOnly
@Deprecated
public synchronized void resetManagedFilesAndProfilesInTests(List<VirtualFile> files, MavenExplicitProfiles explicitProfiles) {
myProjectsTree.resetManagedFilesAndProfiles(files, explicitProfiles);
updateAllMavenProjectsSync(MavenImportSpec.EXPLICIT_IMPORT);

View File

@@ -115,7 +115,12 @@ class AddMavenDependencyQuickFixTest : MavenDomWithIndicesTestCase() {
}
val pomText = readAction { PsiManager.getInstance(myProject).findFile(myProjectPom)!!.getText() }
assertEquals("""
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion><groupId>test</groupId>
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>project</artifactId>
<version>1</version>
<dependencies>
@@ -167,7 +172,12 @@ class AddMavenDependencyQuickFixTest : MavenDomWithIndicesTestCase() {
}
val pomText = readAction { PsiManager.getInstance(myProject).findFile(myProjectPom)!!.getText() }
assertEquals("""
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion><groupId>test</groupId><artifactId>project</artifactId><version>1</version>
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId><artifactId>project</artifactId><version>1</version>
<dependencies>
<dependency>
<groupId>commons-io</groupId>

View File

@@ -48,7 +48,8 @@ class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
UsefulTestCase.assertSameLines("""
<?xml version="1.0"?>${'\r'}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"${'\r'}
<project xmlns="http://maven.apache.org/POM/4.0.0"${'\r'}
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"${'\r'}
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">${'\r'}
<modelVersion>4.0.0</modelVersion>${'\r'}
<groupId>foo</groupId>${'\r'}
@@ -74,7 +75,8 @@ class MavenModelReadingAndWritingTest : MavenMultiVersionImportingTestCase() {
UsefulTestCase.assertSameLines("""
<?xml version="1.0"?>${'\r'}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"${'\r'}
<project xmlns="http://maven.apache.org/POM/4.0.0"${'\r'}
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"${'\r'}
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">${'\r'}
<modelVersion>4.0.0</modelVersion>${'\r'}
<groupId>test</groupId>${'\r'}

View File

@@ -218,7 +218,7 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
private void checkAllMavenConnectorsDisposed() {
private static void checkAllMavenConnectorsDisposed() {
assertEmpty("all maven connectors should be disposed", MavenServerManager.getInstance().getAllConnectors());
}
@@ -366,7 +366,7 @@ public abstract class MavenTestCase extends UsefulTestCase {
protected VirtualFile createSettingsXml(String innerContent) throws IOException {
var content = createSettingsXmlContent(innerContent);
var path = Path.of(myDir.getPath(), "settings.xml");
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
Files.writeString(path, content);
getMavenGeneralSettings().setUserSettingsFile(path.toString());
return LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path);
}
@@ -426,10 +426,7 @@ public abstract class MavenTestCase extends UsefulTestCase {
VirtualFile f = dir.findChild("pom.xml");
if (f == null) {
try {
f = WriteAction.computeAndWait(() -> {
VirtualFile res = dir.createChildData(null, "pom.xml");
return res;
});
f = WriteAction.computeAndWait(() -> dir.createChildData(null, "pom.xml"));
}
catch (IOException e) {
throw new RuntimeException(e);
@@ -441,15 +438,15 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
@NonNls
@Language(value = "XML")
@Language("XML")
public static String createPomXml(@NonNls @Language(value = "XML", prefix = "<project>", suffix = "</project>") String xml) {
return "<?xml version=\"1.0\"?>" +
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\"" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">" +
" <modelVersion>4.0.0</modelVersion>" +
xml +
"</project>";
return """
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
""" + xml + "</project>";
}
protected VirtualFile createProfilesXmlOldStyle(String xml) {
@@ -484,10 +481,7 @@ public abstract class MavenTestCase extends UsefulTestCase {
VirtualFile f = dir.findChild("profiles.xml");
if (f == null) {
try {
f = WriteAction.computeAndWait(() -> {
VirtualFile res = dir.createChildData(null, "profiles.xml");
return res;
});
f = WriteAction.computeAndWait(() -> dir.createChildData(null, "profiles.xml"));
}
catch (IOException e) {
throw new RuntimeException(e);
@@ -498,7 +492,7 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
@Language("XML")
private static String createValidProfiles(String xml, boolean oldStyle) {
private static String createValidProfiles(@Language("XML") String xml, boolean oldStyle) {
if (oldStyle) {
return "<?xml version=\"1.0\"?>" +
"<profiles>" +
@@ -601,10 +595,10 @@ public abstract class MavenTestCase extends UsefulTestCase {
protected static <T> void assertContain(Collection<? extends T> actual, T... expected) {
List<T> expectedList = Arrays.asList(expected);
if (actual.containsAll(expectedList)) return;
Set<T> absent = new HashSet<T>(expectedList);
Set<T> absent = new HashSet<>(expectedList);
absent.removeAll(actual);
fail("expected: " + expectedList + "\n" + "actual: " + actual.toString() +
"\nthis elements not present: " + absent.toString());
fail("expected: " + expectedList + "\n" + "actual: " + actual +
"\nthis elements not present: " + absent);
}
protected static <T> void assertDoNotContain(List<T> actual, T... expected) {