Skip to content

Commit

Permalink
EolDebugger: more protections against NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
agarciadom committed Aug 28, 2024
1 parent a85417e commit c8406f8
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public IEpsilonDebugTarget getTarget() {
}

protected IEolModule getModule() {
return target.getModule();
return target != null ? target.getModule() : null;
}

@Override
public void control(ModuleElement ast, IEolContext context) {
if (!controls(ast)) {
if (target == null || !controls(ast)) {
return;
}
currentModuleElement = ast;
Expand Down Expand Up @@ -133,7 +133,8 @@ private boolean controls(ModuleElement ast) {
}

private int frameStackSize() {
return getModule().getContext().getFrameStack().getFrames().size();
IEolModule module = getModule();
return module != null ? module.getContext().getFrameStack().getFrames().size() : 0;
}

private ModuleElement getGrandparent(ModuleElement ast) {
Expand All @@ -145,7 +146,7 @@ private ModuleElement getParent(ModuleElement ast) {
}

private boolean hasBreakpoint(ModuleElement ast) {
if (target.hasBreakpointItself(ast)) {
if (target != null && target.hasBreakpointItself(ast)) {
return true;
}

Expand Down Expand Up @@ -279,7 +280,10 @@ protected IModule resolveModule(final Map<URI, Path> uriToPathMappings, final St
protected synchronized Map<String, IModule> getURIToModuleMap() throws IOException {
if (this.uriToModule == null) {
this.uriToModule = new HashMap<>();
addAllModules(uriToModule, getModule());
IEolModule module = getModule();
if (module != null) {
addAllModules(uriToModule, module);
}
}
return uriToModule;
}
Expand Down

0 comments on commit c8406f8

Please sign in to comment.