當前位置: 首頁>>代碼示例>>Java>>正文


Java Result類代碼示例

本文整理匯總了Java中com.intellij.openapi.application.Result的典型用法代碼示例。如果您正苦於以下問題:Java Result類的具體用法?Java Result怎麽用?Java Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Result類屬於com.intellij.openapi.application包,在下文中一共展示了Result類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@Override
protected void run(@NotNull Result<PsiFile> result) throws Throwable {
    final PsiPackage packageElement = directoryService.getPackage(directory);
    if (packageElement == null) {
        throw new InvalidDirectoryException("Target directory does not provide a package");
    }

    final String fileName = Extensions.append(name, StdFileTypes.JAVA);
    final PsiFile found = directory.findFile(fileName);
    if (found != null) {
        throw new ClassAlreadyExistsException("Class '" + name + "'already exists in " + packageElement.getName());
    }

    final String packageName = packageElement.getQualifiedName();
    final String className = Extensions.remove(this.name, StdFileTypes.JAVA);
    try {
        final String java = converter.convert(packageName, className, json);
        final PsiFile classFile = fileFactory.createFileFromText(fileName, JavaFileType.INSTANCE, java);
        CodeStyleManager.getInstance(classFile.getProject()).reformat(classFile);
        JavaCodeStyleManager.getInstance(classFile.getProject()).optimizeImports(classFile);
        final PsiFile created = (PsiFile) directory.add(classFile);
        result.setResult(created);
    } catch (IOException e) {
        throw new ClassCreationException("Failed to create new class from JSON", e);
    }
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:27,代碼來源:NewClassCommandAction.java

示例2: createLog4JTest

import com.intellij.openapi.application.Result; //導入依賴的package包/類
private VirtualFile createLog4JTest(final Project project, final MavenId projectId, final VirtualFile appDirectory)
{
    return new WriteCommandAction<VirtualFile>(project, "Create Log4J Test File", PsiFile.EMPTY_ARRAY)
    {
        @Override
        protected void run(@NotNull Result<VirtualFile> result) throws Throwable
        {

            try
            {
                VirtualFile configFile = appDirectory.findOrCreateChildData(this, "log4j2-test.xml");
                final FileTemplateManager manager = FileTemplateManager.getInstance(project);
                final FileTemplate template = manager.getInternalTemplate(MuleFileTemplateDescriptorManager.LOG4J2_TEST);
                final Properties defaultProperties = manager.getDefaultProperties();
                final String text = template.getText(defaultProperties);
                VfsUtil.saveText(configFile, text);
                result.setResult(configFile);
            }
            catch (IOException e)
            {
                showError(project, e);
            }
        }
    }.execute().getResultObject();
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:26,代碼來源:MuleMavenProjectBuilderHelper.java

示例3: setUp

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@Override
protected void setUp() throws Exception {
  super.setUp();
  final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();

  myTestFixture = createFixture(factory);

  myTestFixture.setTestDataPath(getTestDataBasePath() + getTestDataPath());

  Class<? extends LocalInspectionTool>[] inspectionClasses = new DefaultInspectionProvider().getInspectionClasses();
  if (getName().contains("Inspection")) {
    inspectionClasses = ArrayUtil.mergeArrays(inspectionClasses, ApplicationLoader.getInspectionClasses());
  }

  myTestFixture.setUp();

  myTestFixture.enableInspections(inspectionClasses);

  new WriteAction() {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      ResourceUtil.copyFiles(HighlightingTestBase.this);
      init();
    }
  }.execute().throwException();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:HighlightingTestBase.java

示例4: changeLanguageLevel

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@Override
public Promise<Void> changeLanguageLevel(@NotNull Module module, @NotNull final LanguageLevel level) {
  if (!myProjectsManager.isMavenizedModule(module)) return null;

  MavenProject mavenProject = myProjectsManager.findProject(module);
  if (mavenProject == null) return null;

  final MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, mavenProject.getFile());
  if (model == null) return null;

  new WriteCommandAction(myProject, "Add Maven Dependency", DomUtil.getFile(model)) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      MavenDomConfiguration configuration = getCompilerPlugin(model).getConfiguration();
      XmlTag tag = configuration.ensureTagExists();
      setChildTagValue(tag, "source", level.getCompilerComplianceDefaultOption());
      setChildTagValue(tag, "target", level.getCompilerComplianceDefaultOption());
      Document document = PsiDocumentManager.getInstance(myProject).getDocument(DomUtil.getFile(model));
      if (document != null) {
        FileDocumentManager.getInstance().saveDocument(document);
      }
    }
  }.execute();
  return myProjectsManager.forceUpdateProjects(Collections.singleton(mavenProject));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:MavenProjectModelModifier.java

示例5: createSubdirectory

import com.intellij.openapi.application.Result; //導入依賴的package包/類
protected PsiDirectory createSubdirectory(PsiDirectory fileDirectory, String subDirectoryName) throws Exception {
    new WriteCommandAction(this.project) {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            fileDirectory.createSubdirectory(subDirectoryName);
        }

        @Override
        public String getGroupID() {
            return "Create Command";
        }

    }.execute();

    return fileDirectory.findSubdirectory(subDirectoryName);
}
 
開發者ID:project-a,項目名稱:idea-php-spryker-plugin,代碼行數:18,代碼來源:AbstractBundleAction.java

示例6: testRemoveModuleSpecifiedWithInclude

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public void testRemoveModuleSpecifiedWithInclude() throws IOException {
  Collection<String> modules = Arrays.asList("one", "two", "three", "four", "five");
  final String body = getSettingsFileWithModules(modules);
  for (final String module : modules) {
    final GradleSettingsFile file = getTestFile(body);
    new WriteCommandAction<Object>(getProject(), file.getPsiFile()) {
      @Override
      protected void run(@NotNull Result<Object> result) throws Throwable {
        file.removeModule(module);
      }
    }.execute();
    Set<String> postDelete = ImmutableSet.copyOf(file.getModules());
    assertEquals(module + " was not deleted", modules.size() - 1, postDelete.size());
    assertFalse(module + " was not deleted", postDelete.contains(module));
    Predicate<String> notCurrentModule = Predicates.not(Predicates.equalTo(module));
    String expectedFileContents = getSettingsFileWithModules(Iterables.filter(modules, notCurrentModule));
    assertEquals(expectedFileContents, file.getPsiFile().getText());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:GradleSettingsFileTest.java

示例7: configureByText

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@Override
public PsiFile configureByText(@NotNull final FileType fileType, @NotNull @NonNls final String text) {
  assertInitialized();
  final String extension = fileType.getDefaultExtension();
  final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
  if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(@NotNull Result result) throws Exception {
        fileTypeManager.associateExtension(fileType, extension);
      }
    }.execute();
  }
  final String fileName = "aaa." + extension;
  return configureByText(fileName, text);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:CodeInsightTestFixtureImpl.java

示例8: addFileToProject

import com.intellij.openapi.application.Result; //導入依賴的package包/類
protected PsiFile addFileToProject(@NotNull final String rootPath, @NotNull final String relativePath, @NotNull final String fileText) {
  return new WriteCommandAction<PsiFile>(getProject()) {
    @Override
    protected void run(@NotNull Result<PsiFile> result) throws Throwable {
      try {
        if (myTempDirFixture instanceof LightTempDirTestFixtureImpl) {
          final VirtualFile file = myTempDirFixture.createFile(relativePath, fileText);
          result.setResult(PsiManager.getInstance(getProject()).findFile(file));
        }
        else {
          result.setResult(((HeavyIdeaTestFixture)myProjectFixture).addFileToProject(rootPath, relativePath, fileText));
        }
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
      finally {
        ((PsiModificationTrackerImpl)PsiManager.getInstance(getProject()).getModificationTracker()).incCounter();
      }
    }
  }.execute().getResultObject();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:CodeInsightTestFixtureImpl.java

示例9: CompilerTester

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public CompilerTester(Project project, List<Module> modules) throws Exception {
  myProject = project;
  myModules = modules;
  myMainOutput = new TempDirTestFixtureImpl();
  myMainOutput.setUp();

  CompilerTestUtil.enableExternalCompiler();
  new WriteCommandAction(getProject()) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      //noinspection ConstantConditions
      CompilerProjectExtension.getInstance(getProject()).setCompilerOutputUrl(myMainOutput.findOrCreateDir("out").getUrl());
      for (Module module : myModules) {
        ModuleRootModificationUtil.setModuleSdk(module, JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk());
      }
    }
  }.execute();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:CompilerTester.java

示例10: createFile

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@NotNull
protected PsiFile createFile(@NotNull final Module module, @NotNull final VirtualFile vDir, @NotNull final String fileName, @NotNull final String text) throws IOException {
  return new WriteAction<PsiFile>() {
    @Override
    protected void run(@NotNull Result<PsiFile> result) throws Throwable {
      if (!ModuleRootManager.getInstance(module).getFileIndex().isInSourceContent(vDir)) {
        addSourceContentToRoots(module, vDir);
      }

      final VirtualFile vFile = vDir.createChildData(vDir, fileName);
      VfsUtil.saveText(vFile, text);
      assertNotNull(vFile);
      final PsiFile file = myPsiManager.findFile(vFile);
      assertNotNull(file);
      result.setResult(file);
    }
  }.execute().getResultObject();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PsiTestCase.java

示例11: chooseAndOverrideOrImplementMethods

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public static void chooseAndOverrideOrImplementMethods(final Project project,
                                                       final Editor editor,
                                                       final PsiClass aClass,
                                                       final boolean toImplement) {
  LOG.assertTrue(aClass.isValid());
  ApplicationManager.getApplication().assertReadAccessAllowed();

  Collection<CandidateInfo> candidates = getMethodsToOverrideImplement(aClass, toImplement);
  Collection<CandidateInfo> secondary = toImplement || aClass.isInterface() ?
                                        ContainerUtil.<CandidateInfo>newArrayList() : getMethodsToOverrideImplement(aClass, true);

  final MemberChooser<PsiMethodMember> chooser = showOverrideImplementChooser(editor, aClass, toImplement, candidates, secondary);
  if (chooser == null) return;

  final List<PsiMethodMember> selectedElements = chooser.getSelectedElements();
  if (selectedElements == null || selectedElements.isEmpty()) return;

  LOG.assertTrue(aClass.isValid());
  new WriteCommandAction(project, aClass.getContainingFile()) {
    @Override
    protected void run(@NotNull final Result result) throws Throwable {
      overrideOrImplementMethodsInRightPlace(editor, aClass, selectedElements, chooser.isCopyJavadoc(), chooser.isInsertOverrideAnnotation());
    }
  }.execute();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:OverrideImplementUtil.java

示例12: invoke

import com.intellij.openapi.application.Result; //導入依賴的package包/類
@Override
public void invoke(@NotNull final Project project,
                   @NotNull final PsiFile file,
                   @Nullable("is null when called from inspection") Editor editor,
                   @NotNull final PsiElement startElement,
                   @NotNull PsiElement endElement) {
  if (isAvailable(project, null, file)) {
    new WriteCommandAction(project) {
      @Override
      protected void run(@NotNull Result result) throws Throwable {
        final PsiDirectory directory = chooseDirectory(project, file);
        if (directory == null) return;
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            doCreate(directory, startElement);
          }
        });
      }
    }.execute();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:CreateClassOrPackageFix.java

示例13: testCaseInsensitiveRename

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public void testCaseInsensitiveRename() throws IOException {
  File file = createTempFile("file.txt", "");
  File home = file.getParentFile();
  assertOrderedEquals(Collections.singletonList("file.txt"), home.list());

  final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
  assertNotNull(vFile);
  new WriteAction<Void>() {
    @Override
    protected void run(@NotNull Result<Void> result) throws Throwable {
      vFile.rename(LocalFileSystemTest.class, "FILE.txt");
    }
  }.execute();
  assertEquals("FILE.txt", vFile.getName());
  assertOrderedEquals(Collections.singletonList("FILE.txt"), home.list());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:LocalFileSystemTest.java

示例14: addBreakpoint

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public static <T extends XBreakpointType> XBreakpoint addBreakpoint(@NotNull final Project project,
                                                                    @NotNull final Class<T> exceptionType,
                                                                    @NotNull final XBreakpointProperties properties) {
  final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
  XBreakpointType[] types = XBreakpointUtil.getBreakpointTypes();
  final Ref<XBreakpoint> breakpoint = Ref.create(null);
  for (XBreakpointType type : types) {
    if (exceptionType.isInstance(type)) {
      final T breakpointType = exceptionType.cast(type);
      new WriteAction() {
        @Override
        protected void run(@NotNull Result result) throws Throwable {
          breakpoint.set(breakpointManager.addBreakpoint(breakpointType, properties));
        }
      }.execute();
      break;
    }
  }
  return breakpoint.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:XDebuggerTestUtil.java

示例15: invoke

import com.intellij.openapi.application.Result; //導入依賴的package包/類
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
  final MavenDomDependency dep = getDependency(file, editor);

  final VirtualFile[] files;
  if (myFileChooser == null) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, true, false, false);
    final PsiFile currentValue = dep != null ? dep.getSystemPath().getValue() : null;
    final VirtualFile toSelect = currentValue == null ? null : currentValue.getVirtualFile();
    files = FileChooser.chooseFiles(descriptor, project, toSelect);
  }
  else {
    files = myFileChooser.produce();
  }
  if (files == null || files.length == 0) return;

  final PsiFile selectedFile = PsiManager.getInstance(project).findFile(files[0]);
  if (selectedFile == null) return;

  if (dep != null) {
    new WriteCommandAction(project) {
      protected void run(@NotNull Result result) throws Throwable {
        dep.getSystemPath().setValue(selectedFile);
      }
    }.execute();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:ChooseFileIntentionAction.java


注:本文中的com.intellij.openapi.application.Result類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。