List of usage examples for org.eclipse.jdt.core.dom StringLiteral getEscapedValue
public String getEscapedValue()
From source file:astview.Binding.java
License:Open Source License
public static String getEscapedStringLiteral(String stringValue) { StringLiteral stringLiteral = AST.newAST(8).newStringLiteral(); stringLiteral.setLiteralValue(stringValue); return stringLiteral.getEscapedValue(); }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(StringLiteral node) { this.fBuffer.append(node.getEscapedValue()); return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
@Override public boolean visit(StringLiteral node) { boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder(); // b.setPosition(pos.build()); b.setKind(boa.types.Ast.Expression.ExpressionKind.LITERAL); b.setLiteral(node.getEscapedValue()); expressions.push(b.build());// w ww . j a va2 s.c o m return false; }
From source file:ch.acanda.eclipse.pmd.java.resolution.optimization.SimplifyStartsWithQuickFix.java
License:Open Source License
/** * Rewrites <code>s.startsWith("a")</code> as <code>s.charAt(0) == 'a'</code>. *///from w w w. j a v a 2 s . co m @Override @SuppressWarnings("unchecked") protected boolean apply(final MethodInvocation node) { final AST ast = node.getAST(); final MethodInvocation charAt = ast.newMethodInvocation(); charAt.setExpression(copy(node.getExpression())); charAt.setName(ast.newSimpleName("charAt")); charAt.arguments().add(ast.newNumberLiteral("0")); final CharacterLiteral character = ast.newCharacterLiteral(); final StringLiteral s = (StringLiteral) node.arguments().get(0); character.setEscapedValue(s.getEscapedValue().replace('"', '\'')); final InfixExpression eq = ast.newInfixExpression(); eq.setOperator(Operator.EQUALS); eq.setLeftOperand(charAt); eq.setRightOperand(character); replace(node, eq); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.stringandstringbuffer.AppendCharacterWithCharQuickFix.java
License:Open Source License
/** * Replaces the string literal <code>"a"</code> in <code>buffer.append("a")</code> with the character literal * <code>'a'</code>.//from w ww . j av a2s.co m */ @Override protected boolean apply(final StringLiteral node) { final CharacterLiteral character = node.getAST().newCharacterLiteral(); character.setEscapedValue(toCharValue(node.getEscapedValue())); replace(node, character); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.stringandstringbuffer.UseIndexOfCharQuickFix.java
License:Open Source License
/** * Replaces the string literal <code>"a"</code> in <code>s.indexOf("a")</code> with the character literal * <code>'a'</code>./*from ww w .j a va 2 s.co m*/ */ @Override protected boolean apply(final MethodInvocation node) { @SuppressWarnings("unchecked") final List<Expression> arguments = node.arguments(); if (arguments.size() == 1 && arguments.get(0) instanceof StringLiteral) { final CharacterLiteral character = node.getAST().newCharacterLiteral(); final StringLiteral string = (StringLiteral) arguments.get(0); character.setEscapedValue(toCharValue(string.getEscapedValue())); replace(string, character); return true; } return false; }
From source file:cideplus.ui.astview.Binding.java
License:Open Source License
public static String getEscapedStringLiteral(String stringValue) { StringLiteral stringLiteral = AST.newAST(AST.JLS3).newStringLiteral(); stringLiteral.setLiteralValue(stringValue); return stringLiteral.getEscapedValue(); }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(StringLiteral node) { this.buffer.append(node.getEscapedValue()); return false; }
From source file:com.google.dart.java2dart.SyntaxTranslator.java
License:Open Source License
@Override public boolean visit(org.eclipse.jdt.core.dom.StringLiteral node) { String tokenValue = node.getEscapedValue(); tokenValue = StringUtils.replace(tokenValue, "$", "\\$"); SimpleStringLiteral literal = new SimpleStringLiteral(token(TokenType.STRING, tokenValue), node.getLiteralValue());//from w ww .ja va 2 s.co m context.putNodeTypeBinding(literal, node.resolveTypeBinding()); return done(literal); }
From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java
License:Open Source License
@Override public boolean visit(StringLiteral node) { if (isValidCppString(node)) { buffer.append('@'); buffer.append(UnicodeUtils.escapeUnicodeSequences(node.getEscapedValue())); } else {//from w ww. ja v a2s . com buffer.append(buildStringFromChars(node.getLiteralValue())); } return false; }