mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
mxml & xslt refactorings
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.lang.refactoring;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ public abstract class RefactoringSupportProvider {
|
||||
* @param context refactoring context
|
||||
* @return true if refactoring support is available in given context
|
||||
*/
|
||||
public boolean isAvailable(PsiElement context) { return true; }
|
||||
public boolean isAvailable(@NotNull PsiElement context) { return true; }
|
||||
|
||||
/**
|
||||
* Checks if the Safe Delete refactoring can be applied to the specified element
|
||||
|
||||
+14
-2
@@ -22,10 +22,13 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.extensions.ExtensionPointListener;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
@@ -48,8 +51,17 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio
|
||||
protected final RefactoringActionHandler getHandler(DataContext dataContext) {
|
||||
final Language language = LangDataKeys.LANGUAGE.getData(dataContext);
|
||||
if (language != null) {
|
||||
RefactoringSupportProvider provider = LanguageRefactoringSupport.INSTANCE.forLanguage(language);
|
||||
return provider == null ? null : getRefactoringHandler(provider);
|
||||
List<RefactoringSupportProvider> providers = LanguageRefactoringSupport.INSTANCE.allForLanguage(language);
|
||||
if (providers.isEmpty()) return null;
|
||||
if (providers.size() == 1) return getRefactoringHandler(providers.get(0));
|
||||
PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
if (element != null) {
|
||||
for (RefactoringSupportProvider provider : providers) {
|
||||
if (provider.isAvailable(element)) {
|
||||
return getRefactoringHandler(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+8
@@ -16,14 +16,22 @@
|
||||
package org.intellij.lang.xpath.xslt.refactoring;
|
||||
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.intellij.lang.xpath.xslt.refactoring.introduceParameter.XsltIntroduceParameterAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class XsltRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull PsiElement context) {
|
||||
return XsltSupport.isXsltFile(context.getContainingFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringActionHandler getIntroduceParameterHandler() {
|
||||
return new XsltIntroduceParameterAction();
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
|
||||
<inspectionToolProvider implementation="org.intellij.lang.xpath.xslt.impl.XsltStuffProvider" />
|
||||
<usageGroupingRuleProvider implementation="org.intellij.lang.xpath.xslt.impl.XsltStuffProvider" />
|
||||
<lang.refactoringSupport language="XML" implementationClass="org.intellij.lang.xpath.xslt.refactoring.XsltRefactoringSupportProvider" />
|
||||
|
||||
<intentionAction>
|
||||
<className>org.intellij.lang.xpath.xslt.intentions.AddOptionalArgumentsIntention</className>
|
||||
|
||||
Reference in New Issue
Block a user