Skip to content

Commit

Permalink
Refactor property handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Feb 28, 2018
1 parent 6c97ee4 commit fc800bf
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void setHasInconsistentHierarchy(boolean b) {
/**
* Returns the ClassNode this ClassNode is redirecting to.
*/
public ClassNode redirect(){
public ClassNode redirect() {
if (redirect==null) return this;
return redirect.redirect();
}
Expand Down Expand Up @@ -562,15 +562,10 @@ public void setModifiers(int modifiers) {
redirect().modifiers = modifiers;
}

// GRECLIPSE add -- overridable method for JDTClassNode
protected void ensurePropertiesInitialized() {
}
// GRECLIPSE end

public List<PropertyNode> getProperties() {
final ClassNode r = redirect();
// GRECLIPSE add
r.ensurePropertiesInitialized();
if (r != this) return r.getProperties();
// GRECLIPSE end
if (r.properties == null)
r.properties = new ArrayList<PropertyNode> ();
Expand Down Expand Up @@ -642,24 +637,19 @@ public void addFieldFirst(FieldNode node) {
r.fieldIndex.put(node.getName(), node);
}

// GRECLIPSE add
public void addPropertyWithoutField(PropertyNode node) {
ClassNode r = redirect();
node.setDeclaringClass(r);
if (r.properties == null)
r.properties = new ArrayList<PropertyNode>();
r.properties.add(node);
}
// GRECLIPSE end

public void addProperty(PropertyNode node) {
// GRECLIPSE add
getProperties().add(node);
// GRECLIPSE end
node.setDeclaringClass(redirect());
FieldNode field = node.getField();
addField(field);
/* GRECLIPSE edit
final ClassNode r = redirect();
if (r.properties == null)
r.properties = new ArrayList<PropertyNode> ();
r.properties.add(node);
*/
}

public PropertyNode addProperty(String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void setHasInconsistentHierarchy(boolean b) {
/**
* Returns the ClassNode this ClassNode is redirecting to.
*/
public ClassNode redirect(){
public ClassNode redirect() {
if (redirect==null) return this;
return redirect.redirect();
}
Expand Down Expand Up @@ -551,15 +551,10 @@ public void setModifiers(int modifiers) {
redirect().modifiers = modifiers;
}

// GRECLIPSE add -- overridable method for JDTClassNode
protected void ensurePropertiesInitialized() {
}
// GRECLIPSE end

public List<PropertyNode> getProperties() {
final ClassNode r = redirect();
// GRECLIPSE add
r.ensurePropertiesInitialized();
if (r != this) return r.getProperties();
// GRECLIPSE end
if (r.properties == null)
r.properties = new ArrayList<PropertyNode>();
Expand Down Expand Up @@ -636,24 +631,19 @@ public Map<String, FieldNode> getFieldIndex() {
return fieldIndex;
}

// GRECLIPSE add
public void addPropertyWithoutField(PropertyNode node) {
ClassNode r = redirect();
node.setDeclaringClass(r);
if (r.properties == null)
r.properties = new ArrayList<>();
r.properties.add(node);
}
// GRECLIPSE end

public void addProperty(PropertyNode node) {
// GRECLIPSE add
getProperties().add(node);
// GRECLIPSE end
node.setDeclaringClass(redirect());
FieldNode field = node.getField();
addField(field);
/* GRECLIPSE edit
final ClassNode r = redirect();
if (r.properties == null)
r.properties = new ArrayList<PropertyNode>();
r.properties.add(node);
*/
}

public PropertyNode addProperty(String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void setHasInconsistentHierarchy(boolean b) {
/**
* Returns the ClassNode this ClassNode is redirecting to.
*/
public ClassNode redirect(){
public ClassNode redirect() {
if (redirect==null) return this;
return redirect.redirect();
}
Expand Down Expand Up @@ -334,7 +334,7 @@ public ClassNode(Class c, ClassNode componentType) {
* ClassNode will not be a primary ClassNode.
*/
public ClassNode(Class c) {
this(c.getName(), c.getModifiers(), null, null ,MixinNode.EMPTY_ARRAY);
this(c.getName(), c.getModifiers(), null, null, MixinNode.EMPTY_ARRAY);
clazz=c;
lazyInitDone=false;
CompileUnit cu = getCompileUnit();
Expand Down Expand Up @@ -557,15 +557,10 @@ public void setModifiers(int modifiers) {
redirect().modifiers = modifiers;
}

// GRECLIPSE add -- overridable method for JDTClassNode
protected void ensurePropertiesInitialized() {
}
// GRECLIPSE end

public List<PropertyNode> getProperties() {
final ClassNode r = redirect();
// GRECLIPSE add
r.ensurePropertiesInitialized();
if (r != this) return r.getProperties();
// GRECLIPSE end
if (r.properties == null)
r.properties = new ArrayList<PropertyNode>();
Expand Down Expand Up @@ -642,24 +637,19 @@ public Map<String, FieldNode> getFieldIndex() {
return fieldIndex;
}

// GRECLIPSE add
public void addPropertyWithoutField(PropertyNode node) {
ClassNode r = redirect();
node.setDeclaringClass(r);
if (r.properties == null)
r.properties = new ArrayList<>();
r.properties.add(node);
}
// GRECLIPSE end

public void addProperty(PropertyNode node) {
// GRECLIPSE add
getProperties().add(node);
// GRECLIPSE end
node.setDeclaringClass(redirect());
FieldNode field = node.getField();
addField(field);
/* GRECLIPSE edit
final ClassNode r = redirect();
if (r.properties == null)
r.properties = new ArrayList<PropertyNode>();
r.properties.add(node);
*/
}

public PropertyNode addProperty(String name,
Expand Down
Loading

0 comments on commit fc800bf

Please sign in to comment.