diff options
Diffstat (limited to 'plugins/ui-designer/src/com/intellij')
18 files changed, 141 insertions, 116 deletions
diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java index a5cd762fcf15..0377b72ea043 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java @@ -31,6 +31,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiNameHelper; import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; @@ -104,7 +105,7 @@ public abstract class AbstractCreateFormAction extends CreateElementActionBase i @Override public boolean checkInput(String inputString) { - return inputString.length() > 0 && JavaPsiFacade.getInstance(myProject).getNameHelper().isQualifiedName(inputString); + return inputString.length() > 0 && PsiNameHelper.getInstance(myProject).isQualifiedName(inputString); } } }
\ No newline at end of file diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java index d698a076b891..a9996ba276d0 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java @@ -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. @@ -21,7 +21,6 @@ import com.intellij.codeInsight.generation.PsiGenerationInfo; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; @@ -146,7 +145,7 @@ public class GenerateMainAction extends AnAction { PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); if (psiClass == null) return false; if (PsiMethodUtil.findMainMethod(psiClass) != null) return false; - if (FormClassIndex.findFormsBoundToClass(psiClass).isEmpty()) return false; + if (FormClassIndex.findFormsBoundToClass(project, psiClass).isEmpty()) return false; return true; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java index 48816354893d..60f12b2489b6 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java @@ -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. @@ -124,7 +124,7 @@ public class BoundIconRenderer extends GutterIconRenderer { aClass = (PsiClass) myElement; } if (aClass != null && aClass.getQualifiedName() != null) { - formFiles = FormClassIndex.findFormsBoundToClass(aClass); + formFiles = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); } return formFiles; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java index 0733ad85c781..05c1bcb1b912 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -47,7 +47,7 @@ public class FormClassAnnotator implements Annotator { } else if (psiElement instanceof PsiClass) { PsiClass aClass = (PsiClass) psiElement; - final List<PsiFile> formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass); + final List<PsiFile> formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); if (formsBoundToClass.size() > 0) { Annotation boundClassAnnotation = holder.createInfoAnnotation(aClass.getNameIdentifier(), null); boundClassAnnotation.setGutterIconRenderer(new BoundIconRenderer(aClass)); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java index 0bf86d73618b..000b63716ef4 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java @@ -127,15 +127,15 @@ public class FormClassIndex extends ScalarIndexExtension<String> { }); } - public static List<PsiFile> findFormsBoundToClass(@NotNull PsiClass psiClass) { + public static List<PsiFile> findFormsBoundToClass(Project project, @NotNull PsiClass psiClass) { String qName = FormReferencesSearcher.getQualifiedName(psiClass); if (qName == null) return Collections.emptyList(); - return findFormsBoundToClass(psiClass.getProject(), qName); + return findFormsBoundToClass(project, qName); } - public static List<PsiFile> findFormsBoundToClass(PsiClass psiClass, GlobalSearchScope scope) { + public static List<PsiFile> findFormsBoundToClass(Project project, PsiClass psiClass, GlobalSearchScope scope) { String qName = FormReferencesSearcher.getQualifiedName(psiClass); if (qName == null) return Collections.emptyList(); - return findFormsBoundToClass(psiClass.getProject(), qName, scope); + return findFormsBoundToClass(project, qName, scope); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java index c0ef7a143a41..173ae3a3a7c1 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java @@ -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. @@ -83,7 +83,7 @@ public class FormReferenceProvider extends PsiReferenceProvider { public static PsiReference getFormReference(PsiField field) { final PsiClass containingClass = field.getContainingClass(); if (containingClass != null && containingClass.getQualifiedName() != null) { - final List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(containingClass); + final List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(containingClass.getProject(), containingClass); for (PsiFile formFile : forms) { final PsiReference[] refs = formFile.getReferences(); for (final PsiReference ref : refs) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java index 179f47d57a47..d40be21e1786 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java @@ -1,3 +1,18 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.uiDesigner.binding; import com.intellij.lang.properties.IProperty; @@ -15,7 +30,6 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.NullableComputable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; -import com.intellij.psi.impl.PsiManagerImpl; import com.intellij.psi.impl.cache.CacheManager; import com.intellij.psi.impl.search.PsiSearchHelperImpl; import com.intellij.psi.search.*; @@ -27,16 +41,19 @@ import com.intellij.util.QueryExecutor; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; import java.util.List; /** * @author max */ public class FormReferencesSearcher implements QueryExecutor<PsiReference, ReferencesSearch.SearchParameters> { + @Override public boolean execute(@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) { if (!scopeCanContainForms(p.getScope())) return true; final PsiElement refElement = p.getElementToSearch(); final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { + @Override public PsiFile compute() { if (!refElement.isValid()) return null; return refElement.getContainingFile(); @@ -45,31 +62,38 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer if (psiFile == null) return true; final VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null) return true; - Module module = ProjectRootManager.getInstance(refElement.getProject()).getFileIndex().getModuleForFile(virtualFile); + Project project = ApplicationManager.getApplication().runReadAction(new Computable<Project>() { + @Override + public Project compute() { + return psiFile.getProject(); + } + }); + Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile); if (module == null) return true; final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesScope(module); final LocalSearchScope filterScope = p.getScope() instanceof LocalSearchScope ? (LocalSearchScope) p.getScope() : null; + PsiManager psiManager = PsiManager.getInstance(project); if (refElement instanceof PsiPackage) { //no need to do anything //if (!UIFormUtil.processReferencesInUIForms(consumer, (PsiPackage)refElement, scope)) return false; } else if (refElement instanceof PsiClass) { - if (!processReferencesInUIForms(consumer, (PsiClass)refElement, scope, filterScope)) return false; + if (!processReferencesInUIForms(consumer, psiManager,(PsiClass)refElement, scope, filterScope)) return false; } else if (refElement instanceof PsiEnumConstant) { - if (!processReferencesInUIForms(consumer, (PsiEnumConstant)refElement, scope, filterScope)) return false; + if (!processReferencesInUIForms(consumer, psiManager, (PsiEnumConstant)refElement, scope, filterScope)) return false; } else if (refElement instanceof PsiField) { - if (!processReferencesInUIForms(consumer, (PsiField)refElement, scope, filterScope)) return false; + if (!processReferencesInUIForms(consumer, psiManager, (PsiField)refElement, scope, filterScope)) return false; } else if (refElement instanceof IProperty) { - if (!processReferencesInUIForms(consumer, (Property)refElement, scope, filterScope)) return false; + if (!processReferencesInUIForms(consumer, psiManager, (Property)refElement, scope, filterScope)) return false; } else if (refElement instanceof PropertiesFile) { - if (!processReferencesInUIForms(consumer, (PropertiesFile)refElement, scope, filterScope)) return false; + if (!processReferencesInUIForms(consumer, psiManager, (PropertiesFile)refElement, scope, filterScope)) return false; } return true; @@ -79,31 +103,37 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer if (!(scope instanceof LocalSearchScope)) return true; LocalSearchScope localSearchScope = (LocalSearchScope) scope; final PsiElement[] elements = localSearchScope.getScope(); - for (PsiElement element : elements) { + for (final PsiElement element : elements) { if (element instanceof PsiDirectory) return true; - PsiFile file; - if (element instanceof PsiFile) { - file = (PsiFile) element; - } - else { - if (!element.isValid()) continue; - file = element.getContainingFile(); - } - if (file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM) return true; + boolean isForm = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() { + @Override + public Boolean compute() { + PsiFile file; + if (element instanceof PsiFile) { + file = (PsiFile)element; + } + else { + if (!element.isValid()) return false; + file = element.getContainingFile(); + } + return file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM; + } + }); + if (isForm) return true; } return false; } private static boolean processReferencesInUIForms(Processor<PsiReference> processor, - final PsiClass aClass, - GlobalSearchScope scope, final LocalSearchScope filterScope) { - PsiManagerImpl manager = (PsiManagerImpl)aClass.getManager(); + PsiManager psiManager, final PsiClass aClass, + GlobalSearchScope scope, final LocalSearchScope filterScope) { String className = getQualifiedName(aClass); - return className == null || processReferencesInUIFormsInner(className, aClass, processor, scope, manager, filterScope); + return className == null || processReferencesInUIFormsInner(className, aClass, processor, scope, psiManager, filterScope); } public static String getQualifiedName(final PsiClass aClass) { return ApplicationManager.getApplication().runReadAction(new Computable<String>() { + @Override public String compute() { if (!aClass.isValid()) return null; return aClass.getQualifiedName(); @@ -112,83 +142,56 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer } private static boolean processReferencesInUIForms(Processor<PsiReference> processor, - final PsiEnumConstant enumConstant, + PsiManager psiManager, final PsiEnumConstant enumConstant, GlobalSearchScope scope, final LocalSearchScope filterScope) { - PsiManagerImpl manager = (PsiManagerImpl)enumConstant.getManager(); String className = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { return enumConstant.getName(); } }); - return className == null || processReferencesInUIFormsInner(className, enumConstant, processor, scope, manager, filterScope); - + return className == null || processReferencesInUIFormsInner(className, enumConstant, processor, scope, psiManager, filterScope); } private static boolean processReferencesInUIFormsInner(String name, PsiElement element, Processor<PsiReference> processor, GlobalSearchScope scope1, - PsiManagerImpl manager, + PsiManager manager, final LocalSearchScope filterScope) { GlobalSearchScope scope = GlobalSearchScope.projectScope(manager.getProject()).intersectWith(scope1); - manager.startBatchFilesProcessingMode(); - - try { - List<PsiFile> files = FormClassIndex.findFormsBoundToClass(manager.getProject(), name, scope); - - for (PsiFile file : files) { - ProgressManager.checkCanceled(); + List<PsiFile> files = FormClassIndex.findFormsBoundToClass(manager.getProject(), name, scope); - if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue; - if (!processReferences(processor, file, name, element, filterScope)) return false; - } - } - finally { - manager.finishBatchFilesProcessingMode(); - } - - return true; + return processReferencesInFiles(files, manager, name, element, filterScope, processor); } private static boolean processReferencesInUIForms(Processor<PsiReference> processor, - PsiField field, - GlobalSearchScope scope1, - LocalSearchScope filterScope) { - GlobalSearchScope scope = GlobalSearchScope.projectScope(field.getProject()).intersectWith(scope1); - PsiManagerImpl manager = (PsiManagerImpl)field.getManager(); + PsiManager psiManager, + PsiField field, + GlobalSearchScope scope1, + LocalSearchScope filterScope) { + GlobalSearchScope scope = GlobalSearchScope.projectScope(psiManager.getProject()).intersectWith(scope1); + final AccessToken token = ReadAction.start(); PsiClass containingClass = field.getContainingClass(); if (containingClass == null) return true; String fieldName; - final AccessToken token = ReadAction.start(); try { fieldName = field.getName(); } finally { token.finish(); } - manager.startBatchFilesProcessingMode(); - - try { - final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(containingClass, scope); - - for (PsiFile file : files) { - ProgressManager.checkCanceled(); - - if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue; - if (!processReferences(processor, file, fieldName, field, filterScope)) return false; - } - } - finally { - manager.finishBatchFilesProcessingMode(); - } - - return true; + final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(psiManager.getProject(), containingClass, scope); + return processReferencesInFiles(files, psiManager, fieldName, field, filterScope, processor); } - private static boolean processReferences(final Processor<PsiReference> processor, final PsiFile file, String name, final PsiElement element, + private static boolean processReferences(final Processor<PsiReference> processor, + final PsiFile file, + String name, + final PsiElement element, final LocalSearchScope filterScope) { CharSequence chars = ApplicationManager.getApplication().runReadAction(new NullableComputable<CharSequence>() { + @Override public CharSequence compute() { if (filterScope != null) { boolean isInScope = false; @@ -211,6 +214,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer if (index < 0) break; final int finalIndex = index; final Boolean searchDone = ApplicationManager.getApplication().runReadAction(new NullableComputable<Boolean>() { + @Override public Boolean compute() { final PsiReference ref = file.findReferenceAt(finalIndex + offset + 1); if (ref != null && ref.isReferenceTo(element)) { @@ -227,13 +231,13 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer } private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, - final Property property, - final GlobalSearchScope globalSearchScope, - final LocalSearchScope filterScope) { + PsiManager psiManager, + final Property property, + final GlobalSearchScope globalSearchScope, + final LocalSearchScope filterScope) { + final Project project = psiManager.getProject(); - final Project project = property.getProject(); final GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope); - final PsiManagerImpl manager = (PsiManagerImpl)property.getManager(); String name = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { @@ -242,7 +246,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer }); if (name == null) return true; - manager.startBatchFilesProcessingMode(); + psiManager.startBatchFilesProcessingMode(); try { CommonProcessors.CollectProcessor<VirtualFile> collector = new CommonProcessors.CollectProcessor<VirtualFile>() { @@ -268,34 +272,54 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer } } finally { - manager.finishBatchFilesProcessingMode(); + psiManager.finishBatchFilesProcessingMode(); } return true; } - private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, final PropertiesFile propFile, final GlobalSearchScope globalSearchScope, - final LocalSearchScope filterScope) { - final Project project = propFile.getProject(); + private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, + PsiManager psiManager, + final PropertiesFile propFile, + final GlobalSearchScope globalSearchScope, + final LocalSearchScope filterScope) { + final Project project = psiManager.getProject(); GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope); - PsiManagerImpl manager = (PsiManagerImpl)propFile.getContainingFile().getManager(); - final String baseName = propFile.getResourceBundle().getBaseName(); - manager.startBatchFilesProcessingMode(); + final String baseName = ApplicationManager.getApplication().runReadAction(new Computable<String>() { + @Override + public String compute() { + return propFile.getResourceBundle().getBaseName(); + } + }); + PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { + @Override + public PsiFile compute() { + return propFile.getContainingFile(); + } + }); - try { - PsiFile[] files = CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true); + List<PsiFile> files = Arrays.asList(CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true)); + return processReferencesInFiles(files, psiManager, baseName, containingFile, filterScope, processor); + } + private static boolean processReferencesInFiles(List<PsiFile> files, + PsiManager psiManager, String baseName, + PsiElement element, + LocalSearchScope filterScope, + Processor<PsiReference> processor) { + psiManager.startBatchFilesProcessingMode(); + + try { for (PsiFile file : files) { ProgressManager.checkCanceled(); if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue; - if (!processReferences(processor, file, baseName, propFile.getContainingFile(), filterScope)) return false; + if (!processReferences(processor, file, baseName, element, filterScope)) return false; } } finally { - manager.finishBatchFilesProcessingMode(); + psiManager.finishBatchFilesProcessingMode(); } - return true; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java index dbe28385666d..8de344a03f16 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -42,7 +42,7 @@ public class FormRelatedFilesProvider extends GotoRelatedProvider { PsiClass psiClass = PsiTreeUtil.getParentOfType(context, PsiClass.class, false); if (psiClass != null) { while (psiClass != null) { - List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(psiClass); + List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(psiClass.getProject(), psiClass); if (!forms.isEmpty()) { return GotoRelatedItem.createItems(forms, "UI Forms"); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java index cafbb8d2bf73..796aced2a67d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java @@ -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. @@ -39,7 +39,7 @@ public class FormsRenamer extends AutomaticRenamer { public FormsRenamer(PsiClass aClass, String newClassName) { if (aClass.getQualifiedName() != null) { - List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(aClass); + List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); myElements.addAll(forms); suggestAllNames(aClass.getName(), newClassName); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java index 7f719850834e..5ffca466a954 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java @@ -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. @@ -29,7 +29,7 @@ import java.util.List; public class FormsRenamerFactory implements AutomaticRenamerFactory { public boolean isApplicable(final PsiElement element) { if (!(element instanceof PsiClass)) return false; - List<PsiFile> forms = FormClassIndex.findFormsBoundToClass((PsiClass) element); + List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(element.getProject(), (PsiClass)element); return forms.size() > 0; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleFileReference.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleFileReference.java index f2a9bbb8316d..3064746e9cac 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleFileReference.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleFileReference.java @@ -16,8 +16,8 @@ package com.intellij.uiDesigner.binding; import com.intellij.lang.properties.PropertiesFileType; -import com.intellij.lang.properties.PropertiesUtil; import com.intellij.lang.properties.PropertiesUtilBase; +import com.intellij.lang.properties.ResourceBundleManager; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; @@ -61,7 +61,7 @@ public final class ResourceBundleFileReference extends ReferenceInForm { @Override public boolean isReferenceTo(final PsiElement element) { if (!(element instanceof PropertiesFile)) return false; - String baseName = PropertiesUtil.getFullName((PropertiesFile) element); + String baseName = ResourceBundleManager.getInstance(element.getProject()).getFullName((PropertiesFile)element); if (baseName == null) return false; baseName = baseName.replace('.', '/'); final String rangeText = getRangeText(); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleKeyReference.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleKeyReference.java index e6f2bb5930c9..e440400dcbee 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleKeyReference.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ResourceBundleKeyReference.java @@ -16,8 +16,8 @@ package com.intellij.uiDesigner.binding; import com.intellij.lang.properties.IProperty; -import com.intellij.lang.properties.PropertiesUtil; import com.intellij.lang.properties.PropertiesUtilBase; +import com.intellij.lang.properties.ResourceBundleManager; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -74,7 +74,7 @@ public final class ResourceBundleKeyReference extends ReferenceInForm { return false; } IProperty property = (IProperty) element; - String baseName = PropertiesUtil.getFullName(property.getPropertiesFile()); + String baseName = ResourceBundleManager.getInstance(element.getProject()).getFullName(property.getPropertiesFile()); return baseName != null && myBundleName.equals(baseName.replace('.', '/')) && getRangeText().equals(property.getUnescapedKey()); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java index 95be42a02d8b..a3d66a914304 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/palette/ComponentItemDialog.java @@ -325,13 +325,13 @@ public final class ComponentItemDialog extends DialogWrapper { if (myDocument == null) { // why? return false; } - final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(myProject); - if (!javaPsiFacade.getNameHelper().isQualifiedName(myDocument.getText())) { + if (!PsiNameHelper.getInstance(myProject).isQualifiedName(myDocument.getText())) { if (myDocument.getTextLength() > 0) { myErrorLabel.setText(UIDesignerBundle.message("add.component.error.qualified.name.required")); } return false; } + final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(myProject); PsiClass psiClass = javaPsiFacade.findClass(myDocument.getText(), ProjectScope.getAllScope(myProject)); PsiClass componentClass = javaPsiFacade.findClass(JComponent.class.getName(), ProjectScope.getAllScope(myProject)); if (psiClass != null && componentClass != null && !InheritanceUtil.isInheritorOrSelf(psiClass, componentClass, true)) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java index 473593be180e..1b3b00365d8f 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java @@ -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. @@ -34,7 +34,7 @@ public class Form implements Navigatable { public Form(PsiClass classToBind) { myClassToBind = classToBind; - myFormFiles = FormClassIndex.findFormsBoundToClass(classToBind); + myFormFiles = FormClassIndex.findFormsBoundToClass(classToBind.getProject(), classToBind); } public Form(PsiClass classToBind, Collection<PsiFile> formFiles) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java index d4ef25332a60..58306f72167a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java @@ -97,7 +97,7 @@ public final class BindingProperty extends Property<RadComponent, String> { return; } - if (value.length() > 0 && !JavaPsiFacade.getInstance(component.getProject()).getNameHelper().isIdentifier(value)) { + if (value.length() > 0 && !PsiNameHelper.getInstance(component.getProject()).isIdentifier(value)) { throw new Exception("Value '" + value + "' is not a valid identifier"); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IdentifierValidator.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IdentifierValidator.java index 42372bd96104..2a698d3fc6e3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IdentifierValidator.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IdentifierValidator.java @@ -25,6 +25,7 @@ package com.intellij.uiDesigner.propertyInspector.properties; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputValidator; import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiNameHelper; public class IdentifierValidator implements InputValidator { private final Project myProject; @@ -34,7 +35,7 @@ public class IdentifierValidator implements InputValidator { } public boolean checkInput(String inputString) { - return JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(inputString); + return PsiNameHelper.getInstance(myProject).isIdentifier(inputString); } public boolean canClose(String inputString) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BeanStep.java b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BeanStep.java index f273cd32106c..d963bb137aec 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BeanStep.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BeanStep.java @@ -154,7 +154,7 @@ final class BeanStep extends StepAdapter{ throw new CommitStepException(UIDesignerBundle.message("error.please.specify.class.name.of.the.bean.to.be.created")); } final PsiManager psiManager = PsiManager.getInstance(myData.myProject); - if(!JavaPsiFacade.getInstance(psiManager.getProject()).getNameHelper().isIdentifier(shortClassName)){ + if(!PsiNameHelper.getInstance(psiManager.getProject()).isIdentifier(shortClassName)){ throw new CommitStepException(UIDesignerBundle.message("error.X.is.not.a.valid.class.name", shortClassName)); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BindToNewBeanStep.java b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BindToNewBeanStep.java index 0d88412ece9b..00a89febe8b0 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BindToNewBeanStep.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/wizard/BindToNewBeanStep.java @@ -93,7 +93,7 @@ final class BindToNewBeanStep extends StepAdapter{ } // Check that all included fields are bound to valid bean properties - final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myData.myProject).getNameHelper(); + final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myData.myProject); for(int i = 0; i <myData.myBindings.length; i++){ final FormProperty2BeanProperty binding = myData.myBindings[i]; if(binding.myBeanProperty == null){ |