• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ExceptionUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.util.ExceptionUtil的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtil类的具体用法?Java ExceptionUtil怎么用?Java ExceptionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExceptionUtil类属于com.intellij.util包,在下文中一共展示了ExceptionUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createCompiler

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@NotNull
@Override
public JavaCompiler createCompiler() throws CannotCreateJavaCompilerException {
  JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  if (compiler != null) {
    return compiler;
  }

  String message = "System Java Compiler was not found in classpath";
  // trying to obtain additional diagnostic for the case when compiler.jar is present, but there were problems with compiler class loading:
  try {
    Class.forName("com.sun.tools.javac.api.JavacTool", false, JavacMain.class.getClassLoader());
  }
  catch (Throwable ex) {
    message = message + ":\n" + ExceptionUtil.getThrowableText(ex);
  }
  throw new CannotCreateJavaCompilerException(message);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavacCompilerTool.java


示例2: run

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public RunResult<T> run() {
  try {
    myActionRunnable.run(this);
  }
  catch (ProcessCanceledException e) {
    throw e; // this exception may occur from time to time and it shouldn't be caught
  }
  catch (Throwable t) {
    myThrowable = t;
    if (!myActionRunnable.isSilentExecution()) {
      ExceptionUtil.rethrowAllAsUnchecked(t);
    }
  }
  finally {
    myActionRunnable = null;
  }

  return this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:RunResult.java


示例3: removeData

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <E, I> void removeData(@NotNull Key<E> key,
                              @NotNull Collection<I> toRemove,
                              @NotNull final Collection<DataNode<E>> toIgnore,
                              @NotNull final ProjectData projectData,
                              @NotNull Project project,
                              @NotNull final IdeModifiableModelsProvider modelsProvider,
                              boolean synchronous) {
  try {
    List<ProjectDataService<?, ?>> services = myServices.getValue().get(key);
    for (ProjectDataService service : services) {
      final long removeStartTime = System.currentTimeMillis();
      service.removeData(new Computable.PredefinedValueComputable<Collection>(toRemove), toIgnore, projectData, project, modelsProvider);
      final long removeTimeInMs = System.currentTimeMillis() - removeStartTime;
      LOG.debug(String.format("Service %s removed data in %d ms", service.getClass().getSimpleName(), removeTimeInMs));
    }

    commit(modelsProvider, project, synchronous, "Removed data");
  }
  catch (Throwable t) {
    dispose(modelsProvider, project, synchronous);
    ExceptionUtil.rethrowAllAsUnchecked(t);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ProjectDataManager.java


示例4: setFactory

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public static void setFactory(Class<? extends Factory> factory) {
  if (isInitialized()) {
    if (factory.isInstance(ourFactory)) {
      return;
    }

    //noinspection UseOfSystemOutOrSystemErr
    System.out.println("Changing log factory\n" + ExceptionUtil.getThrowableText(new Throwable()));
  }

  try {
    Constructor<? extends Factory> constructor = factory.getDeclaredConstructor();
    constructor.setAccessible(true);
    ourFactory = constructor.newInstance();
  }
  catch (Exception e) {
    //noinspection CallToPrintStackTrace
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:Logger.java


示例5: executeQuery

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
private static void executeQuery(@NotNull Project project,
                                 @NotNull VirtualFile file,
                                 @NotNull Editor editor,
                                 @NotNull IdeScriptEngine engine) {
  String command = getCommand(editor);
  String profile = getProfile(file);
  RunContentDescriptor descriptor = getConsoleView(project, file);
  ConsoleViewImpl consoleView = (ConsoleViewImpl)descriptor.getExecutionConsole();

  prepareEngine(project, engine, descriptor);
  try {
    //myHistoryController.getModel().addToHistory(command);
    consoleView.print("> " + command, ConsoleViewContentType.USER_INPUT);
    consoleView.print("\n", ConsoleViewContentType.USER_INPUT);
    Object o = engine.eval(profile == null ? command : profile + "\n" + command);
    consoleView.print("=> " + o, ConsoleViewContentType.NORMAL_OUTPUT);
    consoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
  }
  catch (Throwable e) {
    //noinspection ThrowableResultOfMethodCallIgnored
    Throwable ex = ExceptionUtil.getRootCause(e);
    consoleView.print(ex.getClass().getSimpleName() + ": " + ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT);
    consoleView.print("\n", ConsoleViewContentType.ERROR_OUTPUT);
  }
  selectContent(descriptor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:RunIdeConsoleAction.java


示例6: getIndexingStampInfo

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public static String getIndexingStampInfo(VirtualFile file) {
  try {
    DataInputStream stream = INDEXED_STAMP.readAttribute(file);
    if (stream == null) {
      return "no data";
    }

    long stamp = DataInputOutputUtil.readTIME(stream);
    long size = DataInputOutputUtil.readLONG(stream);
    stream.close();
    return "indexed at " + stamp + " with size " + size;
  }
  catch (IOException e) {
    return ExceptionUtil.getThrowableText(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StubUpdatingIndex.java


示例7: testCustomizeModule

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public void testCustomizeModule() {
  File rootDir = androidProject.getRootDir();
  IdeaAndroidProject ideaAndroidProject = new IdeaAndroidProject(GradleConstants.SYSTEM_ID, myModule.getName(), rootDir, androidProject,
                                                                 "debug", AndroidProject.ARTIFACT_ANDROID_TEST);
  String compilerOutputPath = "";
  final IdeModifiableModelsProviderImpl modelsProvider = new IdeModifiableModelsProviderImpl(myProject);
  try {
    customizer.customizeModule(myProject, myModule, modelsProvider, ideaAndroidProject);
    CompilerModuleExtension compilerSettings = modelsProvider.getModifiableRootModel(myModule).getModuleExtension(CompilerModuleExtension.class);
    compilerOutputPath = compilerSettings.getCompilerOutputUrl();
    modelsProvider.commit();
  }
  catch (Throwable t) {
    modelsProvider.dispose();
    ExceptionUtil.rethrowAllAsUnchecked(t);
  }

  File classesFolder = ideaAndroidProject.getSelectedVariant().getMainArtifact().getClassesFolder();
  String path = FileUtil.toSystemIndependentName(classesFolder.getPath());
  String expected = VfsUtilCore.pathToUrl(ExternalSystemApiUtil.toCanonicalPath(path));
  assertEquals(expected, compilerOutputPath);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CompilerOutputModuleCustomizerTest.java


示例8: testCustomizeModule

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public void testCustomizeModule() {
  File rootDir = myAndroidProject.getRootDir();
  VariantStub selectedVariant = myAndroidProject.getFirstVariant();
  assertNotNull(selectedVariant);
  String selectedVariantName = selectedVariant.getName();
  IdeaAndroidProject project = new IdeaAndroidProject(GradleConstants.SYSTEM_ID, myAndroidProject.getName(), rootDir, myAndroidProject,
                                                      selectedVariantName, AndroidProject.ARTIFACT_ANDROID_TEST);
  final IdeModifiableModelsProviderImpl modelsProvider = new IdeModifiableModelsProviderImpl(myProject);
  try {
    myCustomizer.customizeModule(myProject, myModule, modelsProvider, project);
    modelsProvider.commit();
  }
  catch (Throwable t) {
    modelsProvider.dispose();
    ExceptionUtil.rethrowAllAsUnchecked(t);
  }

  // Verify that AndroidFacet was added and configured.
  AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  assertSame(project, facet.getIdeaAndroidProject());

  JpsAndroidModuleProperties facetState = facet.getProperties();
  assertFalse(facetState.ALLOW_USER_CONFIGURATION);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidFacetModuleCustomizerTest.java


示例9: testAppendableHistory

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@Test
public void testAppendableHistory() throws Exception {
  final List<GitFileRevision> revisions = new ArrayList<GitFileRevision>(3);
  Consumer<GitFileRevision> consumer = new Consumer<GitFileRevision>() {
    @Override
    public void consume(GitFileRevision gitFileRevision) {
      revisions.add(gitFileRevision);
    }
  };
  Consumer<VcsException> exceptionConsumer = new Consumer<VcsException>() {
    @Override
    public void consume(VcsException exception) {
      fail("No exception expected " + ExceptionUtil.getThrowableText(exception));
    }
  };
  GitHistoryUtils.history(myProject, toFilePath(bfile), null, consumer, exceptionConsumer);
  assertHistory(revisions);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GitHistoryUtilsTest.java


示例10: invokeDslErrorPopup

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@Override
public void invokeDslErrorPopup(Throwable e, final Project project, @NotNull VirtualFile vfile) {
  if (!GroovyDslFileIndex.isActivated(vfile)) {
    return;
  }

  final String exceptionText = ExceptionUtil.getThrowableText(e);
  LOG.info(exceptionText);
  GroovyDslFileIndex.disableFile(vfile, DslActivationStatus.Status.ERROR, exceptionText);


  if (!ApplicationManagerEx.getApplicationEx().isInternal() && !ProjectRootManager.getInstance(project).getFileIndex().isInContent(vfile)) {
    return;
  }

  String content = "<p>" + e.getMessage() + "</p><p><a href=\"\">Click here to investigate.</a></p>";
  NOTIFICATION_GROUP.createNotification("DSL script execution error", content, NotificationType.ERROR,
                                        new NotificationListener() {
                                          @Override
                                          public void hyperlinkUpdate(@NotNull Notification notification,
                                                                      @NotNull HyperlinkEvent event) {
                                            InvestigateFix.analyzeStackTrace(project, exceptionText);
                                            notification.expire();
                                          }
                                        }).notify(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DslErrorReporterImpl.java


示例11: showError

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public final void showError(@NotNull String message, @NotNull Throwable e) {
  if (isProjectClosed()) {
    return;
  }

  while (e instanceof InvocationTargetException) {
    if (e.getCause() == null) {
      break;
    }
    e = e.getCause();
  }

  ErrorInfo info = new ErrorInfo();
  info.myMessage = info.myDisplayMessage = message;
  info.myThrowable = e;
  configureError(info);

  if (info.myShowMessage) {
    showErrorPage(info);
  }
  if (info.myShowLog) {
    LOG.error(LogMessageEx.createEvent(info.myDisplayMessage,
                                       info.myMessage + "\n" + ExceptionUtil.getThrowableText(info.myThrowable),
                                       getErrorAttachments(info)));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DesignerEditorPanel.java


示例12: getIndexingStampInfo

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public static String getIndexingStampInfo(VirtualFile file) {
  try {
    DataInputStream stream = INDEXED_STAMP.readAttribute(file);
    if (stream == null) {
      return "no data";
    }

    long stamp = stream.readLong();
    long size = stream.readLong();
    stream.close();
    return "indexed at " + stamp + " with size " + size;
  }
  catch (IOException e) {
    return ExceptionUtil.getThrowableText(e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:StubUpdatingIndex.java


示例13: invokeDslErrorPopup

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
static void invokeDslErrorPopup(Throwable e, final Project project, @NotNull VirtualFile vfile) {
  if (!isActivated(vfile)) {
    return;
  }

  final String exceptionText = ExceptionUtil.getThrowableText(e);
  LOG.info(exceptionText);
  disableFile(vfile, exceptionText);


  if (!ApplicationManagerEx.getApplicationEx().isInternal() && !ProjectRootManager.getInstance(project).getFileIndex().isInContent(vfile)) {
    return;
  }

  String content = "<p>" + e.getMessage() + "</p><p><a href=\"\">Click here to investigate.</a></p>";
  NOTIFICATION_GROUP.createNotification("DSL script execution error", content, NotificationType.ERROR,
                                        new NotificationListener() {
                                          @Override
                                          public void hyperlinkUpdate(@NotNull Notification notification,
                                                                      @NotNull HyperlinkEvent event) {
                                            GroovyDslAnnotator.analyzeStackTrace(project, exceptionText);
                                            notification.expire();
                                          }
                                        }).notify(project);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:GroovyDslFileIndex.java


示例14: showError

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public final void showError(@NotNull String message, @NotNull Throwable e) {
  if (isProjectClosed()) {
    return;
  }

  while (e instanceof InvocationTargetException) {
    if (e.getCause() == null) {
      break;
    }
    e = e.getCause();
  }

  ErrorInfo info = new ErrorInfo();
  info.myMessage = info.myDisplayMessage = message;
  info.myThrowable = e;
  configureError(info);

  if (info.myShowMessage) {
    showErrorPage(info);
  }
  if (info.myShowLog) {
    LOG.error(LogMessageEx.createEvent(info.myDisplayMessage,
                                       info.myMessage + "\n" + ExceptionUtil.getThrowableText(info.myThrowable),
                                       AttachmentFactory.createAttachment(myFile)));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:DesignerEditorPanel.java


示例15: setFactory

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public static void setFactory(@NotNull Class<? extends Factory> factory) {
  if (isInitialized()) {
    if (factory.isInstance(ourFactory)) {
      return;
    }

    //noinspection UseOfSystemOutOrSystemErr
    System.out.println("Changing log factory\n" + ExceptionUtil.getThrowableText(new Throwable()));
  }

  try {
    Constructor<? extends Factory> constructor = factory.getDeclaredConstructor();
    constructor.setAccessible(true);
    ourFactory = constructor.newInstance();
  }
  catch (Exception e) {
    //noinspection CallToPrintStackTrace
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
开发者ID:JetBrains,项目名称:jediterm,代码行数:22,代码来源:Logger.java


示例16: preprocessFile

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public FutureTask<Boolean> preprocessFile(@Nonnull PsiFile file, boolean processChangedTextOnly) throws IncorrectOperationException {
  final FutureTask<Boolean> previousTask = getPreviousProcessorTask(file, processChangedTextOnly);
  final FutureTask<Boolean> currentTask = prepareTask(file, processChangedTextOnly);

  return new FutureTask<>(() -> {
    try {
      if (previousTask != null) {
        previousTask.run();
        if (!previousTask.get() || previousTask.isCancelled()) return false;
      }

      ApplicationManager.getApplication().runWriteAction(() -> currentTask.run());

      return currentTask.get() && !currentTask.isCancelled();
    }
    catch (ExecutionException e) {
      ExceptionUtil.rethrowUnchecked(e.getCause());
      throw e;
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:AbstractLayoutCodeProcessor.java


示例17: testSkipBridgeMethods

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public void testSkipBridgeMethods() throws Exception {
  final Class<?> testClass = prepareTest();
  try {
    testClass.getMethod("main").invoke(null);
    fail();
  }
  catch (InvocationTargetException e) {
    //noinspection ThrowableResultOfMethodCallIgnored
    assertInstanceOf(e.getCause(), IllegalArgumentException.class);
    String trace = ExceptionUtil.getThrowableText(e.getCause());
    assertEquals("Exception should happen in real, non-bridge method: " + trace,
                 2, StringUtil.getOccurrenceCount(trace, "B.getObject(SkipBridgeMethods"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:NotNullVerifyingInstrumenterTest.java


示例18: getMessage

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@Override
public String getMessage() {
  String msg = "Please change caller according to " + IndexNotReadyException.class.getName() + " documentation";
  if (myStartTrace != null) {
    msg += "\nIndexing started at: " + ExceptionUtil.getThrowableText(myStartTrace) + "\n-----------------------------\n";
  }
  return msg;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IndexNotReadyException.java


示例19: throwException

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
@NotNull
public RunResult<T> throwException() throws RuntimeException, Error {
  if (myThrowable != null) {
    ExceptionUtil.rethrowAllAsUnchecked(myThrowable);
  }

  return this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:RunResult.java


示例20: PsiInvalidElementAccessException

import com.intellij.util.ExceptionUtil; //导入依赖的package包/类
public PsiInvalidElementAccessException(@Nullable PsiElement element, @Nullable String message, @Nullable Throwable cause) {
  super(null, cause);
  myElementReference = new SoftReference<PsiElement>(element);

  if (element == null) {
    myMessage = message;
    myDiagnostic = Attachment.EMPTY_ARRAY;
  }
  else if (element == PsiUtilCore.NULL_PSI_ELEMENT) {
    myMessage = "NULL_PSI_ELEMENT ;" + message;
    myDiagnostic = Attachment.EMPTY_ARRAY;
  }
  else {
    boolean recursiveInvocation = Boolean.TRUE.equals(element.getUserData(REPORTING_EXCEPTION));
    element.putUserData(REPORTING_EXCEPTION, Boolean.TRUE);

    try {
      Object trace = recursiveInvocation ? null : findInvalidationTrace(element.getNode());
      myMessage = getMessageWithReason(element, message, recursiveInvocation, trace);
      if (trace == null) {
        myDiagnostic = Attachment.EMPTY_ARRAY;
      }
      else {
        String diagnostic = trace instanceof Throwable ? ExceptionUtil.getThrowableText((Throwable)trace) : trace.toString();
        myDiagnostic = new Attachment[]{new Attachment("diagnostic.txt", diagnostic)};
      }
    }
    finally {
      element.putUserData(REPORTING_EXCEPTION, null);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PsiInvalidElementAccessException.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Messages类代码示例发布时间:2022-05-22
下一篇:
Java PlainSocketFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap