/* * Copyright (c) Joachim Ansorg, [email protected] * * 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.ansorgit.plugins.bash.refactoring; import com.ansorgit.plugins.bash.lang.psi.api.BashFileReference; import com.ansorgit.plugins.bash.lang.psi.api.function.BashFunctionDef; import com.ansorgit.plugins.bash.lang.psi.api.heredoc.BashHereDocMarker; import com.ansorgit.plugins.bash.lang.psi.api.vars.BashVar; import com.ansorgit.plugins.bash.lang.psi.api.vars.BashVarDef; import com.ansorgit.plugins.bash.lang.psi.util.BashPsiUtils; import com.intellij.lang.refactoring.RefactoringSupportProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; /** * Definition of the refactoring support available in this plugin. * <br> * @author jansorg */ public class BashRefactoringSupport extends RefactoringSupportProvider { @Override public boolean isInplaceRenameAvailable(@NotNull PsiElement element, PsiElement context) { PsiFile fileContext = BashPsiUtils.findFileContext(element); if (context == null || fileContext == null || !fileContext.isEquivalentTo(BashPsiUtils.findFileContext(context))) { return false; } return (element instanceof BashVarDef) || (element instanceof BashFunctionDef) || (element instanceof BashVar) || (element instanceof BashHereDocMarker) || (element instanceof BashFileReference); } }