Java 类org.eclipse.jdt.core.dom.CharacterLiteral 实例源码

项目:fb-contrib-eclipse-quick-fixes    文件:UseCharacterParameterizedMethodResolution.java   
@Override
protected void repairBug(ASTRewrite rewrite, CompilationUnit workingUnit, BugInstance bug) throws BugResolutionException {
    ASTNode node = getASTNode(workingUnit, bug.getPrimarySourceLineAnnotation());
    node = TraversalUtil.backtrackToBlock(node);
    StringToCharVisitor visitor = new StringToCharVisitor();
    node.accept(visitor);

    AST ast = rewrite.getAST();

    if (useStringBuilder) {
        MethodInvocation toString = buildChainedToString(rewrite, visitor, ast);
        rewrite.replace(visitor.infixExpression, toString, null);
    } else {
        handleSimpleConcat(rewrite, visitor, ast);
    }

    // replaces all non-concatenation StringLiterals
    for (Map.Entry<StringLiteral, Character> entry : visitor.replacements.entrySet()) {
        CharacterLiteral charLiteral = ast.newCharacterLiteral();
        charLiteral.setCharValue(entry.getValue());
        rewrite.replace(entry.getKey(), charLiteral, null);
    }
}
项目:gwt-eclipse-plugin    文件:RenamedElementAstMatcher.java   
@Override
public boolean match(CharacterLiteral node, Object other) {
  if (!(other instanceof CharacterLiteral)) {
    return false;
  }
  CharacterLiteral o = (CharacterLiteral) other;
  return safeRenamedEquals(node.getEscapedValue(), o.getEscapedValue(),
      oldName, newName);
}
项目:evosuite    文件:TestExtractingVisitor.java   
private VariableReference retrieveVariableReference(CharacterLiteral characterLiteral) {
    char character = characterLiteral.charValue();
    PrimitiveStatement<Character> charAssignment = new CharPrimitiveStatement(
            testCase.getReference(), character);
    testCase.addStatement(charAssignment);
    return charAssignment.getReturnValue();
}
项目:fb-contrib-eclipse-quick-fixes    文件:UseCharacterParameterizedMethodResolution.java   
private static Expression fixSingleLengthString(Expression expr, AST ast) {
    if (expr instanceof StringLiteral) {
        String literalValue = ((StringLiteral) expr).getLiteralValue();
        if (literalValue.length() == 1) {
            CharacterLiteral charLiteral = ast.newCharacterLiteral();
            charLiteral.setCharValue(literalValue.charAt(0));
            return charLiteral;
        }
    }
    return expr;
}
项目:j2d    文件:J2dVisitor.java   
@Override
public boolean visit(CharacterLiteral node) {
    String chr = node.getEscapedValue();
    // It would seem a lot of the text manipulation stuff
    // in java uses invalid unicode characters, so we use
    // this hack to get around it.
    if (chr.startsWith("'\\u")) {
        chr = "0x" + chr.substring(3, chr.length() - 1);
    }
    print(chr);
    return false;
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(CharacterLiteral node) {
    // Leaf node.
}
项目:che    文件:InferTypeArgumentsConstraintCreator.java   
@Override
public void endVisit(CharacterLiteral node) {
  ITypeBinding typeBinding = node.resolveTypeBinding();
  ImmutableTypeVariable2 cv = fTCModel.makeImmutableTypeVariable(typeBinding, node);
  setConstraintVariable(node, cv);
}
项目:che    文件:SemanticHighlightingReconciler.java   
@Override
public boolean visit(CharacterLiteral node) {
  return visitLiteral(node);
}
项目:vsminecraft    文件:JavaElementLabelComposer.java   
private static String getEscapedCharacterLiteral(char ch) {
    CharacterLiteral characterLiteral= AST.newAST(AST.JLS8).newCharacterLiteral();
    characterLiteral.setCharValue(ch);
    return characterLiteral.getEscapedValue();
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public void endVisit(CharacterLiteral node) {
    logger.warn("Method endVisitCharacterLiteral for " + node + " for " + node + " not implemented!");
    super.endVisit(node);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public boolean visit(CharacterLiteral node) {
    logger.warn("Method visitCharacterLiteral for " + node + " for " + node + " not implemented!");
    return super.visit(node);
}
项目:Beagle    文件:NotRecursingAstVisitor.java   
@Override
public boolean visit(final CharacterLiteral node) {
    return false;
}
项目:Beagle    文件:InstrumentableAstNodeLister.java   
@Override
public boolean visit(final CharacterLiteral node) {
    // not instrumentable, contains no instrumentable nodes
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:InferTypeArgumentsConstraintCreator.java   
@Override
public void endVisit(CharacterLiteral node) {
    ITypeBinding typeBinding= node.resolveTypeBinding();
    ImmutableTypeVariable2 cv= fTCModel.makeImmutableTypeVariable(typeBinding, node);
    setConstraintVariable(node, cv);
}
项目:Eclipse-Postfix-Code-Completion    文件:FlowAnalyzer.java   
@Override
public void endVisit(CharacterLiteral node) {
    // Leaf node.
}
项目:Eclipse-Postfix-Code-Completion    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(CharacterLiteral node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:ConstraintCollector.java   
@Override
public boolean visit(CharacterLiteral node) {
    add(fCreator.create(node));
    return true;
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public void endVisit(CharacterLiteral node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public boolean visit(CharacterLiteral node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:SemanticHighlightingReconciler.java   
@Override
public boolean visit(CharacterLiteral node) {
    return visitLiteral(node);
}
项目:EASyProducer    文件:InvocationRemovalVisitor.java   
@Override
public boolean visit(MethodInvocation node) {
    IMethodBinding iMethod = (IMethodBinding) node.resolveMethodBinding();
    IMethodBinding methodDeclarationCandidate = iMethod.getMethodDeclaration();
    if (check(methodDeclarationCandidate)) {
        // Delete node with expression (i.e.: ClassName.methodname())
        if (null != node.getExpression()) {
            node.getParent().delete();
        } else {
            if (null != replacement) {
                if (node.getParent().getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
                    VariableDeclarationFragment fragment = (VariableDeclarationFragment) node.getParent();
                    Expression expression = null;
                    Type type = methodDeclaration.getReturnType2();
                    int exprType = determineType(type);
                    switch (exprType) {
                    case Expression.NUMBER_LITERAL:
                        expression = fragment.getAST().newNumberLiteral(String.valueOf(replacement));
                        break;
                    case Expression.STRING_LITERAL:
                        expression = fragment.getAST().newStringLiteral();
                        ((StringLiteral) expression).setLiteralValue(String.valueOf(replacement));
                        break;
                    case Expression.BOOLEAN_LITERAL:
                        expression = fragment.getAST().newBooleanLiteral(Boolean.valueOf(replacement.toString()));
                        break;
                    case Expression.CHARACTER_LITERAL:
                        expression = fragment.getAST().newCharacterLiteral();
                        String string = String.valueOf(replacement);
                        if (string.length() != 1) {
                            logger.warn(string + " contains more then one character. Cutting the string of at "
                                    + string.charAt(0));
                        }
                        char c = string.charAt(0);
                        ((CharacterLiteral) expression).setCharValue(Character.valueOf(c));
                        break;
                    case Expression.NULL_LITERAL:
                        expression = fragment.getAST().newNullLiteral();
                        break;
                    case Expression.TYPE_LITERAL:
                        expression = fragment.getAST().newTypeLiteral();
                        break;
                    default:
                        logger.error("Type '" + type + "' not supported yet...");
                        break;
                    }
                    if (expression != null) {
                        fragment.setInitializer(expression);
                    }
                }
            } else {
                node.delete();
            }
        }
        hasBeenDeleted = true;
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InferTypeArgumentsConstraintCreator.java   
@Override
public void endVisit(CharacterLiteral node) {
    ITypeBinding typeBinding= node.resolveTypeBinding();
    ImmutableTypeVariable2 cv= fTCModel.makeImmutableTypeVariable(typeBinding, node);
    setConstraintVariable(node, cv);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FlowAnalyzer.java   
@Override
public void endVisit(CharacterLiteral node) {
    // Leaf node.
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(CharacterLiteral node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ConstraintCollector.java   
@Override
public boolean visit(CharacterLiteral node) {
    add(fCreator.create(node));
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public boolean visit(CharacterLiteral node) {
    return visit((Expression)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public void endVisit(CharacterLiteral node) {
    endVisit((Expression)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTFlattener.java   
@Override
public boolean visit(CharacterLiteral node) {
    this.fBuffer.append(node.getEscapedValue());
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public boolean visit(CharacterLiteral node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public void endVisit(CharacterLiteral node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SemanticHighlightingReconciler.java   
@Override
public boolean visit(CharacterLiteral node) {
    return visitLiteral(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NaiveASTFlattener.java   
public boolean visit(CharacterLiteral node) {
    this.buffer.append(node.getEscapedValue());
    return false;
}
项目:eclipse-i18ntools    文件:ASTNodeFinder.java   
@Override
public boolean visit(final CharacterLiteral node) {
    return this.internalVisit(node);
}
项目:che    文件:ASTNodes.java   
/**
 * Escapes a character value to a literal that can be used in Java source.
 *
 * @param ch the character value
 * @return the escaped string
 * @see org.eclipse.jdt.core.dom.CharacterLiteral#getEscapedValue()
 */
public static String getEscapedCharacterLiteral(char ch) {
  CharacterLiteral characterLiteral =
      AST.newAST(ASTProvider.SHARED_AST_LEVEL).newCharacterLiteral();
  characterLiteral.setCharValue(ch);
  return characterLiteral.getEscapedValue();
}
项目:eclipse.jdt.ls    文件:ASTNodes.java   
/**
 * Escapes a character value to a literal that can be used in Java source.
 *
 * @param ch the character value
 * @return the escaped string
 * @see CharacterLiteral#getEscapedValue()
 */
public static String getEscapedCharacterLiteral(char ch) {
    CharacterLiteral characterLiteral= AST.newAST(IASTSharedValues.SHARED_AST_LEVEL).newCharacterLiteral();
    characterLiteral.setCharValue(ch);
    return characterLiteral.getEscapedValue();
}
项目:Eclipse-Postfix-Code-Completion    文件:ConstraintCreator.java   
/**
 * @param node the AST node
 * @return array of type constraints, may be empty
 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CharacterLiteral)
 */
public ITypeConstraint[] create(CharacterLiteral node) {
    return EMPTY_ARRAY;
}
项目:Eclipse-Postfix-Code-Completion    文件:ASTNodes.java   
/**
 * Escapes a character value to a literal that can be used in Java source.
 * 
 * @param ch the character value 
 * @return the escaped string
 * @see CharacterLiteral#getEscapedValue()
 */
public static String getEscapedCharacterLiteral(char ch) {
    CharacterLiteral characterLiteral= AST.newAST(ASTProvider.SHARED_AST_LEVEL).newCharacterLiteral();
    characterLiteral.setCharValue(ch);
    return characterLiteral.getEscapedValue();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ConstraintCreator.java   
/**
 * @param node the AST node
 * @return array of type constraints, may be empty
 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CharacterLiteral)
 */
public ITypeConstraint[] create(CharacterLiteral node) {
    return EMPTY_ARRAY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTNodes.java   
/**
 * Escapes a character value to a literal that can be used in Java source.
 * 
 * @param ch the character value 
 * @return the escaped string
 * @see CharacterLiteral#getEscapedValue()
 */
public static String getEscapedCharacterLiteral(char ch) {
    CharacterLiteral characterLiteral= AST.newAST(ASTProvider.SHARED_AST_LEVEL).newCharacterLiteral();
    characterLiteral.setCharValue(ch);
    return characterLiteral.getEscapedValue();
}