@Override public void scan(JCTree tree) { noBug[0] |= (tree == val); super.scan(tree); } }.scan(method);
@Override public void visitNewClass(JCTree.JCNewClass tree) { super.visitNewClass(tree); // check for constructor invocations where the type is a member of an enclosing class, // the enclosing instance is passed as an explicit argument Type type = ASTHelpers.getType(tree.clazz); if (type == null) { return; } if (memberOfEnclosing(owner, state, type.tsym)) { canPossiblyBeStatic = false; } }
@Override public void visitSelect(JCTree.JCFieldAccess tree) { super.visitSelect(tree); // check for qualified this/super references if (tree.name == names._this || tree.name == names._super) { canPossiblyBeStatic = false; } }
public void visitClassDef(JCClassDecl tree) { if (tree.sym == element) { result[0] = tree; } else { super.visitClassDef(tree); } }
@Override public void visitMethodDef(JCTree.JCMethodDecl method) { if (ASTHelpers.isGeneratedConstructor(method)) { // Skip types in the signatures of synthetic constructors scan(method.body); } else { super.visitMethodDef(method); } }
public void visitVarDef(JCVariableDecl tree) { if (tree.sym == element) { result[0] = tree; } else { super.visitVarDef(tree); } } }.scan(cu);
@Override public void visitApply(JCMethodInvocation invocation) { // TODO: same for static variables if (invocation.meth instanceof JCIdent && JSweetConfig.TS_STRICT_MODE_KEYWORDS.contains(invocation.meth.toString().toLowerCase())) { PackageSymbol invocationPackage = (PackageSymbol) ((JCIdent) invocation.meth).sym .getEnclosingElement().getEnclosingElement(); String rootRelativeInvocationPackageName = getRootRelativeName(invocationPackage); if (rootRelativeInvocationPackageName.indexOf('.') == -1) { super.visitApply(invocation); return; } String targetRootPackageName = rootRelativeInvocationPackageName.substring(0, rootRelativeInvocationPackageName.indexOf('.')); String pathToReachRootPackage = Util.getRelativePath( "/" + compilationUnit.packge.getQualifiedName().toString().replace('.', '/'), "/" + targetRootPackageName); if (pathToReachRootPackage == null) { super.visitApply(invocation); return; } File moduleFile = new File(new File(pathToReachRootPackage), JSweetConfig.MODULE_FILE_NAME); if (!invocationPackage.toString().equals(compilationUnit.packge.getSimpleName().toString())) { useModule(false, invocationPackage, invocation, targetRootPackageName, moduleFile.getPath().replace('\\', '/'), null); } } super.visitApply(invocation); }
@Override public void visitTopLevel(JCCompilationUnit compilationUnit) { currentTopLevel = compilationUnit; if (pass == 1) { getGraph().add(compilationUnit); } else { if (compilationUnit.packge.getQualifiedName().toString().startsWith(JSweetConfig.LIBS_PACKAGE + ".")) { // skip definitions return; } currentTopLevelImportedTypes.clear(); for (JCImport i : compilationUnit.getImports()) { if (i.qualid.type != null) { currentTopLevelImportedTypes.add(i.qualid.type); } // TypeSymbol type = Util.getImportedType(i); // if (type != null) { // JCCompilationUnit target = typesToCompilationUnits.get(type); // if (target != null && getGraph().contains(target)) { // logger.debug("adding import dependency: " + // currentTopLevel.getSourceFile() + " -> " + // target.getSourceFile()); // getGraph().addEdge(target, currentTopLevel); // } // } } } super.visitTopLevel(compilationUnit); currentTopLevel = null; }
public void visitAssignop(JCAssignOp node) { node.operator = null; super.visitAssignop(node); } public void visitUnary(JCUnary node) {
public void visitBinary(JCBinary node) { node.operator = null; super.visitBinary(node); } public void visitSelect(JCFieldAccess node) {
super.visitClassDef(classdecl);
public void visitMethodDef(JCMethodDecl node) { node.sym = null; super.visitMethodDef(node); } public void visitVarDef(JCVariableDecl node) {
public void visitVarDef(JCVariableDecl node) { node.sym = null; super.visitVarDef(node); } public void visitNewClass(JCNewClass node) {
/** If tree refers to a superclass constructor call, * add all free variables of the superclass. */ public void visitApply(JCMethodInvocation tree) { if (TreeInfo.name(tree.meth) == names._super) { addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner); } super.visitApply(tree); } }
public void visitTopLevel(JCCompilationUnit node) { node.packge = null; super.visitTopLevel(node); } public void visitClassDef(JCClassDecl node) {
public void visitAssignop(JCAssignOp node) { node.operator = null; super.visitAssignop(node); } public void visitUnary(JCUnary node) {
public void visitBinary(JCBinary node) { node.operator = null; super.visitBinary(node); } public void visitSelect(JCFieldAccess node) {
/** * Grab references on the given field-access tree. */ @Override public void visitSelect(JCFieldAccess fieldAccess) { if (fieldAccess.selected.type != null && (fieldAccess.selected.type.tsym instanceof ClassSymbol)) { add(fieldAccess.selected.type.tsym); } super.visitSelect(fieldAccess); }
/** * Grab references on the given new-class tree. */ @Override public void visitNewClass(JCNewClass newClass) { add(newClass.clazz.type.tsym); super.visitNewClass(newClass); }
public void scan(JCTree t) { if (t != null) { stack.push(t); try { super.scan(t); } finally { stack.pop(); } } }