2828import org .apache .commons .lang3 .reflect .FieldUtils ;
2929import org .eclipse .core .resources .IWorkspaceRoot ;
3030import org .eclipse .core .resources .ResourcesPlugin ;
31- import org .eclipse .core .runtime .CoreException ;
3231import org .eclipse .debug .core .DebugException ;
3332import org .eclipse .debug .core .ILaunch ;
3433import org .eclipse .debug .core .ILaunchConfiguration ;
3736import org .eclipse .debug .core .model .ISourceLocator ;
3837import org .eclipse .debug .core .model .IStackFrame ;
3938import org .eclipse .debug .core .sourcelookup .AbstractSourceLookupDirector ;
40- import org .eclipse .debug .core .sourcelookup .containers . ProjectSourceContainer ;
39+ import org .eclipse .debug .core .sourcelookup .ISourceContainer ;
4140import org .eclipse .jdt .core .IJavaProject ;
4241import org .eclipse .jdt .debug .core .IJavaStackFrame ;
4342import org .eclipse .jdt .debug .eval .ICompiledExpression ;
5251import com .microsoft .java .debug .core .adapter .Constants ;
5352import com .microsoft .java .debug .core .adapter .IDebugAdapterContext ;
5453import com .microsoft .java .debug .core .adapter .IEvaluationProvider ;
54+ import com .microsoft .java .debug .core .adapter .ISourceLookUpProvider ;
55+ import com .microsoft .java .debug .plugin .internal .JdtSourceLookUpProvider ;
5556import com .microsoft .java .debug .plugin .internal .JdtUtils ;
5657import com .sun .jdi .StackFrame ;
5758import com .sun .jdi .ThreadReference ;
@@ -319,7 +320,8 @@ private void ensureDebugTarget(VirtualMachine vm, ThreadReference thread, int de
319320 }
320321
321322 if (launch == null ) {
322- launch = createILaunchMock (project );
323+ ISourceLookUpProvider sourceProvider = context .getProvider (ISourceLookUpProvider .class );
324+ launch = createILaunchMock (project , ((JdtSourceLookUpProvider ) sourceProvider ).getSourceContainers ());
323325 }
324326
325327 debugTarget = new JDIDebugTarget (launch , vm , "" , false , false , null , false ) {
@@ -331,7 +333,7 @@ protected synchronized void initialize() {
331333 }
332334 }
333335
334- private static ILaunch createILaunchMock (IJavaProject project ) {
336+ private static ILaunch createILaunchMock (IJavaProject project , ISourceContainer [] containers ) {
335337 return new ILaunch () {
336338 private AbstractSourceLookupDirector locator ;
337339
@@ -405,9 +407,8 @@ public ISourceLocator getSourceLocator() {
405407 locator = new JavaSourceLookupDirector ();
406408
407409 try {
408- locator .setSourceContainers (
409- new ProjectSourceContainer (project .getProject (), true ).getSourceContainers ());
410- } catch (CoreException e ) {
410+ locator .setSourceContainers (containers );
411+ } catch (Exception e ) {
411412 logger .severe (String .format ("Cannot initialize JavaSourceLookupDirector: %s" , e .toString ()));
412413 }
413414 locator .initializeParticipants ();
0 commit comments