Created
January 20, 2016 07:46
-
-
Save qrtt1/47da682e21abd3b47b99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'application' | |
sourceCompatibility = '1.7' | |
repositories { | |
jcenter() | |
} | |
mainClassName = 'EclipseJdtAst' | |
dependencies { | |
compile 'eclipse:jdtcore:3.2.0.v_658' | |
compile 'org.eclipse.core:runtime:3.10.0-v20140318-2214' | |
compile 'org.eclipse.core:resources:3.3.0-v20070604' | |
compile 'org.eclipse.text:org.eclipse.text:3.5.101' | |
compile 'commons-io:commons-io:2.4' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import org.apache.commons.io.FileUtils; | |
import org.eclipse.core.runtime.CoreException; | |
import org.eclipse.jdt.core.dom.AST; | |
import org.eclipse.jdt.core.dom.ASTParser; | |
import org.eclipse.jdt.core.dom.ASTVisitor; | |
import org.eclipse.jdt.core.dom.CompilationUnit; | |
import org.eclipse.jdt.core.dom.FieldDeclaration; | |
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; | |
public class EclipseJdtAst { | |
public static void main(String[] args) throws CoreException, IOException { | |
for (String file : args) { | |
File f = new File(file); | |
if (!f.exists()) { | |
System.out.println("skip path: " + file); | |
continue; | |
} | |
visit(FileUtils.readFileToString(f)); | |
} | |
} | |
protected static void visit(String source) { | |
ASTParser parser = ASTParser.newParser(AST.JLS3); | |
parser.setKind(ASTParser.K_COMPILATION_UNIT); | |
parser.setSource(source.toCharArray()); | |
CompilationUnit unit = (CompilationUnit) parser.createAST(null); | |
unit.accept(new ASTVisitor() { | |
@Override | |
public boolean visit(FieldDeclaration node) { | |
for (Object var : node.fragments()) { | |
VariableDeclarationFragment f = (VariableDeclarationFragment) var; | |
System.out.println(String.format("%s:%s%s;", f.getName(), node.getType(), | |
f.getInitializer() == null ? "" : "=" + f.getInitializer())); | |
} | |
return super.visit(node); | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qty:EclipseJdtCoreAST qrtt1$ ./build/install/EclipseJdtCoreAST/bin/EclipseJdtCoreAST Bitmap.java | |
TAG:String="Bitmap"; | |
DENSITY_NONE:int=0; | |
mBuffer:byte[]; | |
mNativePtr:long; | |
mFinalizer:BitmapFinalizer; | |
mIsMutable:boolean; | |
mRequestPremultiplied:boolean; | |
mNinePatchChunk:byte[]; | |
mNinePatchInsets:NinePatch.InsetStruct; | |
mWidth:int; | |
mHeight:int; | |
mRecycled:boolean; | |
mDensity:int=getDefaultDensity(); | |
sScaleMatrix:Matrix; | |
sDefaultDensity:int=-1; | |
Config:enum; | |
sConfigs:Config={null,ALPHA_8,null,RGB_565,ARGB_4444,ARGB_8888}; | |
CompressFormat:enum; | |
nativeInt:int; | |
WORKING_COMPRESS_STORAGE:int=4096; | |
CREATOR:Parcelable.Creator<Bitmap>; | |
mNativeBitmap:long; | |
mNativeAllocationByteCount:int; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment