From 8fdcb6e59b747eb4c23d84c2087c0a3eee632c39 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 21 Dec 2011 15:20:18 +0100 Subject: [PATCH] IDEA-79048 (False positive 'collection queried but never updated' report) --- .../siyeh/ig/psiutils/VariableAssignedVisitor.java | 6 +++--- .../MismatchedCollectionQueryUpdate.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java index 59a48f74f8ac..99c2137acf56 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,10 +73,10 @@ class VariableAssignedVisitor extends JavaRecursiveElementVisitor { if (assigned) { return; } + super.visitPrefixExpression(prefixExpression); if (!checkUnaryExpressions) { return; } - super.visitPrefixExpression(prefixExpression); final IElementType tokenType = prefixExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.PLUSPLUS) && !tokenType.equals(JavaTokenType.MINUSMINUS)) { @@ -94,10 +94,10 @@ class VariableAssignedVisitor extends JavaRecursiveElementVisitor { if (assigned) { return; } + super.visitPostfixExpression(postfixExpression); if (!checkUnaryExpressions) { return; } - super.visitPostfixExpression(postfixExpression); final IElementType tokenType = postfixExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.PLUSPLUS) && !tokenType.equals(JavaTokenType.MINUSMINUS)) { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java index 369146295d13..c595e4e93337 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java @@ -166,4 +166,15 @@ public class MismatchedCollectionQueryUpdate { for (final String value : ourValues) {} } } + + private void updateAttachmentWarning(final String message) { + final List includedAttachments; + if (message instanceof Object && + !(includedAttachments = boo()).isEmpty()) { + if (includedAttachments.size() == 1) { + } + } + } + + List boo() {return null;} }