Skip to content

Commit

Permalink
[eclipse] Avoid NPE in the SARL launching configuration.
Browse files Browse the repository at this point in the history
see #379

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 26, 2015
1 parent 7cfe5d6 commit c1e638c
Showing 1 changed file with 25 additions and 22 deletions.
Expand Up @@ -447,31 +447,34 @@ protected void initializeLaunchOptions(ILaunchConfigurationWorkingCopy config) {
}

private String extractNameFromJavaElement(final IJavaElement javaElement) {
final String[] name = new String[1];
try {
getLaunchConfigurationDialog().run(true, true, new IRunnableWithProgress() {
@SuppressWarnings("synthetic-access")
@Override
public void run(IProgressMonitor pm) throws InvocationTargetException {
try {
IJavaProject javaProject = javaElement.getJavaProject();
IType agentType = javaProject.findType("io.sarl.lang.core.Agent"); //$NON-NLS-1$
IType[] types = agentType.newTypeHierarchy(pm).getAllSubtypes(agentType);
if (types != null && types.length > 0) {
name[0] = types[0].getFullyQualifiedName();
String name = null;
if (javaElement != null) {
final String[] nameRef = new String[1];
try {
getLaunchConfigurationDialog().run(true, true, new IRunnableWithProgress() {
@SuppressWarnings("synthetic-access")
@Override
public void run(IProgressMonitor pm) throws InvocationTargetException {
try {
IJavaProject javaProject = javaElement.getJavaProject();
IType agentType = javaProject.findType("io.sarl.lang.core.Agent"); //$NON-NLS-1$
IType[] types = agentType.newTypeHierarchy(pm).getAllSubtypes(agentType);
if (types != null && types.length > 0) {
nameRef[0] = types[0].getFullyQualifiedName();
}
} catch (JavaModelException e) {
setErrorMessage(e.getLocalizedMessage());
JDIDebugUIPlugin.log(e);
}
} catch (JavaModelException e) {
setErrorMessage(e.getLocalizedMessage());
JDIDebugUIPlugin.log(e);
}
}
});
} catch (Exception e) {
setErrorMessage(e.getLocalizedMessage());
JDIDebugUIPlugin.log(e);
});
} catch (Exception e) {
setErrorMessage(e.getLocalizedMessage());
JDIDebugUIPlugin.log(e);
}
name = nameRef[0];
}

return Strings.nullToEmpty(name[0]);
return Strings.nullToEmpty(name);
}

/**
Expand Down

0 comments on commit c1e638c

Please sign in to comment.