Java 类com.intellij.lang.ImportOptimizer 实例源码

项目:intellij-ce-playground    文件:JavaFxUnusedImportsInspection.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement psiElement = descriptor.getPsiElement();
  if (psiElement == null) return;
  final PsiFile file = psiElement.getContainingFile();
  if (file == null || !JavaFxFileTypeFactory.isFxml(file)) return;
  if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
  ImportOptimizer optimizer = new JavaFxImportsOptimizer();
  final Runnable runnable = optimizer.processFile(file);
  new WriteCommandAction.Simple(project, getFamilyName(), file) {
    @Override
    protected void run() throws Throwable {
      runnable.run();
    }
  }.execute();
}
项目:tools-idea    文件:JavaFxUnusedImportsInspection.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement psiElement = descriptor.getPsiElement();
  if (psiElement == null) return;
  final PsiFile file = psiElement.getContainingFile();
  if (file == null || !JavaFxFileTypeFactory.isFxml(file)) return;
  if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
  ImportOptimizer optimizer = new JavaFxImportsOptimizer();
  final Runnable runnable = optimizer.processFile(file);
  new WriteCommandAction.Simple(project, getFamilyName(), file) {
    @Override
    protected void run() throws Throwable {
      runnable.run();
    }
  }.execute();
}
项目:intellij-ce-playground    文件:OptimizeImportsProcessor.java   
private void retrieveAndStoreNotificationInfo(@NotNull Runnable runnable) {
  if (runnable instanceof ImportOptimizer.CollectingInfoRunnable) {
    String optimizerMessage = ((ImportOptimizer.CollectingInfoRunnable)runnable).getUserNotificationInfo();
    myOptimizerNotifications.add(optimizerMessage != null ? new NotificationInfo(optimizerMessage) : NOTHING_CHANGED_NOTIFICATION);
  }
  else if (runnable == EmptyRunnable.getInstance()) {
    myOptimizerNotifications.add(NOTHING_CHANGED_NOTIFICATION);
  }
  else {
    myOptimizerNotifications.add(SOMETHING_CHANGED_WITHOUT_MESSAGE_NOTIFICATION);
  }
}
项目:intellij-ce-playground    文件:OptimizeImportsQuickFix.java   
private void optimizeImports(final Project project, final PsiFile file) {
  ImportOptimizer optimizer = new PyImportOptimizer();
  final Runnable runnable = optimizer.processFile(file);
  new WriteCommandAction.Simple(project, getFamilyName(), file) {
    @Override
    protected void run() throws Throwable {
      runnable.run();
    }
  }.execute();
}
项目:epigraph    文件:OptimizeImportsQuickFix.java   
private void optimizeImports(final Project project, final SchemaFile file) {
  ImportOptimizer optimizer = new SchemaImportOptimizer();

  final Runnable runnable = optimizer.processFile(file);
  new WriteCommandAction.Simple(project, getFamilyName(), file) {
    @Override
    protected void run() throws Throwable {
      runnable.run();
    }
  }.execute();
}
项目:intellij-haxe    文件:HaxeUnusedImportInspection.java   
public void invoke(@NotNull final Project project, PsiFile file) {
  ImportOptimizer optimizer = new HaxeImportOptimizer();
  final Runnable runnable = optimizer.processFile(file);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      CommandProcessor.getInstance().executeCommand(project, runnable, getFamilyName(), this);
    }
  });
}
项目:consulo-haxe    文件:HaxeUnusedImportInspection.java   
public void invoke(@NotNull final Project project, PsiFile file)
{
    ImportOptimizer optimizer = new HaxeImportOptimizer();
    final Runnable runnable = optimizer.processFile(file);
    ApplicationManager.getApplication().runWriteAction(new Runnable()
    {
        @Override
        public void run()
        {
            CommandProcessor.getInstance().executeCommand(project, runnable, getFamilyName(), this);
        }
    });
}
项目:consulo-javafx    文件:JavaFxUnusedImportsInspection.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
    final PsiElement psiElement = descriptor.getPsiElement();
    if(psiElement == null)
    {
        return;
    }
    final PsiFile file = psiElement.getContainingFile();
    if(file == null || !JavaFxFileTypeFactory.isFxml(file))
    {
        return;
    }
    if(!FileModificationService.getInstance().prepareFileForWrite(file))
    {
        return;
    }
    ImportOptimizer optimizer = new JavaFxImportsOptimizer();
    final Runnable runnable = optimizer.processFile(file);
    new WriteCommandAction.Simple(project, getFamilyName(), file)
    {
        @Override
        protected void run() throws Throwable
        {
            runnable.run();
        }
    }.execute();
}
项目:consulo    文件:OptimizeImportsProcessor.java   
private void retrieveAndStoreNotificationInfo(@Nonnull Runnable runnable) {
  if (runnable instanceof ImportOptimizer.CollectingInfoRunnable) {
    String optimizerMessage = ((ImportOptimizer.CollectingInfoRunnable)runnable).getUserNotificationInfo();
    myOptimizerNotifications.add(optimizerMessage != null ? new NotificationInfo(optimizerMessage) : NOTHING_CHANGED_NOTIFICATION);
  }
  else if (runnable == EmptyRunnable.getInstance()) {
    myOptimizerNotifications.add(NOTHING_CHANGED_NOTIFICATION);
  }
  else {
    myOptimizerNotifications.add(SOMETHING_CHANGED_WITHOUT_MESSAGE_NOTIFICATION);
  }
}