Codota Logo
CtLiteral.setType
Code IndexAdd Codota to your IDE (free)

How to use
setType
method
in
spoon.reflect.code.CtLiteral

Best Java code snippets using spoon.reflect.code.CtLiteral.setType (Showing top 6 results out of 315)

  • Common ways to obtain CtLiteral
private void myMethod () {
CtLiteral c =
  • Codota IconCtLiteral ctLiteral;Object value;ctLiteral.setValue(value)
  • Smart code suggestions by Codota
}
origin: INRIA/spoon

/**
 * Creates a literal with a given value.
 *
 * @param <T>
 *         the type of the literal
 * @param value
 *         the value of the literal
 * @return a new literal
 */
public <T> CtLiteral<T> createLiteral(T value) {
  CtLiteral<T> literal = factory.Core().<T>createLiteral();
  literal.setValue(value);
  if (value != null) {
    literal.setType((CtTypeReference<T>) factory.Type().<T>createReference((Class<T>) value.getClass()).unbox());
  } else {
    literal.setType((CtTypeReference<T>) factory.Type().nullType());
  }
  return literal;
}
origin: INRIA/spoon

public <T> void visitCtLiteral(final spoon.reflect.code.CtLiteral<T> literal) {
  spoon.reflect.code.CtLiteral<T> aCtLiteral = literal.getFactory().Core().createLiteral();
  this.builder.copy(literal, aCtLiteral);
  aCtLiteral.setAnnotations(this.cloneHelper.clone(literal.getAnnotations()));
  aCtLiteral.setType(this.cloneHelper.clone(literal.getType()));
  aCtLiteral.setTypeCasts(this.cloneHelper.clone(literal.getTypeCasts()));
  aCtLiteral.setComments(this.cloneHelper.clone(literal.getComments()));
  this.cloneHelper.tailor(literal, aCtLiteral);
  this.other = aCtLiteral;
}
origin: net.openhft/spoon-core

@Override
public boolean visit(LongLiteral longLiteral, BlockScope scope) {
  CtLiteral<Long> l = factory.Core().createLiteral();
  l.setValue(longLiteral.constant.longValue());
  CtTypeReference<Long> r = references.getTypeReference(longLiteral.resolvedType);
  l.setType(r);
  context.enter(l, longLiteral);
  return true;
}
origin: net.openhft/spoon-core

@Override
public boolean visit(IntLiteral intLiteral, BlockScope scope) {
  CtLiteral<Integer> l = factory.Core().createLiteral();
  CtTypeReference<Integer> r = references.getTypeReference(intLiteral.resolvedType);
  l.setType(r);
  if (intLiteral.constant != null) { // check required for noclasspath mode
    l.setValue(intLiteral.constant.intValue());
  }
  context.enter(l, intLiteral);
  return true;
}
origin: net.openhft/spoon-core

@Override
public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
  CtLiteral<Object> lit = factory.Core().createLiteral();
  CtTypeReference<Object> ref = factory.Core().createTypeReference();
  ref.setSimpleName(CtTypeReference.NULL_TYPE_NAME);
  lit.setType(ref);
  context.enter(lit, nullLiteral);
  return true;
}
origin: net.openhft/spoon-core

@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);
  return true;
}
spoon.reflect.codeCtLiteralsetType

Popular methods of CtLiteral

  • getValue
    Gets the actual value of the literal (statically known).
  • setValue
    Sets the actual value of the literal.
  • getType
  • getTypeCasts
  • replace
  • getAnnotations
  • getFactory
  • getParent
  • setFactory
  • setTypeCasts
  • addTypeCast
  • clone
  • addTypeCast,
  • clone,
  • getComments,
  • getPosition,
  • setAnnotations,
  • setComments

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now