Example usage for org.eclipse.jdt.internal.compiler.ast StringLiteral source

List of usage examples for org.eclipse.jdt.internal.compiler.ast StringLiteral source

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast StringLiteral source.

Prototype

null source

To view the source code for org.eclipse.jdt.internal.compiler.ast StringLiteral source.

Click Source Link

Usage

From source file:org.nabucco.framework.generator.compiler.transformation.java.service.NabuccoToJavaServiceLocatorVisitor.java

License:Open Source License

/**
 * Modify the logger field./*from w w w .  j  a  va 2 s. c om*/
 * 
 * @param serviceName
 *            the service name
 * @param type
 *            the java type
 * 
 * @throws JavaModelException
 */
private void jndi(String serviceName, TypeDeclaration type) throws JavaModelException {
    JavaAstElementFactory javaFactory = JavaAstElementFactory.getInstance();
    JavaAstModelProducer producer = JavaAstModelProducer.getInstance();

    FieldDeclaration jndi = javaFactory.getJavaAstType().getField(type, FIELD_JNDI);
    StringLiteral literal = (StringLiteral) jndi.initialization;

    String serviceImport = super.resolveImport(serviceName);
    String componentName = NabuccoCompilerSupport.getParentComponentName(serviceImport);
    String jndiName = MessageFormat.format(new String(literal.source()), componentName, serviceImport);

    jndi.initialization = producer.createLiteral(jndiName, LiteralType.STRING_LITERAL);
}

From source file:org.nabucco.framework.mda.template.java.extract.statement.JavaAstStatementExtractorVisitor.java

License:Open Source License

@Override
public boolean visit(StringLiteral stringLiteral, BlockScope scope) {

    StringLiteral stringCopy = new StringLiteral(stringLiteral.source().clone(), stringLiteral.sourceStart,
            stringLiteral.sourceEnd, 0);

    this.statement = stringCopy;

    return false;
}

From source file:spoon.support.builder.JDTTreeBuilder.java

License:Open Source License

@Override
public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
    CtLiteral<String> s = factory.Core().createLiteral();
    // references.getTypeReference(stringLiteral.resolvedType) can be null
    s.setType(factory.Type().createReference(String.class));
    s.setValue(new String(stringLiteral.source()));
    context.enter(s, stringLiteral);//from  ww  w. java2  s .  c o  m
    return true;
}

From source file:spoon.support.compiler.jdt.JDTTreeBuilder.java

License:Open Source License

@Override
public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
    CtLiteral<String> s = factory.Core().createLiteral();
    // references.getTypeReference(stringLiteral.resolvedType) can be null
    s.setType(factory.Type().createReference(String.class));

    // there are two methods in JDT: source() and toString()
    // source() seems better but actually does not return the real source
    // (for instance \n are not \n but newline)
    // toString seems better (see StringLiteralTest)
    // here there is a contract between JDTTreeBuilder and
    // DefaultJavaPrettyPrinter:
    // JDTTreeBuilder si responsible for adding the double quotes
    // s.setValue(new String(stringLiteral.toString()));

    // RP: this is not a good idea but many other usages of the value can be
    // done (apart from the pretty printer). So I moved back the
    // responsibility of pretty printing the string inside the pretty
    // printer (i.e. where it belongs)
    s.setValue(new String(stringLiteral.source()));

    context.enter(s, stringLiteral);/*from w w  w .  j  ava2  s. c  o m*/
    return true;
}