Fix constant values warnings

GitOrigin-RevId: 294c425cf982195817b4c8c762930676187abd9d
This commit is contained in:
Tagir Valeev
2022-12-05 15:06:23 +00:00
committed by intellij-monorepo-bot
parent 383a2d7315
commit 604f30df53
9 changed files with 29 additions and 57 deletions
@@ -6,7 +6,6 @@ import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.project.Project;
@@ -105,18 +104,14 @@ final class UsedIconsListingAction extends AnAction {
PsiMethod getIconMethod = iconLoader.findMethodsByName("getIcon", false)[0];
PsiMethod findIconMethod = iconLoader.findMethodsByName("findIcon", false)[0];
if (true) {
MethodReferencesSearch.search(getIconMethod, false).forEach(consumer);
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
}
MethodReferencesSearch.search(getIconMethod, false).forEach(consumer);
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
if (true) {
PsiClass javaeeIcons = psiFacade.findClass("com.intellij.javaee.JavaeeIcons", allScope);
MethodReferencesSearch.search(javaeeIcons.findMethodsByName("getIcon", false)[0], false).forEach(consumer);
PsiClass javaeeIcons = psiFacade.findClass("com.intellij.javaee.JavaeeIcons", allScope);
MethodReferencesSearch.search(javaeeIcons.findMethodsByName("getIcon", false)[0], false).forEach(consumer);
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
}
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
final List<XmlAttribute> xmlAttributes = new ArrayList<>();
@@ -182,7 +177,6 @@ final class UsedIconsListingAction extends AnAction {
PsiClass iconClass) {
final HashMap<String, String> mappings = new HashMap<>();
collectFields(iconClass, "", mappings);
System.out.println("Found " + mappings.size() + " icons in " + iconClass.getQualifiedName());
GlobalSearchScope useScope = (GlobalSearchScope)iconClass.getUseScope();
@@ -634,9 +634,8 @@ public class ClassWriter {
try {
boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE);
boolean isAnnotation = cl.hasModifier(CodeConstants.ACC_ANNOTATION);
boolean isEnum = cl.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM);
boolean isDeprecated = mt.hasAttribute(StructGeneralAttribute.ATTRIBUTE_DEPRECATED);
boolean clInit = false, init = false, dInit = false;
boolean clInit = false, dInit = false;
MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor());
@@ -677,9 +676,6 @@ public class ClassWriter {
if (mask != null) {
actualParams = mask.stream().filter(Objects::isNull).count();
}
else if (isEnum && init) {
actualParams -= 2;
}
if (actualParams != descriptor.parameterTypes.size()) {
String message = "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor() + " in " + cl.qualifiedName;
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
@@ -700,6 +696,7 @@ public class ClassWriter {
}
String name = mt.getName();
boolean init = false;
if (CodeConstants.INIT_NAME.equals(name)) {
if (node.type == ClassNode.CLASS_ANONYMOUS) {
name = "";
@@ -322,10 +322,6 @@ public final class DomHelper {
if (reducibility > 0) {
// try {
// DotExporter.toDotFile(general, new File("c:\\Temp\\stat1.dot"));
// } catch(Exception ex) {ex.printStackTrace();}
// take care of irreducible control flow graphs
if (IrreducibleCFGDeobfuscator.isStatementIrreducible(general)) {
if (!IrreducibleCFGDeobfuscator.splitIrreducibleNode(general)) {
@@ -334,16 +330,11 @@ public final class DomHelper {
}
}
else {
if (mapstage == 2 || mapRefreshed) { // last chance lost
if (mapRefreshed) { // last chance lost
DecompilerContext.getLogger().writeMessage("Statement cannot be decomposed although reducible!", IFernflowerLogger.Severity.ERROR);
}
break;
}
// try {
// DotExporter.toDotFile(general, new File("c:\\Temp\\stat1.dot"));
// } catch(Exception ex) {ex.printStackTrace();}
mapExtPost = new HashMap<>();
mapRefreshed = true;
}
@@ -384,12 +375,6 @@ public final class DomHelper {
}
}
}
// try {
// DotExporter.toDotFile(general, new File("c:\\Temp\\stat1.dot"));
// } catch (Exception ex) {
// ex.printStackTrace();
// }
}
if (mapRefreshed) {
@@ -88,15 +88,13 @@ public class JavaFxRelatedItemLineMarkerProvider extends RelatedItemLineMarkerPr
ReferencesSearch.search(field, GlobalSearchScope.filesScope(field.getProject(), fxmls)).forEach(
reference -> {
final PsiElement referenceElement = reference.getElement();
if (referenceElement == null) return true;
final PsiFile containingFile = referenceElement.getContainingFile();
if (containingFile == null) return true;
if (!JavaFxFileTypeFactory.isFxml(containingFile)) return true;
if (!(referenceElement instanceof XmlAttributeValue)) return true;
final XmlAttributeValue attributeValue = (XmlAttributeValue)referenceElement;
if (!(referenceElement instanceof final XmlAttributeValue attributeValue)) return true;
final PsiElement parent = attributeValue.getParent();
if (!(parent instanceof XmlAttribute)) return true;
if (!FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName())) return true;
if (!(parent instanceof XmlAttribute attribute)) return true;
if (!FxmlConstants.FX_ID.equals(attribute.getName())) return true;
targets.add(fun.fun(parent));
return !stopAtFirst;
});
@@ -181,7 +181,7 @@ public final class JavaFxRedundantPropertyValueInspection extends XmlSuppressabl
if (line.isEmpty() || line.startsWith("--")) continue;
boolean lineParsed = false;
final int p1 = line.indexOf('#');
if (p1 > 0 && p1 < line.length()) {
if (p1 > 0) {
final String className = line.substring(0, p1);
final int p2 = line.indexOf('=', p1);
if (p2 > p1 && p2 < line.length()) {
@@ -58,11 +58,9 @@ class JavaFxEventHandlerReferenceProvider extends JavaFxControllerBasedReference
return new PsiReference[]{new PsiMultiReference(references, xmlAttributeValue)};
}
if (references.length == 0) {
final XmlTag rootTag = ((XmlFile)xmlAttributeValue.getContainingFile()).getRootTag();
if (rootTag == null || FxmlConstants.FX_ROOT.equals(rootTag.getName())) {
return PsiReference.EMPTY_ARRAY;
}
final XmlTag rootTag = ((XmlFile)xmlAttributeValue.getContainingFile()).getRootTag();
if (rootTag == null || FxmlConstants.FX_ROOT.equals(rootTag.getName())) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[]{new JavaFxEventHandlerReference(xmlAttributeValue, null, controllerClass)};
}
@@ -202,16 +202,17 @@ public final class CompletionLists {
lp = PsiTreeUtil.getParentOfType(lp == null ? element : lp, XPathLocationPath.class, true);
} while (lp != null && lp.getPrevSibling() == null);
check = lp == null || (sibling = lp.getPrevSibling()) != null;
}
if (check) {
if (sibling instanceof XPathToken && XPathTokenTypes.PATH_OPS.contains(((XPathToken)sibling).getTokenType())) {
// xx/yy<caret> : prevSibl = /
} else {
list.addAll(getFunctionCompletions(element));
list.addAll(getVariableCompletions(element));
if (lp != null) {
sibling = lp.getPrevSibling();
}
}
if (sibling instanceof XPathToken && XPathTokenTypes.PATH_OPS.contains(((XPathToken)sibling).getTokenType())) {
// xx/yy<caret> : prevSibl = /
}
else {
list.addAll(getFunctionCompletions(element));
list.addAll(getVariableCompletions(element));
}
}
if (principalType == XPathNodeTest.PrincipalType.ELEMENT && prefixedName.getPrefix() == null) {
list.addAll(getNodeTypeCompletions(element));
@@ -412,12 +412,11 @@ class YAMLFormattingContext {
@Nullable
private static ASTNode getPreviousNonBlankNode(ASTNode node) {
do {
while (true) {
node = TreeUtil.prevLeaf(node);
if (!YAMLElementTypes.BLANK_ELEMENTS.contains(PsiUtilCore.getElementType(node))) {
if (node == null || !YAMLElementTypes.BLANK_ELEMENTS.contains(PsiUtilCore.getElementType(node))) {
return node;
}
} while (node != null);
return null;
}
}
}
@@ -83,7 +83,7 @@ public class XmlWrongClosingTagNameInspection implements Annotator {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
if (contextNode != null) {
// TODO: we should check for concatenations here
return;
}
@@ -110,7 +110,7 @@ public class XmlWrongClosingTagNameInspection implements Annotator {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
if (contextNode != null) {
// TODO: we should check for concatenations here
return;
}