diff options
Diffstat (limited to 'plugins/groovy/src/org/jetbrains/plugins/groovy')
8 files changed, 35 insertions, 25 deletions
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java index c7a2c3ae4625..5ed50b62efef 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateClassDialog.java @@ -99,7 +99,7 @@ public class GroovyCreateClassDialog extends DialogWrapper { myPackageTextField.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { - PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myProject).getNameHelper(); + PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject); String packageName = getPackageName(); getOKAction().setEnabled(nameHelper.isQualifiedName(packageName) || packageName != null && packageName.isEmpty()); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrHighlightHandlerFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrHighlightHandlerFactory.java index 811f8caec379..a25abdf311ef 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrHighlightHandlerFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrHighlightHandlerFactory.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. @@ -15,14 +15,14 @@ */ package org.jetbrains.plugins.groovy.findUsages; -import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerBase; -import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactory; +import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactoryBase; import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Editor; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; @@ -30,13 +30,9 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefini /** * @author Max Medvedev */ -public class GrHighlightHandlerFactory implements HighlightUsagesHandlerFactory { +public class GrHighlightHandlerFactory extends HighlightUsagesHandlerFactoryBase { @Override - public HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file) { - int offset = TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()); - final PsiElement target = file.findElementAt(offset); - if (target == null) return null; - + public HighlightUsagesHandlerBase createHighlightUsagesHandler(@NotNull Editor editor, @NotNull PsiFile file, @NotNull PsiElement target) { ASTNode node = target.getNode(); if (node == null) return null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java index 318db55df11b..befb360e5885 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java @@ -23,6 +23,7 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; @@ -459,17 +460,33 @@ public class ConvertParameterToMapEntryIntention extends Intention { } }; ReferencesSearch.search(namedElem).forEach(consumer); - if (namedElem instanceof GrField && ((GrField)namedElem).isProperty()) { - final GrAccessorMethod[] getters = ((GrField)namedElem).getGetters(); + boolean isProperty = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() { + @Override + public Boolean compute() { + return namedElem instanceof GrField && ((GrField)namedElem).isProperty(); + } + }); + if (isProperty) { + final GrAccessorMethod[] getters = ApplicationManager.getApplication().runReadAction(new Computable<GrAccessorMethod[]>() { + @Override + public GrAccessorMethod[] compute() { + return ((GrField)namedElem).getGetters(); + } + }); for (GrAccessorMethod getter : getters) { MethodReferencesSearch.search(getter).forEach(consumer); } } - for (PsiReference reference : references) { - final PsiElement element = reference.getElement(); - if (element != null) { - occurrences.add(element); - } + for (final PsiReference reference : references) { + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + final PsiElement element = reference.getElement(); + if (element != null) { + occurrences.add(element); + } + } + }); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionUtil.java index 6ba946c6798b..b1856c124e0e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionUtil.java @@ -128,7 +128,7 @@ public class GroovyNameSuggestionUtil { NameValidator validator, boolean forStaticVariable, Project project) { - if (!JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(value)) return; + if (!PsiNameHelper.getInstance(project).isIdentifier(value)) return; if (forStaticVariable) { StringBuilder buffer = new StringBuilder(value.length() + 10); char[] chars = new char[value.length()]; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUtil.java index 8c8b156eace4..097d90024daf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUtil.java @@ -17,13 +17,14 @@ package org.jetbrains.plugins.groovy.refactoring.changeSignature; import com.intellij.openapi.project.Project; import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiNameHelper; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil; public class GrChangeSignatureUtil { @NotNull public static String getNameWithQuotesIfNeeded(@NotNull final String originalName, @NotNull final Project project) { - return JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(originalName) + return PsiNameHelper.getInstance(project).isIdentifier(originalName) ? originalName : GrStringUtil.getLiteralTextByValue(originalName).toString(); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java index 7658a3e2f211..a6f9673fbe62 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java @@ -354,7 +354,7 @@ public class GrIntroduceConstantDialog extends DialogWrapper return; } final String trimmed = targetClassName.trim(); - if (!JavaPsiFacade.getInstance(myContext.getProject()).getNameHelper().isQualifiedName(trimmed)) { + if (!PsiNameHelper.getInstance(myContext.getProject()).isQualifiedName(trimmed)) { setOKActionEnabled(false); return; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java index d3531eac1720..297f3fa7770a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java @@ -155,13 +155,11 @@ public class GrIntroduceConstantProcessor { return GroovyRefactoringBundle.message("class.language.is.not.groovy"); } - final JavaPsiFacade facade = JavaPsiFacade.getInstance(context.getProject()); - if (fieldName == null || fieldName.isEmpty()) { return RefactoringBundle.message("no.field.name.specified"); } - else if (!facade.getNameHelper().isIdentifier(fieldName)) { + else if (!PsiNameHelper.getInstance(context.getProject()).isIdentifier(fieldName)) { return RefactoringMessageUtil.getIncorrectIdentifierMessage(fieldName); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java index 90e4131f1ef9..7673ff1c334b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java @@ -60,8 +60,6 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { ModulesConfigurator.showDialog(module.getProject(), module.getName(), ClasspathEditor.NAME); return false; } - - return true; } |