當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。