Skip to content

Commit

Permalink
use Couple
Browse files Browse the repository at this point in the history
  • Loading branch information
bulenkov committed May 8, 2014
1 parent 43ba882 commit 5543b2f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,9 @@
package org.intellij.images.completion;

import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.file.FileLookupInfoProvider;
import com.intellij.util.indexing.FileBasedIndex;
import org.intellij.images.fileTypes.ImageFileTypeManager;
Expand All @@ -30,7 +30,7 @@
*/
public class ImageLookupInfoProvider extends FileLookupInfoProvider {

public Pair<String, String> getLookupInfo(@NotNull VirtualFile file, Project project) {
public Couple<String> getLookupInfo(@NotNull VirtualFile file, Project project) {
final String[] s = new String[] {null};
ImageInfoIndex.processValues(file, new FileBasedIndex.ValueProcessor<ImageInfoIndex.ImageInfo>() {
@SuppressWarnings({"HardCodedStringLiteral"})
Expand All @@ -40,7 +40,7 @@ public boolean process(VirtualFile file, ImageInfoIndex.ImageInfo value) {
}
}, project);

return s[0] == null ? null : new Pair<String, String>(file.getName(), s[0]);
return s[0] == null ? null : Couple.newOne(file.getName(), s[0]);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.util.IncorrectOperationException;
Expand All @@ -45,8 +45,8 @@ public JavaCreatePropertyFix(PsiElement element, String key, final List<Properti
}

@Override
protected Pair<String, String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) {
final Pair<String, String> result = super.doAction(project, psiElement, model);
protected Couple<String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) {
final Couple<String> result = super.doAction(project, psiElement, model);
if (result != null && psiElement instanceof PsiLiteralExpression) {
final String key = result.first;

Expand All @@ -71,12 +71,12 @@ protected Pair<String, String> doAction(Project project, PsiElement psiElement,
}

@Nullable
protected Pair<String, String> invokeAction(@NotNull final Project project,
@NotNull PsiFile file,
@NotNull PsiElement psiElement,
@Nullable final String suggestedKey,
@Nullable String suggestedValue,
@Nullable final List<PropertiesFile> propertiesFiles) {
protected Couple<String> invokeAction(@NotNull final Project project,
@NotNull PsiFile file,
@NotNull PsiElement psiElement,
@Nullable final String suggestedKey,
@Nullable String suggestedValue,
@Nullable final List<PropertiesFile> propertiesFiles) {
final PsiLiteralExpression literalExpression = psiElement instanceof PsiLiteralExpression ? (PsiLiteralExpression)psiElement : null;
final String propertyValue = suggestedValue == null ? "" : suggestedValue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiAnchor;
import com.intellij.psi.PsiElement;
Expand Down Expand Up @@ -128,7 +129,7 @@ protected static I18nizeQuickFixDialog.DialogCustomization createDefaultCustomiz
return new I18nizeQuickFixDialog.DialogCustomization(NAME, false, true, propertiesFiles, suggestedKey == null ? "" : suggestedKey);
}

protected Pair<String, String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) {
protected Couple<String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) {
if (!model.hasValidData()) {
return null;
}
Expand All @@ -138,7 +139,7 @@ protected Pair<String, String> doAction(Project project, PsiElement psiElement,
final Collection<PropertiesFile> selectedPropertiesFiles = model.getAllPropertiesFiles();
createProperty(project, psiElement, selectedPropertiesFiles, key, value);

return new Pair<String, String>(key, value);
return Couple.newOne(key, value);
}

public static void createProperty(@NotNull final Project project,
Expand Down

0 comments on commit 5543b2f

Please sign in to comment.