Inspections - pass onTheFly into ProblemDescriptors & use it to create LAZY refs...
[fedora-idea.git] / plugins / java-i18n / src / com / intellij / codeInspection / i18n / JavaCreatePropertyFix.java
blob5b2476784151bd22aa5308b27f9c6ebc6df645ec
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.codeInspection.i18n;
18 import com.intellij.lang.properties.psi.PropertiesFile;
19 import com.intellij.lang.properties.references.CreatePropertyFix;
20 import com.intellij.lang.properties.references.I18nizeQuickFixDialog;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.openapi.util.Pair;
23 import com.intellij.psi.PsiElement;
24 import com.intellij.psi.PsiFile;
25 import com.intellij.psi.PsiLiteralExpression;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
29 import java.util.List;
31 /**
32 * Created by IntelliJ IDEA.
33 * User: Maxim.Mossienko
34 * Date: 06.02.2009
35 * Time: 21:13:07
36 * To change this template use File | Settings | File Templates.
38 public class JavaCreatePropertyFix extends CreatePropertyFix {
39 public JavaCreatePropertyFix() {}
41 public JavaCreatePropertyFix(PsiElement element, String key, final List<PropertiesFile> propertiesFiles) {
42 super(element, key, propertiesFiles);
45 @Nullable
46 protected static Pair<String, String> invokeAction(@NotNull final Project project,
47 @NotNull PsiFile file,
48 @NotNull PsiElement psiElement,
49 @Nullable final String suggestedKey,
50 @Nullable String suggestedValue,
51 @Nullable final List<PropertiesFile> propertiesFiles) {
52 final PsiLiteralExpression literalExpression = psiElement instanceof PsiLiteralExpression ? (PsiLiteralExpression)psiElement : null;
53 final String propertyValue = suggestedValue == null ? "" : suggestedValue;
55 final I18nizeQuickFixDialog dialog = new JavaI18nizeQuickFixDialog(
56 project,
57 file,
58 literalExpression,
59 propertyValue,
60 createDefaultCustomization(suggestedKey, propertiesFiles),
61 false,
62 false
64 return doAction(project, psiElement, dialog);