提交 a5024387 编写于 作者: D Dmitry Jemerov

all the little dances required to have Find Usages working

上级 b5f0c2e3
......@@ -29,6 +29,7 @@
<lang.psiStructureViewFactory language="jet" implementationClass="org.jetbrains.jet.plugin.structureView.JetStructureViewFactory"/>
<lang.foldingBuilder language="jet" implementationClass="org.jetbrains.jet.plugin.JetFoldingBuilder"/>
<lang.formatter language="jet" implementationClass="org.jetbrains.jet.plugin.formatter.JetFormattingModelBuilder"/>
<lang.findUsagesProvider language="jet" implementationClass="org.jetbrains.jet.plugin.findUsages.JetFindUsagesProvider"/>
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.SoftKeywordsAnnotator"/>
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.LabelsAnnotator"/>
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.JetPsiChecker"/>
......@@ -38,5 +39,6 @@
<codeInsight.lineMarkerProvider language="jet" implementationClass="org.jetbrains.jet.plugin.annotations.JetLineMarkerProvider"/>
<iconProvider implementation="org.jetbrains.jet.plugin.JetIconProvider"/>
<fileTypeIndentOptionsProvider implementation="org.jetbrains.jet.plugin.formatter.JetIndentOptionsProvider"/>
<elementDescriptionProvider implementation="org.jetbrains.jet.plugin.findUsages.JetElementDescriptionProvider"/>
</extensions>
</idea-plugin>
package org.jetbrains.jet.plugin.findUsages;
import com.intellij.psi.ElementDescriptionLocation;
import com.intellij.psi.ElementDescriptionProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.usageView.UsageViewLongNameLocation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetElement;
/**
* @author yole
*/
public class JetElementDescriptionProvider implements ElementDescriptionProvider {
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
if (location instanceof UsageViewLongNameLocation) {
if (element instanceof PsiNamedElement && element instanceof JetElement) {
return ((PsiNamedElement)element).getName();
}
}
return null;
}
}
package org.jetbrains.jet.plugin.findUsages;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.*;
/**
* @author yole
*/
public class JetFindUsagesProvider implements FindUsagesProvider {
@Override
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return psiElement instanceof JetNamedDeclaration;
}
@Override
public WordsScanner getWordsScanner() {
return new JetWordsScanner();
}
@Override
public String getHelpId(@NotNull PsiElement psiElement) {
return null;
}
@NotNull
@Override
public String getType(@NotNull PsiElement psiElement) {
if (psiElement instanceof JetFunction) {
return "function";
}
if (psiElement instanceof JetClass) {
return "class";
}
if (psiElement instanceof JetParameter) {
return "parameter";
}
if (psiElement instanceof JetProperty) {
return "property";
}
return "";
}
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement psiElement) {
if (psiElement instanceof PsiNamedElement) {
final String name = ((PsiNamedElement)psiElement).getName();
return name == null ? "<unnamed>" : name;
}
return "";
}
@NotNull
@Override
public String getNodeText(@NotNull PsiElement psiElement, boolean useFullName) {
return getDescriptiveName(psiElement);
}
}
package org.jetbrains.jet.plugin.findUsages;
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.jet.lexer.JetLexer;
import org.jetbrains.jet.lexer.JetTokens;
/**
* @author yole
*/
public class JetWordsScanner extends DefaultWordsScanner {
public JetWordsScanner() {
super(new JetLexer(),
TokenSet.create(JetTokens.IDENTIFIER),
JetTokens.COMMENTS,
JetTokens.STRINGS);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册