// Copyright 2015 ThoughtWorks, Inc. // This file is part of getgauge/Intellij-plugin. // getgauge/Intellij-plugin is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // getgauge/Intellij-plugin is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with getgauge/Intellij-plugin. If not, see <http://www.gnu.org/licenses/>. package com.thoughtworks.gauge.findUsages; import com.intellij.lang.HelpID; import com.intellij.lang.cacheBuilder.WordsScanner; import com.intellij.lang.findUsages.FindUsagesProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl; import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class SpecStepFindUsagesProvider implements FindUsagesProvider { @Nullable @Override public WordsScanner getWordsScanner() { return new SpecStepWordScanner(); } @Override public boolean canFindUsagesFor(PsiElement psiElement) { return psiElement instanceof SpecStepImpl || psiElement instanceof ConceptStepImpl; } @Nullable @Override public String getHelpId(PsiElement psiElement) { return HelpID.FIND_OTHER_USAGES; } @NotNull @Override public String getType(PsiElement psiElement) { if (psiElement instanceof SpecStepImpl) return "Step"; return ""; } @NotNull @Override public String getDescriptiveName(@NotNull PsiElement psiElement) { return ((PsiNamedElement) psiElement).getName(); } @NotNull @Override public String getNodeText(@NotNull PsiElement psiElement, boolean b) { return getDescriptiveName(psiElement); } }