Handle erroneous files and incompatibilities between class and source files more gracefully.
authorJan Lahoda <jlahoda@netbeans.org>
Sat, 03 Aug 2013 23:14:11 +0200
changeset 977e262ca133e80
parent 976 f2cfa4472600
child 978 cb2dd061627f
Handle erroneous files and incompatibilities between class and source files more gracefully.
remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java
     1.1 --- a/remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java	Fri Aug 02 22:52:24 2013 +0200
     1.2 +++ b/remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java	Sat Aug 03 23:14:11 2013 +0200
     1.3 @@ -42,9 +42,14 @@
     1.4  package org.netbeans.modules.jackpot30.resolve.api;
     1.5  
     1.6  import com.sun.source.tree.CompilationUnitTree;
     1.7 +import com.sun.source.tree.Tree;
     1.8  import com.sun.source.util.JavacTask;
     1.9  import com.sun.tools.javac.api.JavacTaskImpl;
    1.10 +import com.sun.tools.javac.code.Symbol.ClassSymbol;
    1.11 +import com.sun.tools.javac.model.LazyTreeLoader;
    1.12  import com.sun.tools.javac.util.Abort;
    1.13 +import com.sun.tools.javac.util.Context;
    1.14 +import com.sun.tools.javac.util.Context.Factory;
    1.15  import java.io.IOException;
    1.16  import java.io.InputStream;
    1.17  import java.io.OutputStream;
    1.18 @@ -136,7 +141,8 @@
    1.19  
    1.20          if (jti == null) {
    1.21              FMImpl fm = new FMImpl(sourceRoot.getClassPath());
    1.22 -            javacTask.set(jti = JavacCreator.create(null, fm, null, Arrays.asList("-Xjcov", "-proc:none"), null, Collections.<JavaFileObject>emptyList()));
    1.23 +            javacTask.set(jti = JavacCreator.create(null, fm, null, Arrays.asList("-Xjcov", "-proc:none", "-XDshouldStopPolicy=FLOW"), null, Collections.<JavaFileObject>emptyList()));
    1.24 +            TreeLoaderImpl.preRegister(jti.getContext());
    1.25          }
    1.26  
    1.27          return jti;
    1.28 @@ -330,4 +336,24 @@
    1.29          }
    1.30  
    1.31      }
    1.32 +
    1.33 +    private static final class TreeLoaderImpl extends LazyTreeLoader {
    1.34 +        public static void preRegister(Context ctx) {
    1.35 +            ctx.put(lazyTreeLoaderKey, new Factory<LazyTreeLoader>() {
    1.36 +                @Override public LazyTreeLoader make(Context ctx) {
    1.37 +                    return new TreeLoaderImpl(ctx);
    1.38 +                }
    1.39 +            });
    1.40 +        }
    1.41 +
    1.42 +        public TreeLoaderImpl(Context ctx) {
    1.43 +            ctx.put(lazyTreeLoaderKey, this);
    1.44 +        }
    1.45 +
    1.46 +        @Override
    1.47 +        public void couplingError(ClassSymbol clazz, Tree t) {
    1.48 +            //ignore...
    1.49 +        }
    1.50 +
    1.51 +    }
    1.52  }