replacing == and != for strings where appropriate

This commit is contained in:
Dmitry Jemerov
2012-11-09 20:19:44 +01:00
parent 88676aa8fa
commit ef73c9a750
9 changed files with 17 additions and 19 deletions
@@ -33,7 +33,7 @@ public class AddDefaultConstructorFix extends AddMethodFix {
}
private static String generateConstructor(final String className, @PsiModifier.ModifierConstant final String modifier) {
if (modifier == PsiModifier.PACKAGE_LOCAL) {
if (modifier.equals(PsiModifier.PACKAGE_LOCAL)) {
return className + "() {}";
}
return modifier + " " + className + "() {}";
@@ -137,7 +137,7 @@ public class NullableNotNullManager implements PersistentStateComponent<Element>
if (DEFAULT_NULLABLES.length != getNullables().size() || DEFAULT_NOT_NULLS.length != getNotNulls().size()) {
return false;
}
if (myDefaultNotNull != AnnotationUtil.NOT_NULL || myDefaultNullable != AnnotationUtil.NULLABLE) {
if (!myDefaultNotNull.equals(AnnotationUtil.NOT_NULL) || !myDefaultNullable.equals(AnnotationUtil.NULLABLE)) {
return false;
}
for (int i = 0; i < DEFAULT_NULLABLES.length; i++) {
@@ -153,7 +153,7 @@ public class DefaultLogFilterModel extends LogFilterModel {
final String type = LogConsolePreferences.getType(line);
Key contentType = type != null
? LogConsolePreferences.getProcessOutputTypes(type)
: (myPrevType == LogConsolePreferences.ERROR ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT);
: (myPrevType.equals(LogConsolePreferences.ERROR) ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT);
if (type != null) {
myPrevType = type;
}
@@ -377,7 +377,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
}
public Object getData(@NonNls String dataId) {
if (dataId == myKey) return StructureViewWrapperImpl.this;
if (dataId.equals(myKey)) return StructureViewWrapperImpl.this;
return null;
}
}
@@ -67,7 +67,7 @@ abstract class RenameChooser {
dropHighlighters();
final MarkupModel markupModel = myEditor.getMarkupModel();
if (selectedValue == ALL_OCCURRENCES) {
if (selectedValue.equals(ALL_OCCURRENCES)) {
for (Pair<PsiElement, TextRange> pair : stringUsages) {
final TextRange textRange = pair.second.shiftRight(pair.first.getTextOffset());
final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter(
@@ -96,7 +96,7 @@ abstract class RenameChooser {
.setRequestFocus(true)
.setItemChoosenCallback(new Runnable() {
public void run() {
runRenameTemplate(list.getSelectedValue() == ALL_OCCURRENCES ? stringUsages : new ArrayList<Pair<PsiElement, TextRange>>());
runRenameTemplate(list.getSelectedValue().equals(ALL_OCCURRENCES) ? stringUsages : new ArrayList<Pair<PsiElement, TextRange>>());
}
})
.addListener(new JBPopupAdapter() {
@@ -107,7 +107,7 @@ public class LabeledComponent<Comp extends JComponent> extends JPanel implements
public void setLabelLocation(@NonNls String borderConstrains) {
String constrains = findBorderConstrains(borderConstrains);
if (constrains == null || constrains == myLabelConstraints) return;
if (constrains == null || constrains.equals(myLabelConstraints)) return;
myLabelConstraints = borderConstrains;
insertLabel();
}
@@ -17,6 +17,8 @@ package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -124,17 +126,12 @@ public class TestSuiteStack {
return EMPTY;
}
final StringBuilder builder = new StringBuilder();
final String lastName = names[names.length - 1];
for (String name : names) {
builder.append('[').append(name).append(']');
//Here we can use != instead of !equals()
//noinspection StringEquality
if (name != lastName) {
builder.append("->");
return StringUtil.join(names, new Function<String, String>() {
@Override
public String fun(String s) {
return "[" + s + "]";
}
}
return builder.toString();
}, "->");
}
public void clear() {
@@ -93,7 +93,7 @@ public enum FragmentSide {
public static FragmentSide chooseSide(DiffFragment oneSide) {
LOG.assertTrue(oneSide.isOneSide());
LOG.assertTrue(oneSide.getText1() != oneSide.getText2());
LOG.assertTrue(!oneSide.getText1().equals(oneSide.getText2()));
return oneSide.getText1() == null ? SIDE2 : SIDE1;
}
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.groovy.mvc;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataKeys;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.DumbAwareAction;
@@ -29,7 +30,7 @@ public abstract class MvcActionBase extends DumbAwareAction {
@Nullable
public static Pair<MvcFramework, Module> guessFramework(AnActionEvent event) {
final Module module = event.getData(event.getPlace() == ActionPlaces.MAIN_MENU ? DataKeys.MODULE : DataKeys.MODULE_CONTEXT);
final Module module = event.getData(event.getPlace().equals(ActionPlaces.MAIN_MENU) ? LangDataKeys.MODULE : LangDataKeys.MODULE_CONTEXT);
if (module != null) {
MvcFramework commonPluginModuleFramework = MvcFramework.findCommonPluginModuleFramework(module);