Skip to content

Commit

Permalink
Reduced debugging verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
arg0n1s committed Jul 17, 2020
1 parent 6ed270e commit c4cbbe5
Showing 1 changed file with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 7,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
Expand Down Expand Up @@ -287,31 289,47 @@ public void monitor(final Collection<Resource> resources) {
}

EcoreUtil.resolveAll(resourceSet);


boolean[] foundConflicts = {false, false};
Set<String> problems = new HashSet<>();
Set<String> exceptions = new HashSet<>();
EcoreUtil.UnresolvedProxyCrossReferencer//
.find(resourceSet)//
.forEach((eob, settings) -> {
logger.error("Problems resolving: " eob);
problems.add(eob.toString());
settings.forEach(setting -> {
EObject o = setting.getEObject();
EStructuralFeature f = setting.getEStructuralFeature();

try {
if (f.isMany()) {
((Collection<Object>) o.eGet(f)).remove(eob);
logger.warn(
"Removed proxy from collection. You should probably check why this cannot be resolved!");
foundConflicts[0] = true;
} else {
o.eSet(f, null);
logger.warn(
"Removed proxy (set to null). You should probably check why this cannot be resolved!");
foundConflicts[1] = true;
}
} catch (Exception e) {
logger.warn("Unable to remove proxy: " e);
exceptions.add(e.getMessage());
}
});
});


// Debugging output
if(problems.size() > 0) {
logger.error("Problems resolving proxy cross-references occurred for " problems.size() " EObjects.");
}
if(foundConflicts[0]) {
logger.warn(
"Removed proxy from collection. You should probably check why this cannot be resolved!");
}
if(foundConflicts[1]) {
logger.warn(
"Removed proxy (set to null). You should probably check why this cannot be resolved!");
}
exceptions.forEach(ex -> logger.warn("Unable to remove proxy: " ex));

// Insert model into engine
resources.forEach(r -> {
observer.install(r);
});
Expand Down

0 comments on commit c4cbbe5

Please sign in to comment.