src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java
changeset 49092 6dc5e0cdb44c
parent 48610 a587f95313f1
child 49518 d0ff431a596e
equal deleted inserted replaced
49091:0fa50be70f7a 49092:6dc5e0cdb44c
   309         @Override
   309         @Override
   310         public JavaFileObject sourceToFileObject(MemoryFileManager fm, OuterWrap w) {
   310         public JavaFileObject sourceToFileObject(MemoryFileManager fm, OuterWrap w) {
   311             return fm.createSourceFileObject(w, w.classFullName(), w.wrapped());
   311             return fm.createSourceFileObject(w, w.classFullName(), w.wrapped());
   312         }
   312         }
   313 
   313 
       
   314         /**
       
   315          * Get the source information from the wrap.  If this is external, or
       
   316          * otherwise does not have wrap info, just use source code.
       
   317          * @param d the Diagnostic from the compiler
       
   318          * @return the corresponding Diag
       
   319          */
   314         @Override
   320         @Override
   315         public Diag diag(Diagnostic<? extends JavaFileObject> d) {
   321         public Diag diag(Diagnostic<? extends JavaFileObject> d) {
   316             SourceMemoryJavaFileObject smjfo = (SourceMemoryJavaFileObject) d.getSource();
   322             JavaFileObject jfo = d.getSource();
   317             if (smjfo == null) {
   323             return jfo instanceof SourceMemoryJavaFileObject
   318                 // Handle failure that doesn't preserve mapping
   324                     ? ((OuterWrap) ((SourceMemoryJavaFileObject) jfo).getOrigin()).wrapDiag(d)
   319                 return new StringSourceHandler().diag(d);
   325                     : new StringSourceHandler().diag(d);
   320             }
       
   321             OuterWrap w = (OuterWrap) smjfo.getOrigin();
       
   322             return w.wrapDiag(d);
       
   323         }
   326         }
   324     }
   327     }
   325 
   328 
   326     /**
   329     /**
   327      * Parse a snippet of code (as a String) using the parser subclass.  Return
   330      * Parse a snippet of code (as a String) using the parser subclass.  Return