Package com.sun.tools.javac.tree.JCTree

Examples of com.sun.tools.javac.tree.JCTree.JCVariableDecl


      } else {
        members = ((JCBlock) path.getLeaf()).getStatements();
      }
      for (JCTree jcTree : members) {
        if (jcTree.getKind() == Kind.VARIABLE) {
          JCVariableDecl declaration = (JCVariableDecl) jcTree;
          TypeSymbol variableTypeSymbol = declaration.getType().type.tsym;

          if (ASTHelpers.getSymbol(toReplace).isMemberOf(variableTypeSymbol, state.getTypes())) {
            if (toReplace.getKind() == Kind.IDENTIFIER) {
              fix = SuggestedFix.prefixWith(toReplace, declaration.getName() + ".");
            } else {
              fix = SuggestedFix.replace(
                  ((JCFieldAccess) toReplace).getExpression(), declaration.getName().toString());
            }
          }
        }
      }
    }
View Full Code Here


      JCClassDecl klass = (JCClassDecl) path.getLeaf();
      int minEditDistance = Integer.MAX_VALUE;
      String replacement = null;
      for (JCTree member : klass.getMembers()) {
        if (member.getKind() == VARIABLE) {
          JCVariableDecl var = (JCVariableDecl) member;
          if (!Flags.isStatic(var.sym) && var.type == type) {
            int editDistance = EditDistance.getEditDistance(lhsName, var.name.toString());
            if (editDistance < minEditDistance) {
              // pick one with minimum edit distance
              minEditDistance = editDistance;
View Full Code Here

        path = path.getParentPath();
      }
      JCBlock block = (JCBlock)path.getLeaf();
      for (JCStatement jcStatement : block.getStatements()) {
        if (jcStatement.getKind() == Kind.VARIABLE) {
          JCVariableDecl declaration = (JCVariableDecl) jcStatement;
          TypeSymbol variableTypeSymbol = declaration.getType().type.tsym;

          if (ASTHelpers.getSymbol(toReplace).isMemberOf(variableTypeSymbol, state.getTypes())) {
            if (toReplace.getKind() == Kind.IDENTIFIER) {
              fix = SuggestedFix.prefixWith(toReplace, declaration.getName() + ".");
            } else {
              fix = SuggestedFix.replace(((JCFieldAccess) toReplace).getExpression(),
                  declaration.getName().toString());
            }
          }
        }
      }
    }
View Full Code Here

      JCClassDecl klass = (JCClassDecl) path.getLeaf();
      int minEditDistance = Integer.MAX_VALUE;
      String replacement = null;
      for (JCTree member : klass.getMembers()) {
        if (member.getKind() == VARIABLE) {
          JCVariableDecl var = (JCVariableDecl) member;
          if (!Flags.isStatic(var.sym)
              && variableType(isSubtypeOf("java.util.Collection")).matches(var, state)) {
            int editDistance = EditDistance.getEditDistance(lhsName, var.name.toString());
            if (editDistance < minEditDistance) {
              // pick one with minimum edit distance
View Full Code Here

   
    boolean hasAnonymousClassDeclaration = false;

    // only static fields
    for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCVariableDecl){
      JCVariableDecl f = (JCVariableDecl)tr;
      hasAnonymousClassDeclaration |= anonymousTester.test(f);
     
      if(!isStatic(f.getModifiers())) continue;
      if(null==f.getInitializer() || "null".equals(f.getInitializer().toString())) continue;
     
      cl.selfPrefix = getObfuscatedName(cl.name)+ ".";
     
//      parse(f.getName());
     
      String fName = f.getName().toString();
//      if("name".equals(fName)) fName = "__name";
      code.append(cl.selfPrefix + getObfuscatedName(fName) + (obfuscate ? "=" : " = "));
      parse(f.getInitializer());
      code.append(";\n");
    }

    code.append(getObfuscatedName(cl.name) + ".prototype."+getObfuscatedName(cl.name+"_initInstanceFields") + " = function()" + ifObfuscated("{", " {\n"));
   
    if(null!=superType && classes.containsKey(superType) && !classes.get(superType).isNative) {
      code.append("this."+getObfuscatedName(superType+"_initInstanceFields") + "();" + ifObfuscated("", "\n"));
    }
   
//     only NOT static fields

    if(hasAnonymousClassDeclaration) {
      code.append("var "+(cl.selfPrefix = getObfuscatedName("self"))+" = this;\n");
    } else cl.selfPrefix = "this";
   
    for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCVariableDecl){
      JCVariableDecl f = (JCVariableDecl)tr;
     
      if(isStatic(f.getModifiers())) continue;
      if(null==f.getInitializer() || "null".equals(f.getInitializer().toString())) continue;

      //cl.selfPrefix = "this";
     
      parse(f.getName());
      code.append(obfuscate ? "=" : " = ");
      parse(f.getInitializer());
      code.append(";\n");
    }
   
    code.append("}\n");
   
View Full Code Here

     
      currentClass.add(cl);
      cl.skipInnerObfuscation = claz.skipInnerObfuscation;
      for(Object o : acl.getMembers()) {
        if(o instanceof JCVariableDecl) {
          JCVariableDecl f = (JCVariableDecl)o;
          if(i>0) code.append(","+indentPrefix);
          i++;
          code.append(getObfuscatedName(f.getName().toString(), cl.skipInnerObfuscation || cl.isNative) + ": ");
          parse(f.getInitializer());
        }
        if(o instanceof JCMethodDecl) {
          if(i>0) code.append(","+indentPrefix);
          i++;
          JCMethodDecl m = (JCMethodDecl)o;
View Full Code Here

        }

    Map<String, JCVariableDecl> fields = new TreeMap<String, JCVariableDecl>();
   
    for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCVariableDecl) {
      JCVariableDecl f = (JCVariableDecl)tr;
      if(parser.isStatic(f.getModifiers())) continue;
//      System.out.println(f);
      if(parser.hasAnnotation(AjaxTransient.class.getSimpleName(), f.getModifiers())) continue;
      if(null!=f.getInitializer()) {
        fields.put(f.getName().toString(), f);         
      }
    }
   
    for(JCTree tr : cl.type.getMembers()) if(tr instanceof JCMethodDecl) {
      JCMethodDecl m = (JCMethodDecl)tr;
View Full Code Here

   
    Set<String> myProperties = new TreeSet<String>();
    for(Object decl : bodies) {
      if(decl instanceof JCVariableDecl) {
        JCVariableDecl field = (JCVariableDecl)decl;
        boolean isStatic = isStatic(field.getModifiers());
       
        String fName = field.getName().toString();
        if(myProperties.contains(fName) || cl.fields.containsKey(fName)) {
          throw new RuntimeException("Dublicate field or method: " + name+"."+fName);
        }
        myProperties.add(fName);
        if(isStatic) cl.staticFields.add(fName);
        cl.fields.put(fName, new ParsedField(fName, field.getType(), cl));
        //System.out.println(name+" :: "+fr.getName().toString()+ " :: " + field.getType());
      }
      if(decl instanceof JCMethodDecl) {
        JCMethodDecl method = (JCMethodDecl)decl;
        String mName = method.getName().toString();
View Full Code Here

    if(anonymousTester.test(block)) {
      code.append("var "+(currentClass.lastElement().selfPrefix = getObfuscatedName("self" + currentClass.size()))+ifObfuscated("=this;", " = this;\n"+indentPrefix));
    } else currentClass.lastElement().selfPrefix = "this";
   
    if(params.size()>0) {
      JCVariableDecl lastParam = params.get(params.size()-1);
      String lpn = lastParam.getName().toString();
     
      if(lastParam.toString().indexOf("...") > 0) {
//        System.out.println("!!!" + lastParam);
//        code.append("var "+lpn+"=" + "[];"+indentPrefix);
        code.append("{var $$$=[];for(var i=0;i<arguments.length;i++)if(i>="+(params.size()-1)+")$$$.push(arguments[i]);"+getObfuscatedName(lpn)+"=$$$;}"+indentPrefix);         
//        System.out.println("###" + lastParam.);
      }
View Full Code Here

                        final List<JCStatement> statements = ((JCMethodDecl) blockNode).body.stats;

                        // Новое тело метода
                        List<JCStatement> newStatements = List.nil();
                        // Добавляем в начало метода сохранение текущего времени
                        JCVariableDecl var = makeTimeStartVar(maker, utils, time);
                        newStatements = newStatements.append(var);

                        // Создаём тело блока try, копируем в него оригинальное содержимое метода
                        List<JCStatement> tryBlock = List.nil();
                        for (JCStatement statement : statements) {
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.tree.JCTree.JCVariableDecl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.