本文整理汇总了Java中com.intellij.ide.util.gotoByName.GotoClassModel2类的典型用法代码示例。如果您正苦于以下问题:Java GotoClassModel2类的具体用法?Java GotoClassModel2怎么用?Java GotoClassModel2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GotoClassModel2类属于com.intellij.ide.util.gotoByName包,在下文中一共展示了GotoClassModel2类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPsiElementsFromClassesNames
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
/**
* useful for go to declaration using only the class name
*
* @param classes
* @param project
* @return
*/
@NotNull
public static List<PsiElement> getPsiElementsFromClassesNames(List<String> classes, Project project) {
List<PsiElement> psiElements = new ArrayList<PsiElement>();
if (classes != null && project != null) {
GotoClassModel2 model = new GotoClassModel2(project);
for (String className : classes) {
Object[] elements = model.getElementsByName(className, true, className);
if (elements != null && elements.length > 0) {
for (Object element : elements) {
if (element instanceof PsiElement) {
psiElements.add((PsiElement) element);
}
}
}
}
}
return psiElements;
}
示例2: testGoToMessage
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToMessage() throws Exception {
ProtoPsiFileRoot file = addProto("test.proto", String.join("\n",
"package navigation;",
"message MyProtobufMessage {}"));
ProtoType message = findType(file, "navigation.MyProtobufMessage");
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProto", false);
Assert.assertEquals(1, elements.size());
Assert.assertSame(message, elements.get(0));
}
示例3: testGoToNestedMessage
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToNestedMessage() throws Exception {
ProtoPsiFileRoot file = addProto("test.proto", String.join("\n",
"package navigation;",
"message MyProtobufMessage {",
"enum MyProtobufNestedMessage {}",
"}"));
ProtoType message = findType(file, "navigation.MyProtobufMessage.MyProtobufNestedMessage");
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProtoNes", false);
Assert.assertEquals(1, elements.size());
Assert.assertSame(message, elements.get(0));
}
示例4: testGoToEnum
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToEnum() throws Exception {
ProtoPsiFileRoot file = addProto("test.proto", String.join("\n",
"package navigation;",
"enum MyProtobufEnum {}"));
ProtoType anEnum = findType(file, "navigation.MyProtobufEnum");
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProto", false);
Assert.assertEquals(1, elements.size());
Assert.assertSame(anEnum, elements.get(0));
}
示例5: testGoToNestedEnum
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToNestedEnum() throws Exception {
ProtoPsiFileRoot file = addProto("test.proto", String.join("\n",
"package navigation;",
"message MyProtobufMessage {",
"enum MyProtobufNestedEnum {}",
"}"));
ProtoType anEnum = findType(file, "navigation.MyProtobufMessage.MyProtobufNestedEnum");
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProtoNes", false);
Assert.assertEquals(1, elements.size());
Assert.assertSame(anEnum, elements.get(0));
}
示例6: testGoToService
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToService() throws Exception {
ProtoPsiFileRoot file = addProto("test.proto", String.join("\n",
"package navigation;",
"service MyProtobufService {}"));
ProtoType service = findType(file, "navigation.MyProtobufService");
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProto", false);
Assert.assertEquals(1, elements.size());
Assert.assertSame(service, elements.get(0));
}
示例7: testMultipleElements
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testMultipleElements() throws Exception {
addProto("test.proto", String.join("\n",
"package navigation;",
"message MyProtobufMessage {}",
"enum MyProtobufEnum {}",
"service MyProtobufService {}"
));
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MyProto", false);
Assert.assertEquals(3, elements.size());
}
示例8: testGoToMessage_inCustomIncludePath
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public void testGoToMessage_inCustomIncludePath() throws Exception {
File includePathRoot = tempDir;
ProtobufSettings settings = getProject().getComponent(ProtobufSettings.class);
settings.setIncludePaths(Collections.singletonList(includePathRoot.getAbsolutePath()));
File proto = new File(tempDir.getPath() + "/test.proto");
Writer writer = new BufferedWriter(new FileWriter(proto));
writer.write("message MessageInCustomPath {}");
writer.close();
List<Object> elements = getPopupElements(new GotoClassModel2(getProject()), "MeInCus", false);
Assert.assertEquals(1, elements.size());
}
示例9: DirectoryChooser
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public DirectoryChooser(@NotNull Project project, @NotNull DirectoryChooserView view){
super(project, true);
myView = view;
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
myFilterExisting = propertiesComponent.isTrueValue(FILTER_NON_EXISTING);
myTabbedPaneWrapper = new TabbedPaneWrapper(getDisposable());
myChooseByNamePanel = new ChooseByNamePanel(project, new GotoClassModel2(project){
@NotNull
@Override
public String[] getNames(boolean checkBoxState) {
return super.getNames(false);
}
}, "", false, null) {
@Override
protected void showTextFieldPanel() {
}
@Override
protected void close(boolean isOk) {
super.close(isOk);
if (isOk) {
final List<Object> elements = getChosenElements();
if (elements != null && elements.size() > 0) {
myActionListener.elementChosen(elements.get(0));
}
doOKAction();
}
else {
doCancelAction();
}
}
};
Disposer.register(myDisposable, myChooseByNamePanel);
init();
}
示例10: DirectoryChooser
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public DirectoryChooser(@NotNull Project project, @NotNull DirectoryChooserView view){
super(project, true);
myView = view;
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
myFilterExisting = propertiesComponent.isValueSet(FILTER_NON_EXISTING) && propertiesComponent.isTrueValue(FILTER_NON_EXISTING);
myTabbedPaneWrapper = new TabbedPaneWrapper(getDisposable());
myChooseByNamePanel = new ChooseByNamePanel(project, new GotoClassModel2(project){
@NotNull
@Override
public String[] getNames(boolean checkBoxState) {
return super.getNames(false);
}
}, "", false, null) {
@Override
protected void showTextFieldPanel() {
}
@Override
protected void close(boolean isOk) {
super.close(isOk);
if (isOk) {
final List<Object> elements = getChosenElements();
if (elements != null && elements.size() > 0) {
myActionListener.elementChosen(elements.get(0));
}
doOKAction();
}
else {
doCancelAction();
}
}
};
Disposer.register(myDisposable, myChooseByNamePanel);
init();
}
示例11: searchClasses
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public static ArrayList<String> searchClasses(String regex, Project project) {
GotoClassModel2 model = new GotoClassModel2(project);
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
ArrayList classesNamesFounded = new ArrayList<String>();
String[] models = model.getNames(true);
for (String clazz : models) {
if (p.matcher(clazz).find()) {
classesNamesFounded.add(clazz);
}
}
return classesNamesFounded;
}
示例12: DirectoryChooser
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
public DirectoryChooser(@Nonnull Project project, @Nonnull DirectoryChooserView view){
super(project, true);
myView = view;
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
myFilterExisting = propertiesComponent.isValueSet(FILTER_NON_EXISTING) && propertiesComponent.isTrueValue(FILTER_NON_EXISTING);
myTabbedPaneWrapper = new TabbedPaneWrapper(getDisposable());
myChooseByNamePanel = new ChooseByNamePanel(project, new GotoClassModel2(project){
@Nonnull
@Override
public String[] getNames(boolean checkBoxState) {
return super.getNames(false);
}
}, "", false, null) {
@Override
protected void showTextFieldPanel() {
}
@Override
protected void close(boolean isOk) {
super.close(isOk);
if (isOk) {
final List<Object> elements = getChosenElements();
if (elements != null && elements.size() > 0) {
myActionListener.elementChosen(elements.get(0));
}
doOKAction();
}
else {
doCancelAction();
}
}
};
Disposer.register(myDisposable, myChooseByNamePanel);
init();
}
示例13: createModel
import com.intellij.ide.util.gotoByName.GotoClassModel2; //导入依赖的package包/类
@Override
protected GotoClassModel2 createModel(@NotNull Project project) {
GotoClassModel2 model = super.createModel(project);
model.setFilterItems(Collections.singleton(SchemaLanguage.INSTANCE));
return model;
}