diff options
| author | 2015-01-13 23:25:04 -0500 | |
|---|---|---|
| committer | 2015-01-13 23:25:04 -0500 | |
| commit | 959cb5fd4f9586ec3bd265b452fe25fe1db82e3f (patch) | |
| tree | bdd8a2c52c2fe053ba3460614bde8542e5378dbe /src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |
| parent | got rid of gradle in favor of ivy+ssjb (diff) | |
| download | enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.gz enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.xz enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.zip | |
source format change
don't hate me too much if you were planning a big merge. =P
Diffstat (limited to 'src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | 97 |
1 files changed, 43 insertions, 54 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index 24c4822..7b902a9 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -31,95 +31,84 @@ import cuchaz.enigma.mapping.ClassEntry; | |||
| 31 | import cuchaz.enigma.mapping.ConstructorEntry; | 31 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 32 | import cuchaz.enigma.mapping.FieldEntry; | 32 | import cuchaz.enigma.mapping.FieldEntry; |
| 33 | 33 | ||
| 34 | public class SourceIndexClassVisitor extends SourceIndexVisitor | 34 | public class SourceIndexClassVisitor extends SourceIndexVisitor { |
| 35 | { | 35 | |
| 36 | private ClassEntry m_classEntry; | 36 | private ClassEntry m_classEntry; |
| 37 | 37 | ||
| 38 | public SourceIndexClassVisitor( ClassEntry classEntry ) | 38 | public SourceIndexClassVisitor(ClassEntry classEntry) { |
| 39 | { | ||
| 40 | m_classEntry = classEntry; | 39 | m_classEntry = classEntry; |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | @Override | 42 | @Override |
| 44 | public Void visitTypeDeclaration( TypeDeclaration node, SourceIndex index ) | 43 | public Void visitTypeDeclaration(TypeDeclaration node, SourceIndex index) { |
| 45 | { | ||
| 46 | // is this this class, or a subtype? | 44 | // is this this class, or a subtype? |
| 47 | TypeDefinition def = node.getUserData( Keys.TYPE_DEFINITION ); | 45 | TypeDefinition def = node.getUserData(Keys.TYPE_DEFINITION); |
| 48 | ClassEntry classEntry = new ClassEntry( def.getInternalName() ); | 46 | ClassEntry classEntry = new ClassEntry(def.getInternalName()); |
| 49 | if( !classEntry.equals( m_classEntry ) ) | 47 | if (!classEntry.equals(m_classEntry)) { |
| 50 | { | ||
| 51 | // it's a sub-type, recurse | 48 | // it's a sub-type, recurse |
| 52 | index.addDeclaration( node.getNameToken(), classEntry ); | 49 | index.addDeclaration(node.getNameToken(), classEntry); |
| 53 | return node.acceptVisitor( new SourceIndexClassVisitor( classEntry ), index ); | 50 | return node.acceptVisitor(new SourceIndexClassVisitor(classEntry), index); |
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | return recurse( node, index ); | 53 | return recurse(node, index); |
| 57 | } | 54 | } |
| 58 | 55 | ||
| 59 | @Override | 56 | @Override |
| 60 | public Void visitSimpleType( SimpleType node, SourceIndex index ) | 57 | public Void visitSimpleType(SimpleType node, SourceIndex index) { |
| 61 | { | 58 | TypeReference ref = node.getUserData(Keys.TYPE_REFERENCE); |
| 62 | TypeReference ref = node.getUserData( Keys.TYPE_REFERENCE ); | 59 | if (node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY) { |
| 63 | if( node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY ) | 60 | ClassEntry classEntry = new ClassEntry(ref.getInternalName()); |
| 64 | { | 61 | index.addReference(node.getIdentifierToken(), classEntry, m_classEntry); |
| 65 | ClassEntry classEntry = new ClassEntry( ref.getInternalName() ); | ||
| 66 | index.addReference( node.getIdentifierToken(), classEntry, m_classEntry ); | ||
| 67 | } | 62 | } |
| 68 | 63 | ||
| 69 | return recurse( node, index ); | 64 | return recurse(node, index); |
| 70 | } | 65 | } |
| 71 | 66 | ||
| 72 | @Override | 67 | @Override |
| 73 | public Void visitMethodDeclaration( MethodDeclaration node, SourceIndex index ) | 68 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { |
| 74 | { | 69 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 75 | MethodDefinition def = node.getUserData( Keys.METHOD_DEFINITION ); | 70 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 76 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 71 | BehaviorEntry behaviorEntry = BehaviorEntryFactory.create(classEntry, def.getName(), def.getSignature()); |
| 77 | BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( classEntry, def.getName(), def.getSignature() ); | ||
| 78 | AstNode tokenNode = node.getNameToken(); | 72 | AstNode tokenNode = node.getNameToken(); |
| 79 | if( behaviorEntry instanceof ConstructorEntry ) | 73 | if (behaviorEntry instanceof ConstructorEntry) { |
| 80 | { | ||
| 81 | ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry; | 74 | ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry; |
| 82 | if( constructorEntry.isStatic() ) | 75 | if (constructorEntry.isStatic()) { |
| 83 | { | ||
| 84 | tokenNode = node.getModifiers().firstOrNullObject(); | 76 | tokenNode = node.getModifiers().firstOrNullObject(); |
| 85 | } | 77 | } |
| 86 | } | 78 | } |
| 87 | index.addDeclaration( tokenNode, behaviorEntry ); | 79 | index.addDeclaration(tokenNode, behaviorEntry); |
| 88 | return node.acceptVisitor( new SourceIndexBehaviorVisitor( behaviorEntry ), index ); | 80 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(behaviorEntry), index); |
| 89 | } | 81 | } |
| 90 | 82 | ||
| 91 | @Override | 83 | @Override |
| 92 | public Void visitConstructorDeclaration( ConstructorDeclaration node, SourceIndex index ) | 84 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { |
| 93 | { | 85 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 94 | MethodDefinition def = node.getUserData( Keys.METHOD_DEFINITION ); | 86 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 95 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 87 | ConstructorEntry constructorEntry = new ConstructorEntry(classEntry, def.getSignature()); |
| 96 | ConstructorEntry constructorEntry = new ConstructorEntry( classEntry, def.getSignature() ); | 88 | index.addDeclaration(node.getNameToken(), constructorEntry); |
| 97 | index.addDeclaration( node.getNameToken(), constructorEntry ); | 89 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(constructorEntry), index); |
| 98 | return node.acceptVisitor( new SourceIndexBehaviorVisitor( constructorEntry ), index ); | ||
| 99 | } | 90 | } |
| 100 | 91 | ||
| 101 | @Override | 92 | @Override |
| 102 | public Void visitFieldDeclaration( FieldDeclaration node, SourceIndex index ) | 93 | public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { |
| 103 | { | 94 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 104 | FieldDefinition def = node.getUserData( Keys.FIELD_DEFINITION ); | 95 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 105 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 96 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName()); |
| 106 | FieldEntry fieldEntry = new FieldEntry( classEntry, def.getName() ); | 97 | assert (node.getVariables().size() == 1); |
| 107 | assert( node.getVariables().size() == 1 ); | ||
| 108 | VariableInitializer variable = node.getVariables().firstOrNullObject(); | 98 | VariableInitializer variable = node.getVariables().firstOrNullObject(); |
| 109 | index.addDeclaration( variable.getNameToken(), fieldEntry ); | 99 | index.addDeclaration(variable.getNameToken(), fieldEntry); |
| 110 | 100 | ||
| 111 | return recurse( node, index ); | 101 | return recurse(node, index); |
| 112 | } | 102 | } |
| 113 | 103 | ||
| 114 | @Override | 104 | @Override |
| 115 | public Void visitEnumValueDeclaration( EnumValueDeclaration node, SourceIndex index ) | 105 | public Void visitEnumValueDeclaration(EnumValueDeclaration node, SourceIndex index) { |
| 116 | { | ||
| 117 | // treat enum declarations as field declarations | 106 | // treat enum declarations as field declarations |
| 118 | FieldDefinition def = node.getUserData( Keys.FIELD_DEFINITION ); | 107 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 119 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 108 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 120 | FieldEntry fieldEntry = new FieldEntry( classEntry, def.getName() ); | 109 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName()); |
| 121 | index.addDeclaration( node.getNameToken(), fieldEntry ); | 110 | index.addDeclaration(node.getNameToken(), fieldEntry); |
| 122 | 111 | ||
| 123 | return recurse( node, index ); | 112 | return recurse(node, index); |
| 124 | } | 113 | } |
| 125 | } | 114 | } |