@Override @NotNull public CharSequence decompile(@NotNull VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if (decompiler instanceof ClassFileDecompilers.Full) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); return ((ClassFileDecompilers.Full)decompiler).createFileViewProvider(file, manager, true).getContents(); } if (decompiler instanceof ClassFileDecompilers.Light) { try { return ((ClassFileDecompilers.Light)decompiler).getText(file); } catch (ClassFileDecompilers.Light.CannotDecompileException e) { LOG.warn("decompiler: " + decompiler.getClass(), e); } } return ClsFileImpl.decompile(file); }
private static Map<String, Object> getOptions() { Map<String, Object> options = ContainerUtil.newHashMap(); options.put(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR, "0"); options.put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1"); options.put(IFernflowerPreferences.REMOVE_SYNTHETIC, "1"); options.put(IFernflowerPreferences.REMOVE_BRIDGE, "1"); options.put(IFernflowerPreferences.LITERALS_AS_IS, "1"); options.put(IFernflowerPreferences.NEW_LINE_SEPARATOR, "1"); options.put(IFernflowerPreferences.BANNER, BANNER); options.put(IFernflowerPreferences.MAX_PROCESSING_METHOD, 60); Project project = DefaultProjectFactory.getInstance().getDefaultProject(); CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings(); CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE); options.put(IFernflowerPreferences.INDENT_STRING, StringUtil.repeat(" ", indentOptions.INDENT_SIZE)); if (ApplicationManager.getApplication().isUnitTestMode()) { options.put(IFernflowerPreferences.UNIT_TEST_MODE, "1"); } return Collections.unmodifiableMap(options); }
/** * Kicks off the SimpleCheckout workflow with the Git Url passed */ public void processCommand() { final Project project = DefaultProjectFactory.getInstance().getDefaultProject(); final CheckoutProvider.Listener listener = ProjectLevelVcsManager.getInstance(project).getCompositeCheckoutListener(); try { launchApplicationWindow(); final SimpleCheckoutController controller = new SimpleCheckoutController(project, listener, gitUrl, ref); controller.showModalDialog(); } catch (Throwable t) { //unexpected error occurred while doing simple checkout logger.warn("VSTS commandline checkout failed due to an unexpected error", t); VcsNotifier.getInstance(project).notifyError(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_TITLE), TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, t.getMessage())); } }
/** * @return psiFile associated with the content. If the file was not set on FileContentCreation, it will be created on the spot */ @NotNull @Override public PsiFile getPsiFile() { PsiFile psi = getUserData(IndexingDataKeys.PSI_FILE); if (psi == null) { psi = getUserData(CACHED_PSI); } if (psi == null) { Project project = getProject(); if (project == null) { project = DefaultProjectFactory.getInstance().getDefaultProject(); } final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage(); final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project); psi = PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, getContentAsText(), false, false, true); psi.putUserData(IndexingDataKeys.VIRTUAL_FILE, getFile()); putUserData(CACHED_PSI, psi); } return psi; }
@Override public void actionPerformed(ActionEvent e) { final List<Course> courses = myGenerator.getCoursesUnderProgress(true, "Refreshing Course List", DefaultProjectFactory.getInstance().getDefaultProject()); if (!courses.contains(Course.INVALID_COURSE)) { refreshCoursesList(courses); } }
@NotNull public static CharSequence decompile(@NotNull VirtualFile file) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); final ClsFileImpl clsFile = new ClsFileImpl(new ClassFileViewProvider(manager, file), true); final StringBuilder buffer = new StringBuilder(); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { clsFile.appendMirrorText(0, buffer); } }); return buffer; }
public PsiFile createFileFromText(@NotNull CharSequence text) { Project project = getProject(); if (project == null) { project = DefaultProjectFactory.getInstance().getDefaultProject(); } final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage(); final VirtualFile file = getFile(); final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project); return PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, text, false, false, true, file); }
@RequiredReadAction public PsiFile createFileFromText(@Nonnull CharSequence text) { Project project = getProject(); if (project == null) { project = DefaultProjectFactory.getInstance().getDefaultProject(); } return createFileFromText(project, text, (LanguageFileType)getFileTypeWithoutSubstitution(), myFile, myFileName); }
@NotNull public static CharSequence decompile(@NotNull VirtualFile file) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); final ClsFileImpl clsFile = new ClsFileImpl(new ClassFileViewProvider(manager, file), true); final StringBuilder buffer = new StringBuilder(); ApplicationManager.getApplication().runReadAction(() -> clsFile.appendMirrorText(0, buffer)); return buffer; }
@Override @NotNull public CharSequence decompile(@NotNull VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if(decompiler instanceof ClassFileDecompilers.Full) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); return ((ClassFileDecompilers.Full) decompiler).createFileViewProvider(file, manager, true).getContents(); } return decompileText(file); }
public DirDiffViewer(@NotNull DiffContext context, @NotNull ContentDiffRequest request) { myContext = context; myRequest = request; List<DiffContent> contents = request.getContents(); DiffElement element1 = createDiffElement(contents.get(0)); DiffElement element2 = createDiffElement(contents.get(1)); Project project = context.getProject(); if (project == null) project = DefaultProjectFactory.getInstance().getDefaultProject(); DirDiffTableModel model = new DirDiffTableModel(project, element1, element2, new DirDiffSettings()); myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) { @Override public Window getWindow() { return null; } @Override public Disposable getDisposable() { return DirDiffViewer.this; } @Override public void setTitle(String title) { } }); myPanel = new JPanel(new BorderLayout()); myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.HELP_ID.is(dataId)) { return "reference.dialogs.diff.folder"; } return myDirDiffPanel.getData(dataId); } }); }
public DirDiffViewer(@Nonnull DiffContext context, @Nonnull ContentDiffRequest request) { myContext = context; myRequest = request; List<DiffContent> contents = request.getContents(); DiffElement element1 = createDiffElement(contents.get(0)); DiffElement element2 = createDiffElement(contents.get(1)); Project project = context.getProject(); if (project == null) project = DefaultProjectFactory.getInstance().getDefaultProject(); DirDiffTableModel model = new DirDiffTableModel(project, element1, element2, new DirDiffSettings()); myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) { @Override public Window getWindow() { return null; } @Override public Disposable getDisposable() { return DirDiffViewer.this; } @Override public void setTitle(String title) { } }); myPanel = new JPanel(new BorderLayout()); myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@Nonnull @NonNls Key dataId) { if (PlatformDataKeys.HELP_ID == dataId) { return "reference.dialogs.diff.folder"; } return myDirDiffPanel.getData(dataId); } }); }