本文整理汇总了Java中org.eclipse.jdt.core.dom.CharacterLiteral.setCharValue方法的典型用法代码示例。如果您正苦于以下问题:Java CharacterLiteral.setCharValue方法的具体用法?Java CharacterLiteral.setCharValue怎么用?Java CharacterLiteral.setCharValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.CharacterLiteral
的用法示例。
在下文中一共展示了CharacterLiteral.setCharValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: repairBug
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
@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);
}
}
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:24,代码来源:UseCharacterParameterizedMethodResolution.java
示例2: fixSingleLengthString
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
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;
}
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:12,代码来源:UseCharacterParameterizedMethodResolution.java
示例3: getEscapedCharacterLiteral
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
private static String getEscapedCharacterLiteral(char ch) {
CharacterLiteral characterLiteral= AST.newAST(AST.JLS8).newCharacterLiteral();
characterLiteral.setCharValue(ch);
return characterLiteral.getEscapedValue();
}
示例4: getEscapedCharacterLiteral
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
/**
* 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();
}
示例5: getEscapedCharacterLiteral
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
/**
* 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();
}
示例6: getEscapedCharacterLiteral
import org.eclipse.jdt.core.dom.CharacterLiteral; //导入方法依赖的package包/类
/**
* 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();
}