use of st.gravel.support.compiler.ast.ClassDiff in project gravel by gravel-st.
the class SystemNode method diffTo_.
public SystemDiff diffTo_(final SystemNode _aSystemNode) {
final List<ClassDiff>[] _unordered;
final SystemNode[] _start;
final List<ClassDiff>[] _classDiffs;
_unordered = new List[1];
_start = new SystemNode[1];
_classDiffs = new List[1];
_unordered[0] = new java.util.ArrayList();
st.gravel.support.jvm.DictionaryExtensions.syncWith(this.classNodes(), _aSystemNode.classNodes(), new st.gravel.support.jvm.Block2<Object, ClassNode, ClassNode>() {
@Override
public Object value_value_(final ClassNode _old, final ClassNode _new) {
final UpdateClassDiff _diff;
_diff = _old.diffTo_(_new);
if (!_diff.isEmpty()) {
return _unordered[0].add(_diff);
}
return SystemNode.this;
}
}, new st.gravel.support.jvm.Block1<Object, ClassNode>() {
@Override
public Object value_(final ClassNode _classNode) {
return _unordered[0].add(_classNode.javaClassPath() == null ? AddClassDiff.factory.classNode_(_classNode) : WrapJavaclassDiff.factory.classNode_(_classNode));
}
}, new st.gravel.support.jvm.Block1<Object, ClassNode>() {
@Override
public Object value_(final ClassNode _classNode) {
return _unordered[0].add(RemoveClassDiff.factory.classNode_(_classNode));
}
});
_start[0] = this;
_classDiffs[0] = new java.util.ArrayList();
boolean _temp1 = false;
while (!_temp1) {
_temp1 = _unordered[0].size() == 0;
if (!_temp1) {
final List<ClassDiff> _todo;
_todo = st.gravel.support.jvm.OrderedCollectionExtensions.select_(_unordered[0], new st.gravel.support.jvm.Predicate1<ClassDiff>() {
@Override
public boolean value_(final ClassDiff _elem) {
final Reference _superclassReference;
_superclassReference = _elem.superclassReference();
return (_superclassReference == null) || _start[0].includesReference_(_superclassReference);
}
});
if (_todo.size() == 0) {
throw new RuntimeException("Prerequisite error; trying to load classes with unknown superclass");
}
_unordered[0].removeAll(_todo);
for (final ClassDiff _each : _todo) {
if (_each.isNewClassDiff()) {
_start[0] = _start[0].withClassDescriptionNode_(((NewClassDiff) _each).classNode());
if (_each.isStatic()) {
Reference _nextRef;
_nextRef = _each.superclassReference();
boolean _temp2 = false;
while (!_temp2) {
_temp2 = _nextRef == null;
if (!_temp2) {
final ClassDiff _superNode;
final Reference _ref;
_ref = _nextRef;
_superNode = ((ClassDiff) st.gravel.support.jvm.OrderedCollectionExtensions.detect_ifNone_(_classDiffs[0], new st.gravel.support.jvm.Predicate1<ClassDiff>() {
@Override
public boolean value_(final ClassDiff _cd) {
return st.gravel.support.jvm.ObjectExtensions.equals_(_cd.reference(), _ref);
}
}, ((st.gravel.support.jvm.Block0<ClassDiff>) (new st.gravel.support.jvm.Block0<ClassDiff>() {
@Override
public ClassDiff value() {
throw new RuntimeException("Prereq not found");
}
}))));
_nextRef = _superNode.isStatic() ? null : _superNode.superclassReference();
_superNode.beStatic();
}
}
}
}
_classDiffs[0].add(_each);
}
}
}
return SystemDiff.factory.classDiffs_namespaces_(_classDiffs[0].toArray(new ClassDiff[_classDiffs[0].size()]), _aSystemNode.namespaceNodes());
}
use of st.gravel.support.compiler.ast.ClassDiff in project gravel by gravel-st.
the class SystemMapping method applyDiff_.
public SystemMapping applyDiff_(final SystemDiff _aSystemDiff) {
final SystemMappingUpdater[] _updater;
_updater = new SystemMappingUpdater[1];
_updater[0] = this.newSystemMappingUpdater();
for (final ClassDiff _each : _aSystemDiff.classDiffs()) {
_updater[0].visit_(_each);
}
_updater[0].setNamespaceNodes_(_aSystemDiff.namespaces());
_updater[0].link();
return this;
}
Aggregations