diff --git a/java/java-impl/src/com/intellij/internal/UsedIconsListingAction.java b/java/java-impl/src/com/intellij/internal/UsedIconsListingAction.java index dba0cd127ed2..e744b1cb2f4c 100644 --- a/java/java-impl/src/com/intellij/internal/UsedIconsListingAction.java +++ b/java/java-impl/src/com/intellij/internal/UsedIconsListingAction.java @@ -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 xmlAttributes = new ArrayList<>(); @@ -182,7 +177,6 @@ final class UsedIconsListingAction extends AnAction { PsiClass iconClass) { final HashMap mappings = new HashMap<>(); collectFields(iconClass, "", mappings); - System.out.println("Found " + mappings.size() + " icons in " + iconClass.getQualifiedName()); GlobalSearchScope useScope = (GlobalSearchScope)iconClass.getUseScope(); diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java index dbcd9789d7ac..c012edd94f3f 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -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 = ""; diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/DomHelper.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/DomHelper.java index fe2d3b14c6e4..868955437f5c 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/DomHelper.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/DomHelper.java @@ -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) { diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/JavaFxRelatedItemLineMarkerProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/JavaFxRelatedItemLineMarkerProvider.java index 06475ee84a4d..8b899309a09f 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/JavaFxRelatedItemLineMarkerProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/JavaFxRelatedItemLineMarkerProvider.java @@ -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; }); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection.java index d236891633fb..7a80b8510015 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection.java @@ -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()) { diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java index 7d86b2674342..e0ea9fd4db37 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java @@ -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)}; } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java index 7f83a0dfa6d4..2ae6c6b616a1 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java @@ -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 : 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 : prevSibl = / + } + else { + list.addAll(getFunctionCompletions(element)); + list.addAll(getVariableCompletions(element)); + } } if (principalType == XPathNodeTest.PrincipalType.ELEMENT && prefixedName.getPrefix() == null) { list.addAll(getNodeTypeCompletions(element)); diff --git a/plugins/yaml/src/org/jetbrains/yaml/formatter/YAMLFormattingContext.java b/plugins/yaml/src/org/jetbrains/yaml/formatter/YAMLFormattingContext.java index 6f76153144f3..9b85c5ae4935 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/formatter/YAMLFormattingContext.java +++ b/plugins/yaml/src/org/jetbrains/yaml/formatter/YAMLFormattingContext.java @@ -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; + } } } diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java index 8b96ea4fbbb8..01a0f6b15601 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java @@ -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; }