当前位置: 首页>>代码示例>>Java>>正文


Java OpenFileDescriptor.getFile方法代码示例

本文整理汇总了Java中com.intellij.openapi.fileEditor.OpenFileDescriptor.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java OpenFileDescriptor.getFile方法的具体用法?Java OpenFileDescriptor.getFile怎么用?Java OpenFileDescriptor.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.fileEditor.OpenFileDescriptor的用法示例。


在下文中一共展示了OpenFileDescriptor.getFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStackTraceParseerAcceptsJavaStacktrace

import com.intellij.openapi.fileEditor.OpenFileDescriptor; //导入方法依赖的package包/类
public void testStackTraceParseerAcceptsJavaStacktrace() throws Exception {
  myFixture.addClass("abstract class ATest extends junit.framework.TestCase {" +
                     "  public void testMe() {\n" +
                     "    int i = 0;\n" +
                     "    int j = 0;\n" +
                     "    int k = 0;\n" +
                     "    fail();\n" +
                     "  }\n" +
                     "}");
  myFixture.addClass("public class ChildTest extends ATest {}");

  final SMTestProxy testProxy = new SMTestProxy("testMe", false, "java:test://ChildTest.testMe");
  testProxy.setTestFailed("failure", "\tat junit.framework.Assert.fail(Assert.java:57)\n" +
                                     "\tat junit.framework.Assert.failNotEquals(Assert.java:329)\n" +
                                     "\tat junit.framework.Assert.assertEquals(Assert.java:78)\n" +
                                     "\tat junit.framework.Assert.assertEquals(Assert.java:234)\n" +
                                     "\tat junit.framework.Assert.assertEquals(Assert.java:241)\n" +
                                     "\tat junit.framework.TestCase.assertEquals(TestCase.java:409)\n" +
                                     "\tat ATest.testMe(Dummy.java:6)\n", true);
  final Project project = getProject();
  final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project);
  testProxy.setLocator(JavaTestLocator.INSTANCE);

  final Location location = testProxy.getLocation(project, searchScope);
  assertNotNull(location);
  assertInstanceOf(location, MethodLocation.class);

  final JUnitConfiguration configuration =
    new JUnitConfiguration("p", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
  final Navigatable descriptor =
    testProxy.getDescriptor(location, new JUnitConsoleProperties(configuration, DefaultRunExecutor.getRunExecutorInstance()));
  assertInstanceOf(descriptor, OpenFileDescriptor.class);
  final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor)descriptor;
  final VirtualFile file = fileDescriptor.getFile();
  assertNotNull(file);
  assertEquals(5, fileDescriptor.getLine());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JUnitOpenSourceAtExceptionTest.java

示例2: update

import com.intellij.openapi.fileEditor.OpenFileDescriptor; //导入方法依赖的package包/类
@Override
public void update(final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(false);
  presentation.setEnabled(false);
  final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    return;
  }
  final ErrorTreeElement errorTreeElement = getSelectedErrorTreeElement();
  if (errorTreeElement instanceof NavigatableMessageElement) {
    final NavigatableMessageElement messageElement = (NavigatableMessageElement)errorTreeElement;
    final String[] text = messageElement.getText();
    if (text.length > 0) {
      if (text[0].startsWith("[") && text[0].indexOf("]") != -1) {
        final Navigatable navigatable = messageElement.getNavigatable();
        if (navigatable instanceof OpenFileDescriptor) {
          final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor)navigatable;
          final VirtualFile virtualFile = fileDescriptor.getFile();
          final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
          if (module == null) {
            return;
          }
          final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
          if (jdk == null) {
            return;
          }
          final boolean is_1_5 = JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5);
          if (!is_1_5) {
            return;
          }
          final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
          if (psiFile == null) {
            return;
          }
          if (LanguageLevelUtil.getEffectiveLanguageLevel(module).compareTo(LanguageLevel.JDK_1_5) < 0) return;
          final PsiElement context = psiFile.findElementAt(fileDescriptor.getOffset());
          if (context == null) {
            return;
          }
          final String id = text[0].substring(1, text[0].indexOf("]"));
          final SuppressFix suppressInspectionFix = getSuppressAction(id);
          final boolean available = suppressInspectionFix.isAvailable(project, context);
          presentation.setEnabled(available);
          presentation.setVisible(available);
          if (available) {
            presentation.setText(suppressInspectionFix.getText());
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:CompilerErrorTreeView.java

示例3: OpenFileHyperlinkInfo

import com.intellij.openapi.fileEditor.OpenFileDescriptor; //导入方法依赖的package包/类
public OpenFileHyperlinkInfo(@NotNull OpenFileDescriptor descriptor) {
  this(descriptor.getProject(), descriptor.getFile(), descriptor.getLine(), descriptor.getColumn());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:OpenFileHyperlinkInfo.java


注:本文中的com.intellij.openapi.fileEditor.OpenFileDescriptor.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。