Raw type and other warnings fixed

GitOrigin-RevId: cde52de8987d2a995c4d2861f3b77356d79f3dd4
This commit is contained in:
Tagir Valeev
2024-06-28 14:09:43 +02:00
committed by intellij-monorepo-bot
parent 1b6bc7105c
commit 229eff0461
12 changed files with 66 additions and 87 deletions

View File

@@ -56,7 +56,7 @@ public final class PsiMatchers {
}
@NotNull
public static PsiMatcherExpression hasClass(final Class @NotNull ... classes) {
public static PsiMatcherExpression hasClass(final Class<?> @NotNull ... classes) {
return new PsiMatcherExpression() {
@Override
public Boolean match(PsiElement element) {

View File

@@ -33,7 +33,7 @@ public final class InitializationUtils {
}
public static boolean expressionAssignsVariableOrFails(@Nullable PsiExpression expression, @NotNull PsiVariable variable) {
return expressionAssignsVariableOrFails(expression, variable, new HashSet(), true);
return expressionAssignsVariableOrFails(expression, variable, new HashSet<>(), true);
}
public static boolean methodAssignsVariableOrFails(@Nullable PsiMethod method, @NotNull PsiVariable variable, boolean strict) {
@@ -142,11 +142,6 @@ public final class InitializationUtils {
}
}
public static boolean switchStatementAssignsVariableOrFails(@NotNull PsiSwitchStatement switchStatement, @NotNull PsiVariable variable,
boolean strict) {
return switchStatementAssignsVariableOrFails(switchStatement, variable, new HashSet(), strict);
}
private static boolean switchStatementAssignsVariableOrFails(@NotNull PsiSwitchStatement switchStatement, @NotNull PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
final PsiExpression expression = switchStatement.getExpression();
@@ -261,9 +256,7 @@ public final class InitializationUtils {
}
if (BoolUtils.isTrue(condition)) {
final PsiStatement body = whileStatement.getBody();
if (statementAssignsVariableOrFails(body, variable, checkedMethods, strict)) {
return true;
}
return statementAssignsVariableOrFails(body, variable, checkedMethods, strict);
}
return false;
}
@@ -281,9 +274,7 @@ public final class InitializationUtils {
if (statementAssignsVariableOrFails(forStatement.getBody(), variable, checkedMethods, strict)) {
return true;
}
if (statementAssignsVariableOrFails(forStatement.getUpdate(), variable, checkedMethods, strict)) {
return true;
}
return statementAssignsVariableOrFails(forStatement.getUpdate(), variable, checkedMethods, strict);
}
return false;
}
@@ -357,9 +348,7 @@ public final class InitializationUtils {
}
if (lhs instanceof PsiReferenceExpression) {
final PsiElement element = ((PsiReference)lhs).resolve();
if (variable.equals(element)) {
return true;
}
return variable.equals(element);
}
return false;
}

View File

@@ -259,7 +259,7 @@ public abstract class ImportLayoutPanel extends JPanel {
}
@Override
public Class getColumnClass(int col) {
public Class<?> getColumnClass(int col) {
col += panel.areStaticImportsEnabled() ? 0 : 1;
if (col == 0) {
return Boolean.class;
@@ -294,7 +294,7 @@ public abstract class ImportLayoutPanel extends JPanel {
}
else if (col == 2) {
PackageEntry newPackageEntry =
new PackageEntry(packageEntry.isStatic(), packageEntry.getPackageName(), ((Boolean)aValue).booleanValue());
new PackageEntry(packageEntry.isStatic(), packageEntry.getPackageName(), (Boolean)aValue);
packageTable.setEntryAt(newPackageEntry, row);
}
else {

View File

@@ -142,8 +142,8 @@ class ExcludeTable extends ListTableWithButtons<ExcludeTable.Item> {
}
@Override
protected ListTableModel createListModel() {
return new ListTableModel<Item>(NAME_COLUMN, SCOPE_COLUMN);
protected ListTableModel<Item> createListModel() {
return new ListTableModel<>(NAME_COLUMN, SCOPE_COLUMN);
}
@Override

View File

@@ -23,14 +23,14 @@ public final class ClassesWithAnnotatedMembersSearcher extends QueryExecutorBase
@NotNull final Processor<? super PsiClass> consumer) {
SearchScope scope = queryParameters.getScope();
for (QueryExecutor<PsiClass, ClassesWithAnnotatedMembersSearch.Parameters> executor : ClassesWithAnnotatedMembersSearch.EP_NAME.getExtensionList()) {
if (executor instanceof ScopedQueryExecutor) {
scope = scope.intersectWith(GlobalSearchScope.notScope(((ScopedQueryExecutor) executor).getScope(queryParameters)));
if (executor instanceof ScopedQueryExecutor<PsiClass, ClassesWithAnnotatedMembersSearch.Parameters> scopedQueryExecutor) {
scope = scope.intersectWith(GlobalSearchScope.notScope(scopedQueryExecutor.getScope(queryParameters)));
}
}
final Set<PsiClass> processed = new HashSet<>();
AnnotatedElementsSearch.searchPsiMembers(queryParameters.getAnnotationClass(), scope).forEach(member -> {
PsiClass psiClass = ReadAction.compute(() -> member instanceof PsiClass ? (PsiClass)member : member.getContainingClass());
PsiClass psiClass = ReadAction.compute(() -> member instanceof PsiClass cls ? cls : member.getContainingClass());
if (psiClass != null && processed.add(psiClass)) {
consumer.process(psiClass);

View File

@@ -257,8 +257,8 @@ public class EnvironmentVariablesDialog extends DialogWrapper {
}
@Override
protected ListTableModel createListModel() {
return new ListTableModel(new MyNameColumnInfo(), new MyValueColumnInfo());
protected ListTableModel<EnvironmentVariable> createListModel() {
return new ListTableModel<>(new MyNameColumnInfo(), new MyValueColumnInfo());
}
protected class MyNameColumnInfo extends NameColumnInfo {

View File

@@ -48,8 +48,8 @@ public class EnvVariablesTable extends ListTableWithButtons<EnvironmentVariable>
}
@Override
protected ListTableModel createListModel() {
return new ListTableModel(new NameColumnInfo(), new ValueColumnInfo());
protected ListTableModel<EnvironmentVariable> createListModel() {
return new ListTableModel<>(new NameColumnInfo(), new ValueColumnInfo());
}
public void editVariableName(final EnvironmentVariable environmentVariable) {

View File

@@ -147,7 +147,7 @@ public abstract class ListTableWithButtons<T> extends Observable {
return myTableView;
}
protected abstract ListTableModel createListModel();
protected abstract ListTableModel<T> createListModel();
protected void setModified() {
setChanged();
@@ -181,7 +181,7 @@ public abstract class ListTableWithButtons<T> extends Observable {
var downButton = ToolbarDecorator.findDownButton(panel);
Stream.of(addButton, removeButton, editButton, upButton, downButton)
.filter(it -> it != null)
.filter(Objects::nonNull)
.forEach(it -> it.addCustomUpdater(e -> myIsEnabled));
if (removeButton != null) {

View File

@@ -17,32 +17,35 @@
package com.intellij.execution.util;
import com.intellij.execution.ExecutionBundle;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.PathMappingSettings;
import com.intellij.util.PathMappingSettings.PathMapping;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
final class PathMappingTable extends ListTableWithButtons<PathMappingSettings.PathMapping> {
final class PathMappingTable extends ListTableWithButtons<PathMapping> {
PathMappingTable() {
getTableView().getEmptyText().setText(ExecutionBundle.message("empty.text.no.mappings"));
}
@Override
protected ListTableModel createListModel() {
ColumnInfo local = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>(ExecutionBundle.message("path.mapping.column.path.local")) {
protected ListTableModel<PathMapping> createListModel() {
ColumnInfo<PathMapping, @NlsContexts.ListItem String> local =
new ElementsColumnInfoBase<>(ExecutionBundle.message("path.mapping.column.path.local")) {
@Override
public @NlsSafe String valueOf(PathMappingSettings.PathMapping pathMapping) {
public @NlsSafe String valueOf(PathMapping pathMapping) {
return pathMapping.getLocalRoot();
}
@Override
public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
public boolean isCellEditable(PathMapping pathMapping) {
return canDeleteElement(pathMapping);
}
@Override
public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
public void setValue(PathMapping pathMapping, String s) {
if (s.equals(valueOf(pathMapping))) {
return;
}
@@ -51,24 +54,25 @@ final class PathMappingTable extends ListTableWithButtons<PathMappingSettings.Pa
}
@Override
protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
protected String getDescription(PathMapping pathMapping) {
return valueOf(pathMapping);
}
};
ColumnInfo remote = new ElementsColumnInfoBase<PathMappingSettings.PathMapping>(ExecutionBundle.message("path.mapping.column.path.remote")) {
ColumnInfo<PathMapping, @NlsContexts.ListItem String> remote =
new ElementsColumnInfoBase<>(ExecutionBundle.message("path.mapping.column.path.remote")) {
@Override
public @NlsSafe String valueOf(PathMappingSettings.PathMapping pathMapping) {
public @NlsSafe String valueOf(PathMapping pathMapping) {
return pathMapping.getRemoteRoot();
}
@Override
public boolean isCellEditable(PathMappingSettings.PathMapping pathMapping) {
public boolean isCellEditable(PathMapping pathMapping) {
return canDeleteElement(pathMapping);
}
@Override
public void setValue(PathMappingSettings.PathMapping pathMapping, String s) {
public void setValue(PathMapping pathMapping, String s) {
if (s.equals(valueOf(pathMapping))) {
return;
}
@@ -77,12 +81,12 @@ final class PathMappingTable extends ListTableWithButtons<PathMappingSettings.Pa
}
@Override
protected String getDescription(PathMappingSettings.PathMapping pathMapping) {
protected String getDescription(PathMapping pathMapping) {
return valueOf(pathMapping);
}
};
return new ListTableModel(local, remote);
return new ListTableModel<>(local, remote);
}
@@ -91,22 +95,22 @@ final class PathMappingTable extends ListTableWithButtons<PathMappingSettings.Pa
}
@Override
protected PathMappingSettings.PathMapping createElement() {
return new PathMappingSettings.PathMapping();
protected PathMapping createElement() {
return new PathMapping();
}
@Override
protected boolean isEmpty(PathMappingSettings.PathMapping element) {
protected boolean isEmpty(PathMapping element) {
return StringUtil.isEmpty(element.getLocalRoot()) && StringUtil.isEmpty(element.getRemoteRoot());
}
@Override
protected PathMappingSettings.PathMapping cloneElement(PathMappingSettings.PathMapping envVariable) {
protected PathMapping cloneElement(PathMapping envVariable) {
return envVariable.clone();
}
@Override
protected boolean canDeleteElement(PathMappingSettings.PathMapping selection) {
protected boolean canDeleteElement(PathMapping selection) {
return true;
}
}

View File

@@ -237,8 +237,8 @@ public final class AntRunConfiguration extends LocatableConfigurationBase implem
private static class PropertiesTable extends ListTableWithButtons<BuildFileProperty> {
@Override
protected ListTableModel createListModel() {
final ColumnInfo nameColumn = new TableColumn(AntBundle.message("column.name.ant.configuration.property.name")) {
protected ListTableModel<BuildFileProperty> createListModel() {
final ColumnInfo<BuildFileProperty, @NlsContexts.ListItem String> nameColumn = new TableColumn(AntBundle.message("column.name.ant.configuration.property.name")) {
@Nullable
@Override
public String valueOf(BuildFileProperty property) {
@@ -250,7 +250,7 @@ public final class AntRunConfiguration extends LocatableConfigurationBase implem
property.setPropertyName(value);
}
};
final ColumnInfo valueColumn = new TableColumn(AntBundle.message("column.name.ant.configuration.property.value")) {
final ColumnInfo<BuildFileProperty, @NlsContexts.ListItem String> valueColumn = new TableColumn(AntBundle.message("column.name.ant.configuration.property.value")) {
@Nullable
@Override
public String valueOf(BuildFileProperty property) {
@@ -262,7 +262,7 @@ public final class AntRunConfiguration extends LocatableConfigurationBase implem
property.setPropertyValue(value);
}
};
return new ListTableModel(nameColumn, valueColumn);
return new ListTableModel<>(nameColumn, valueColumn);
}
@Override

View File

@@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.packaging.artifacts.Artifact;
@@ -23,8 +24,6 @@ import org.jetbrains.plugins.javaFX.JavaFXBundle;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
@@ -66,19 +65,11 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit
myParams.addBrowseFolderListener(JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.run.in.browser.title"), JavaFXBundle.message("javafx.artifact.properties.editor.choose.file.run.in.browser.description"), project, descriptor);
myHtmlTemplate.addBrowseFolderListener(JavaFXBundle.message("javafx.artifact.properties.editor.choose.html.file.title"), JavaFXBundle.message("javafx.artifact.properties.editor.choose.html.file.description"), project,
FileChooserDescriptorFactory.createSingleFileDescriptor(HtmlFileType.INSTANCE));
myEditSignCertificateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myDialog = new JavaFxEditCertificatesDialog(myWholePanel, myProperties, project);
myDialog.show();
}
});
myEnableSigningCB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myEditSignCertificateButton.setEnabled(myEnableSigningCB.isSelected());
}
myEditSignCertificateButton.addActionListener(e -> {
myDialog = new JavaFxEditCertificatesDialog(myWholePanel, myProperties, project);
myDialog.show();
});
myEnableSigningCB.addActionListener(e -> myEditSignCertificateButton.setEnabled(myEnableSigningCB.isSelected()));
myEditAttributesButton.addActionListener(e -> {
final CustomManifestAttributesDialog customManifestAttributesDialog =
@@ -280,8 +271,8 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit
private static final class AttributesTable extends ListTableWithButtons<JavaFxManifestAttribute> {
@Override
protected ListTableModel createListModel() {
final ColumnInfo name = new ElementsColumnInfoBase<JavaFxManifestAttribute>(JavaFXBundle.message(
protected ListTableModel<JavaFxManifestAttribute> createListModel() {
final ColumnInfo<JavaFxManifestAttribute, @NlsContexts.ListItem String> name = new ElementsColumnInfoBase<>(JavaFXBundle.message(
"column.name.artifact.manifest.property.name")) {
@Override
public @Nullable String valueOf(JavaFxManifestAttribute attribute) {
@@ -304,7 +295,8 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit
}
};
final ColumnInfo value = new ElementsColumnInfoBase<JavaFxManifestAttribute>(JavaFXBundle.message("column.name.artifact.manifest.property.value")) {
final ColumnInfo<JavaFxManifestAttribute, @NlsContexts.ListItem String>
value = new ElementsColumnInfoBase<>(JavaFXBundle.message("column.name.artifact.manifest.property.value")) {
@Override
public String valueOf(JavaFxManifestAttribute attr) {
return attr.getValue();
@@ -326,7 +318,7 @@ public final class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEdit
}
};
return new ListTableModel(name, value);
return new ListTableModel<>(name, value);
}
@Override

View File

@@ -2,6 +2,7 @@ package com.intellij.tasks.generic;
import com.intellij.execution.util.ListTableWithButtons;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.tasks.TaskBundle;
import com.intellij.util.ui.AbstractTableCellEditor;
@@ -46,8 +47,8 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
@Override
protected ListTableModel createListModel() {
final ColumnInfo name = new ElementsColumnInfoBase<TemplateVariable>(TaskBundle.message("column.name.name")) {
protected ListTableModel<TemplateVariable> createListModel() {
final ColumnInfo<TemplateVariable, @NlsContexts.ListItem String> name = new ElementsColumnInfoBase<>(TaskBundle.message("column.name.name")) {
@Override
protected @NotNull String getDescription(final TemplateVariable templateVariable) {
return templateVariable.getDescription();
@@ -73,7 +74,8 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
};
final ColumnInfo value = new ElementsColumnInfoBase<TemplateVariable>(TaskBundle.message("column.name.value")) {
final ColumnInfo<TemplateVariable, @NlsContexts.ListItem String> value =
new ElementsColumnInfoBase<>(TaskBundle.message("column.name.value")) {
@Override
public @NotNull String valueOf(TemplateVariable templateVariable) {
return templateVariable.getValue();
@@ -93,16 +95,8 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
@Override
public TableCellRenderer getRenderer(TemplateVariable variable) {
if (variable.isHidden()) {
return new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
return new JPasswordField(value.toString()); //NON-NLS
}
return (table, value1, isSelected, hasFocus, row, column) -> {
return new JPasswordField(value1.toString()); //NON-NLS
};
}
return super.getRenderer(variable);
@@ -135,7 +129,7 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
};
final ColumnInfo isShownOnFirstTab = new ColumnInfo<TemplateVariable, Boolean>(TaskBundle.message("column.name.show.on.first.tab")) {
final ColumnInfo<TemplateVariable, Boolean> isShownOnFirstTab = new ColumnInfo<>(TaskBundle.message("column.name.show.on.first.tab")) {
@Override
public @NotNull Boolean valueOf(TemplateVariable o) {
return o.isShownOnFirstTab();
@@ -148,7 +142,7 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
@Override
public Class getColumnClass() {
public Class<?> getColumnClass() {
return Boolean.class;
}
@@ -163,7 +157,7 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
};
final ColumnInfo isHidden = new ColumnInfo<TemplateVariable, Boolean>(TaskBundle.message("column.name.hide")) {
final ColumnInfo<TemplateVariable, Boolean> isHidden = new ColumnInfo<>(TaskBundle.message("column.name.hide")) {
@Override
public @NotNull Boolean valueOf(TemplateVariable o) {
return o.isHidden();
@@ -178,7 +172,7 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
}
@Override
public Class getColumnClass() {
public Class<?> getColumnClass() {
return Boolean.class;
}
@@ -192,7 +186,7 @@ public class ManageTemplateVariablesDialog extends DialogWrapper {
return TaskBundle.message("tooltip.whether.this.template.variable.will.be.hidden.like.password.field");
}
};
return new ListTableModel(name, value, isShownOnFirstTab, isHidden);
return new ListTableModel<>(name, value, isShownOnFirstTab, isHidden);
}
@Override