Search in sources :

Example 1 with ClassDiff

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());
}
Also used : ClassNode(st.gravel.support.compiler.ast.ClassNode) ArrayList(java.util.ArrayList) List(java.util.List) UpdateClassDiff(st.gravel.support.compiler.ast.UpdateClassDiff) Reference(st.gravel.support.compiler.ast.Reference) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) NewClassDiff(st.gravel.support.compiler.ast.NewClassDiff) RemoveClassDiff(st.gravel.support.compiler.ast.RemoveClassDiff) UpdateClassDiff(st.gravel.support.compiler.ast.UpdateClassDiff) ClassDiff(st.gravel.support.compiler.ast.ClassDiff) AddClassDiff(st.gravel.support.compiler.ast.AddClassDiff) NewClassDiff(st.gravel.support.compiler.ast.NewClassDiff) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ClassDiff

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;
}
Also used : SystemMappingUpdater(st.gravel.support.compiler.ast.SystemMappingUpdater) ClassDiff(st.gravel.support.compiler.ast.ClassDiff)

Aggregations

ClassDiff (st.gravel.support.compiler.ast.ClassDiff)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AbsoluteReference (st.gravel.support.compiler.ast.AbsoluteReference)1 AddClassDiff (st.gravel.support.compiler.ast.AddClassDiff)1 ClassNode (st.gravel.support.compiler.ast.ClassNode)1 NewClassDiff (st.gravel.support.compiler.ast.NewClassDiff)1 Reference (st.gravel.support.compiler.ast.Reference)1 RemoveClassDiff (st.gravel.support.compiler.ast.RemoveClassDiff)1 SystemMappingUpdater (st.gravel.support.compiler.ast.SystemMappingUpdater)1 UpdateClassDiff (st.gravel.support.compiler.ast.UpdateClassDiff)1