Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit fb2a3d8237c156f91aa623fd0c161e2a052144cf
Merge: 26df1e5 edf4499
Author: �ukasz Zieli�ski <zieluuuu@gmail.com>
Date:   Sun Jan 22 22:13:34 2012 +0100

    Issue #6
  • Loading branch information
zielu committed Mar 22, 2012
1 parent d2023f0 commit ae621a2
Show file tree
Hide file tree
Showing 16 changed files with 237 additions and 93 deletions.
20 changes: 18 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<idea-plugin>
<name>IntelliJad Plus</name>
<description>IntelliJad Plus integrates the Jad decompiler into IntelliJ IDEA 11+.</description>
<version>0.2</version>
<version>0.3.2</version>
<vendor logo="/scn-idea-16.png">Łukasz Zieliński</vendor>
<idea-version since-build="110.365" until-build="111.999"/>
<idea-version since-build="117.000" until-build="117.999"/>

<application-components>
<component>
Expand Down Expand Up @@ -70,6 +70,22 @@
<change-notes>
<![CDATA[
<ul>
<li>0.3.2
<ol>
<li>Marked as compatible with latest Idea 11.1 RC</li>
<li>Fixed <a href="https://github.com/zielu/IntelliJadPlus/issues/6">issue #6</a>.</li>
</ol>
</li>
<li>0.3.1
<ol>
<li>Marked as compatible with latest Idea 11.1 EAP</li>
</ol>
</li>
<li>0.3
<ol>
<li>Marked as compatible with Idea 11.1 EAP</li>
</ol>
</li>
<li>0.2
<ol>
<li>Fixed <a href="https://github.com/zielu/IntelliJadPlus/issues/3">issue #3</a>.</li>
Expand Down
1 change: 1 addition & 0 deletions license-2.0.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
6 changes: 3 additions & 3 deletions src/java/net/stevechaloner/intellijad/IntelliJad.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileSystem;
import net.stevechaloner.intellijad.actions.NavigationListener;
import net.stevechaloner.intellijad.config.Config;
import net.stevechaloner.intellijad.console.ConsoleContext;
Expand All @@ -49,7 +50,6 @@
import net.stevechaloner.intellijad.environment.ValidationResult;
import net.stevechaloner.intellijad.util.FileSystemUtil;
import net.stevechaloner.intellijad.util.PluginUtil;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFileSystem;
import org.jetbrains.annotations.NotNull;

import java.io.File;
Expand Down Expand Up @@ -351,8 +351,8 @@ private void checkSDKRoot(final Project project)
{
if (project.getUserData(IntelliJadConstants.SDK_SOURCE_ROOT_ATTACHED) != Boolean.TRUE)
{
MemoryVirtualFileSystem vfs = (MemoryVirtualFileSystem) VirtualFileManager.getInstance().getFileSystem(
IntelliJadConstants.INTELLIJAD_PROTOCOL);
VirtualFileSystem vfs = VirtualFileManager.getInstance().getFileSystem(
IntelliJadConstants.INTELLIJAD_PROTOCOL);
checkSDKRoot(project,
vfs.findFileByPath(IntelliJadConstants.INTELLIJAD_ROOT));
project.putUserData(IntelliJadConstants.SDK_SOURCE_ROOT_ATTACHED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import net.stevechaloner.intellijad.decompilers.DecompilationDescriptorFactory;
import net.stevechaloner.intellijad.environment.EnvironmentContext;
import net.stevechaloner.intellijad.util.PluginUtil;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFileSystem;

import net.stevechaloner.intellijad.vfs.MemoryVF;
import net.stevechaloner.intellijad.vfs.MemoryVFS;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -194,13 +194,12 @@ private boolean isExcluded(@NotNull Config config,
public void fileClosed(FileEditorManager fileEditorManager,
VirtualFile virtualFile)
{
if (virtualFile instanceof MemoryVirtualFile)
if (virtualFile instanceof MemoryVF)
{
MemoryVirtualFileSystem vfs = (MemoryVirtualFileSystem) VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
MemoryVFS vfs = (MemoryVFS) VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
try
{
vfs.deleteFile(this,
virtualFile);
vfs.deleteFile(this, virtualFile);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import net.stevechaloner.intellijad.format.SourceReorganiser;
import net.stevechaloner.intellijad.format.StyleReformatter;
import net.stevechaloner.intellijad.util.StreamPumper;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;
import net.stevechaloner.intellijad.vfs.MemoryVF;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -178,19 +178,17 @@ protected abstract OperationStatus setup(DecompilationDescriptor descriptor,
* @param file the file to reformat
*/
protected void reformatToStyle(@NotNull final DecompilationContext context,
@NotNull final MemoryVirtualFile file)
@NotNull final MemoryVF file)
{
Config config = context.getConfig();
switch (CodeStyle.getByName(config.getReformatStyle()))
{
case DEBUGGABLE_STYLE:
SourceReorganiser.reorganise(context,
file);
SourceReorganiser.reorganise(context, file);
break;
case PREFERRED_STYLE:
default:
StyleReformatter.reformat(context,
file);
StyleReformatter.reformat(context, file.asVirtualFile());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import net.stevechaloner.intellijad.console.ConsoleContext;
import net.stevechaloner.intellijad.console.ConsoleEntryType;
import net.stevechaloner.intellijad.util.LibraryUtil;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFileSystem;
import net.stevechaloner.intellijad.vfs.MemoryVF;
import net.stevechaloner.intellijad.vfs.MemoryVFS;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -138,8 +138,8 @@ else if (!outputDirExists)
/* {@inheritDoc} */
protected VirtualFile insertIntoFileSystem(@NotNull DecompilationDescriptor descriptor,
@NotNull final DecompilationContext context,
@NotNull MemoryVirtualFileSystem vfs,
@NotNull MemoryVirtualFile file)
@NotNull MemoryVFS vfs,
@NotNull MemoryVF file)
{
final boolean debug = LOG.isDebugEnabled();

Expand Down Expand Up @@ -223,7 +223,7 @@ public void run()
/* {@inheritDoc} */
protected void attachSourceToLibraries(@NotNull DecompilationDescriptor descriptor,
@NotNull DecompilationContext context,
@NotNull MemoryVirtualFileSystem vfs,
@NotNull MemoryVFS vfs,
@NotNull List<Library> libraries)
{
if (context.getUserData(STORE_IN_MEMORY))
Expand Down Expand Up @@ -313,12 +313,11 @@ public void run()
* @param file
*/
protected void lockFile(@NotNull DecompilationContext context,
@NotNull MemoryVirtualFile file)
@NotNull MemoryVF file)
{
if (context.getUserData(STORE_IN_MEMORY))
{
super.lockFile(context,
file);
super.lockFile(context, file);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;

import com.intellij.openapi.vfs.VirtualFileSystem;
import net.stevechaloner.intellijad.IntelliJadConstants;
import net.stevechaloner.intellijad.IntelliJadResourceBundle;
import net.stevechaloner.intellijad.config.CodeStyle;
import net.stevechaloner.intellijad.config.Config;
import net.stevechaloner.intellijad.console.ConsoleContext;
import net.stevechaloner.intellijad.console.ConsoleEntryType;
import net.stevechaloner.intellijad.util.LibraryUtil;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFileSystem;
import net.stevechaloner.intellijad.vfs.MemoryVF;
import net.stevechaloner.intellijad.vfs.MemoryVFS;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -105,14 +106,13 @@ protected VirtualFile processOutput(@NotNull final DecompilationDescriptor descr
@NotNull final DecompilationContext context,
@NotNull final String content) throws DecompilationException
{
MemoryVirtualFileSystem vfs = (MemoryVirtualFileSystem) VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
MemoryVirtualFile file = new MemoryVirtualFile(descriptor.getClassName() + IntelliJadConstants.DOT_JAVA_EXTENSION,
MemoryVFS vfs = (MemoryVFS) VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
MemoryVF file = vfs.newMemoryFV(descriptor.getClassName() + IntelliJadConstants.DOT_JAVA_EXTENSION,
content);
file.putUserData(IntelliJadConstants.DECOMPILED_BY_INTELLIJAD,
true);
file.asVirtualFile().putUserData(IntelliJadConstants.DECOMPILED_BY_INTELLIJAD,
true);

reformatToStyle(context,
file);
reformatToStyle(context, file);

VirtualFile actualFile = insertIntoFileSystem(descriptor,
context,
Expand Down Expand Up @@ -152,9 +152,13 @@ protected VirtualFile processOutput(@NotNull final DecompilationDescriptor descr
* @param file the file to lock
*/
protected void lockFile(@NotNull DecompilationContext context,
@NotNull MemoryVirtualFile file)
@NotNull MemoryVF file)
{
file.setWritable(false);
try {
file.setWritable(false);
} catch (IOException e) {
LOG.error("Error while locking file: "+file.asVirtualFile().getPath(), e);
}
}

/**
Expand All @@ -168,14 +172,14 @@ protected void lockFile(@NotNull DecompilationContext context,
*/
protected VirtualFile insertIntoFileSystem(@NotNull DecompilationDescriptor descriptor,
@NotNull final DecompilationContext context,
@NotNull MemoryVirtualFileSystem vfs,
@NotNull MemoryVirtualFile file)
@NotNull MemoryVFS vfs,
@NotNull MemoryVF file)
{
vfs.addFile(file);
MemoryVirtualFile parentFile = "".equals(descriptor.getPackageName()) ? (MemoryVirtualFile)vfs.findFileByPath(IntelliJadConstants.INTELLIJAD_ROOT) : vfs.getFileForPackage(descriptor.getPackageName());
MemoryVF parentFile = "".equals(descriptor.getPackageName()) ? (MemoryVF) vfs.asVirtualFileSystem().findFileByPath(IntelliJadConstants.INTELLIJAD_ROOT) : vfs.getFileForPackage(descriptor.getPackageName());
parentFile.addChild(file);

return file;
return file.asVirtualFile();
}

/**
Expand All @@ -188,7 +192,7 @@ protected VirtualFile insertIntoFileSystem(@NotNull DecompilationDescriptor desc
*/
protected void attachSourceToLibraries(@NotNull final DecompilationDescriptor descriptor,
@NotNull final DecompilationContext context,
@NotNull final MemoryVirtualFileSystem vfs,
@NotNull final MemoryVFS vfs,
@NotNull final List<Library> libraries)
{
// CommandProcessor.getInstance().execute
Expand All @@ -208,7 +212,7 @@ public void run()
}
if (!found)
{
model.addRoot(vfs.findFileByPath(IntelliJadConstants.INTELLIJAD_ROOT),
model.addRoot(vfs.asVirtualFileSystem().findFileByPath(IntelliJadConstants.INTELLIJAD_ROOT),
OrderRootType.SOURCES);
model.commit();
}
Expand Down Expand Up @@ -281,7 +285,7 @@ public VirtualFile getVirtualFile(DecompilationDescriptor descriptor,
VirtualFile file = null;
if (fqNameAsPath != null)
{
MemoryVirtualFileSystem vfs = (MemoryVirtualFileSystem) VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
VirtualFileSystem vfs = VirtualFileManager.getInstance().getFileSystem(IntelliJadConstants.INTELLIJAD_PROTOCOL);
file = vfs.findFileByPath(fqNameAsPath);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
package net.stevechaloner.intellijad.format;

import com.intellij.openapi.diagnostic.Logger;

import net.stevechaloner.intellijad.decompilers.DecompilationContext;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;
import net.stevechaloner.intellijad.vfs.MemoryVF;

import java.io.IOException;
import java.io.LineNumberReader;
Expand Down Expand Up @@ -53,8 +52,7 @@ public class SourceReorganiser

private static final int LINE_NUMBER_MARKER_LENGTH = 8;

public static void reorganise(DecompilationContext context,
MemoryVirtualFile file)
public static void reorganise(DecompilationContext context, MemoryVF file)
{
LineNumberReader in = null;
StringWriter out = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package net.stevechaloner.intellijad.gui.tree;

import com.intellij.openapi.vfs.VirtualFile;
import net.stevechaloner.intellijad.gui.IntelliJadIcons;
import net.stevechaloner.intellijad.vfs.MemoryVirtualFile;

Expand Down Expand Up @@ -51,7 +52,7 @@ private static boolean isDirectory(VisitableTreeNode node)
Object o = node.getUserObject();
if (o instanceof CheckBoxTreeNode)
{
MemoryVirtualFile file = (MemoryVirtualFile)((CheckBoxTreeNode)o).getUserObject();
VirtualFile file = (VirtualFile)((CheckBoxTreeNode)o).getUserObject();
isDirectory = file.isDirectory();
}
return isDirectory;
Expand Down
Loading

0 comments on commit ae621a2

Please sign in to comment.