Commits

Anonymous committed 8e5f6ff

Moving CancelService to NetBeans proper.

  • Participants
  • Parent commits 25da9fc

Comments (0)

Files changed (9)

src/share/classes/com/sun/tools/javac/comp/Attr.java

     final JCDiagnostic.Factory diags;
     final Annotate annotate;
     final DeferredLintHandler deferredLintHandler;
-    private final CancelService cancelService;
     private final boolean isBackgroundCompilation;
 
     public static Attr instance(Context context) {
         findDiamonds = options.get("findDiamond") != null &&
                  source.allowDiamond();
         useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
-        cancelService = CancelService.instance(context);
         isBackgroundCompilation = options.get("backgroundCompilation") != null;     //NOI18N
     }
 
     }
 
     public void visitClassDef(JCClassDecl tree) {
-        cancelService.abortIfCanceled();
         // Local classes have not been entered yet, so we need to do it now:
         if ((env.info.scope.owner.kind & (VAR | MTH)) != 0
                 && (env.info.scope.owner.kind != ERR || tree.sym == null))
     }
 
     public void visitMethodDef(JCMethodDecl tree) {
-        cancelService.abortIfCanceled();
         MethodSymbol m = tree.sym;
         if (m == null) {
             // exit in case something drastic went wrong during enter.
     }
 
     public void visitBlock(JCBlock tree) {
-        cancelService.abortIfCanceled();
         if (env.info.scope.owner != null && (env.info.scope.owner.kind == TYP || env.info.scope.owner.kind == ERR)) {
             // Block is a static or instance initializer;
             // let the owner of the environment be a freshly

src/share/classes/com/sun/tools/javac/comp/Enter.java

     JavaFileManager fileManager;
     PkgInfo pkginfoOpt;
     
-    private final CancelService cancelService;
     private final LowMemoryWatch memoryWatch;
     private final LazyTreeLoader treeLoader;
     private final DuplicateClassChecker duplicateClassChecker;
         annotate = Annotate.instance(context);
         lint = Lint.instance(context);
         names = Names.instance(context);
-        cancelService = CancelService.instance(context);
         memoryWatch = LowMemoryWatch.instance(context);
         treeLoader = LazyTreeLoader.instance(context);
         duplicateClassChecker = context.get(DuplicateClassChecker.class);
 
     @Override
     public void visitClassDef(JCClassDecl tree) {
-        cancelService.abortIfCanceled();
         Symbol owner = env.info.scope.owner;
         Scope enclScope = enterScope(env);
         ClassSymbol c = null;

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java

     private final Target target;
     private final DeferredLintHandler deferredLintHandler;
     private final JavacMessages messages;
-    private final CancelService cancelService;
     private final LazyTreeLoader treeLoader;
 
     private final boolean skipAnnotations;
         boolean backgroundCompilation = options.get("backgroundCompilation") != null;
         ignoreNoLang = ideMode && !backgroundCompilation;
         messages = JavacMessages.instance(context);
-        cancelService = CancelService.instance(context);
         treeLoader = LazyTreeLoader.instance(context);
     }
 
     }
 
     public void visitTopLevel(JCCompilationUnit tree) {
-        cancelService.abortIfCanceled();
         if (tree.starImportScope.elems != null) {
             // we must have already processed this toplevel
             return;
 
     // process the non-static imports and the static imports of types.
     public void visitImport(JCImport tree) {
-        cancelService.abortIfCanceled();
         JCTree imp = tree.qualid;
         Name name = TreeInfo.name(imp);
         TypeSymbol p;
     }
 
     public void visitMethodDef(JCMethodDecl tree) {
-        cancelService.abortIfCanceled();
         Scope enclScope = enter.enterScope(env);
         MethodSymbol m = new MethodSymbol(0, tree.name, null, enclScope.owner);
         m.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, m, tree);
     }
 
     public void visitVarDef(JCVariableDecl tree) {
-        cancelService.abortIfCanceled();
         Env<AttrContext> localEnv = env;
         if ((tree.mods.flags & STATIC) != 0 ||
             (env.info.scope.owner.flags() & INTERFACE) != 0) {

src/share/classes/com/sun/tools/javac/parser/EndPosParser.java

 import java.util.HashMap;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.TreeInfo;
-import com.sun.tools.javac.util.CancelService;
 
 import static com.sun.tools.javac.tree.JCTree.*;
 
  */
 public class EndPosParser extends JavacParser {
 
-    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap, CancelService cancelService) {
-        this(fac, S, keepDocComments, keepLineMap, cancelService, null);
+    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap) {
+        this(fac, S, keepDocComments, keepLineMap, null);
     }
 
-    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap, CancelService cancelService, Map<JCTree,Integer> endPositions) {
-        super(fac, S, keepDocComments, keepLineMap, cancelService);
+    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap, Map<JCTree,Integer> endPositions) {
+        super(fac, S, keepDocComments, keepLineMap);
         this.endPositions = endPositions == null ? new HashMap<JCTree,Integer>() : endPositions;
     }
 

src/share/classes/com/sun/tools/javac/parser/JavacParser.java

     /** The name table. */
     private Names names;
 
-    private final CancelService cancelService;
-
     /** Construct a parser from a given scanner, tree factory and log.
      */
     protected JavacParser(ParserFactory fac,
                      Lexer S,
                      boolean keepDocComments,
-                     boolean keepLineMap,
-                     CancelService cancelService) {
+                     boolean keepLineMap) {
         this.S = S;
         S.nextToken(); // prime the pump
         this.F = fac.F;
         docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
-        this.cancelService = cancelService;
     }
 
     /** Switch: Should generics be recognized?
      *  @param mods    The modifiers starting the class declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    JCClassDecl classDeclaration(JCModifiers mods, String dc) {
-        if (cancelService != null) {
-            cancelService.abortIfCanceled();
-        }
+    protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
         int pos = S.pos();
         accept(CLASS);
         Name name = ident();
      *  @param mods    The modifiers starting the interface declaration
      *  @param dc       The documentation comment for the interface, or null.
      */
-    JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
-        if (cancelService != null) {
-            cancelService.abortIfCanceled();
-        }
+    protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
         int pos = S.pos();
         accept(INTERFACE);
         Name name = ident();
      *  @param mods    The modifiers starting the enum declaration
      *  @param dc       The documentation comment for the enum, or null.
      */
-    JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
-        if (cancelService != null) {
-            cancelService.abortIfCanceled();
-        }
+    protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
         int pos = S.pos();
         accept(ENUM);
         JCModifiers newMods =
      *  ConstructorDeclaratorRest =
      *      "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
      */
-    JCTree methodDeclaratorRest(int pos,
+    protected JCTree methodDeclaratorRest(int pos,
                               JCModifiers mods,
                               JCExpression type,
                               Name name,
                               List<JCTypeParameter> typarams,
                               boolean isInterface, boolean isVoid,
                               String dc) {
-        if (cancelService != null) {
-            cancelService.abortIfCanceled();
-        }
         List<JCVariableDecl> params = formalParameters();
         if (!isVoid) type = bracketsOpt(type);
         List<JCExpression> thrown = List.nil();

src/share/classes/com/sun/tools/javac/parser/ParserFactory.java

 
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.tree.TreeMaker;
-import com.sun.tools.javac.util.CancelService;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Names;
     final Names names;
     final Options options;
     final ScannerFactory scannerFactory;
-    final CancelService cancelSevice;
 
     protected ParserFactory(Context context) {
         super();
         this.source = Source.instance(context);
         this.options = Options.instance(context);
         this.scannerFactory = ScannerFactory.instance(context);
-        this.cancelSevice = CancelService.instance(context);
     }
 
     public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
     public Parser newParser(CharSequence input, int startPos, Map<JCTree,Integer> endPos) {
         Lexer lexer = scannerFactory.newScanner(input, true);
         ((Scanner)lexer).seek(startPos);
-        JavacParser p = new EndPosParser(this, lexer, true, false, cancelSevice, endPos);
+        JavacParser p = new EndPosParser(this, lexer, true, false, endPos);
         return p;
     }
 
         Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
         JavacParser p;
         if (keepEndPos) {
-            p = new EndPosParser(this, lexer, keepDocComments, keepLineMap, cancelSevice);
+            p = new EndPosParser(this, lexer, keepDocComments, keepLineMap);
         } else {
-            p = new JavacParser(this, lexer, keepDocComments, keepLineMap, cancelSevice);
+            p = new JavacParser(this, lexer, keepDocComments, keepLineMap);
         }
         return p;
     }

src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java

 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.Abort;
 import com.sun.tools.javac.util.Assert;
-import com.sun.tools.javac.util.CancelAbort;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Convert;
         } catch (Throwable t) {
             if (t instanceof ThreadDeath)
                 throw (ThreadDeath)t;
-            if (t instanceof CancelAbort)
-                throw (CancelAbort)t;
+            if (t instanceof Abort)
+                throw (Abort)t;
             LOGGER.log(Level.INFO, "Error while re-entering:", t);
             throw new Abort(t);
         }            

src/share/classes/com/sun/tools/javac/util/CancelAbort.java

-/*
- * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package com.sun.tools.javac.util;
-
-/**
- *
- * @author Tomas Zezula
- */
-public final class CancelAbort extends Abort {
-
-    CancelAbort() {
-    }
-
-}

src/share/classes/com/sun/tools/javac/util/CancelService.java

-/*
- * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package com.sun.tools.javac.util;
-
-/**
- *
- * @author Tomas Zezula
- */
-public class CancelService {
-
-
-    /** The context key for the parameter name resolver. */
-    protected static final Context.Key<CancelService> cancelServiceKey =
-        new Context.Key<CancelService>();
-
-    public static CancelService instance(Context context) {
-        CancelService instance = context.get(cancelServiceKey);
-        if (instance == null) {
-            instance = new CancelService();
-            context.put(cancelServiceKey, instance);
-        }
-        return instance;
-    }
-
-    protected CancelService() {
-    }
-
-
-    public boolean isCanceled () {
-        return false;
-    }
-
-    public final void abortIfCanceled () {
-        if (isCanceled()) {
-            throw new CancelAbort ();
-        }
-    }
-
-}