List of usage examples for org.eclipse.jdt.core.dom PrimitiveType getPrimitiveTypeCode
public PrimitiveType.Code getPrimitiveTypeCode()
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(PrimitiveType node) { printTypeAnnotations(node);//from w w w . j av a2 s.c o m this.fBuffer.append(node.getPrimitiveTypeCode().toString()); return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
protected String typeName(final PrimitiveType t) { return t.getPrimitiveTypeCode().toString(); }
From source file:chibi.gumtreediff.gen.jdt.cd.CdJdtVisitor.java
License:Open Source License
@Override public boolean visit(PrimitiveType node) { String vName = ""; if (fInMethodDeclaration) { vName += getCurrentParent().getLabel() + COLON_SPACE; }//from w ww . j ava 2s . c o m pushNode(node, vName + node.getPrimitiveTypeCode().toString()); return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(PrimitiveType node) { this.buffer.append(node.getPrimitiveTypeCode().toString()); return false; }
From source file:com.google.devtools.j2cpp.util.NameTable.java
License:Open Source License
/** * Return the Objective-C equivalent name for a Java primitive type. *//*from www . j av a2 s . co m*/ public static String primitiveTypeToCpp(PrimitiveType type) { PrimitiveType.Code code = type.getPrimitiveTypeCode(); return primitiveTypeToCpp(code.toString()); }
From source file:com.google.devtools.j2objc.translate.ASTFactoryTest.java
License:Apache License
public void testNewPrimitiveType() throws IOException { ITypeBinding binding = ast.resolveWellKnownType("int"); Type type = ASTFactory.newType(ast, binding); assertTrue(type instanceof PrimitiveType); PrimitiveType primitiveType = (PrimitiveType) type; assertEquals(PrimitiveType.INT, primitiveType.getPrimitiveTypeCode()); }
From source file:com.google.devtools.j2objc.types.TypesTest.java
License:Open Source License
public void testMakePrimitiveType() throws IOException { ITypeBinding binding = ast.resolveWellKnownType("int"); Type type = Types.makeType(binding); assertTrue(type instanceof PrimitiveType); PrimitiveType primitiveType = (PrimitiveType) type; assertEquals(PrimitiveType.INT, primitiveType.getPrimitiveTypeCode()); }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java
License:Open Source License
public static String asString(Type type) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; return asString(arrayType.getComponentType()) + "[]"; }// w w w . j a va 2s . c o m if (type.isParameterizedType()) { ParameterizedType parameterizedType = (ParameterizedType) type; List<Type> typeArguments = Generics.asT(parameterizedType.typeArguments()); class TypeToString implements ClosureUtil.IClosure<Type, String> { public String eval(Type type) { return asString(type); } } return asString(parameterizedType.getType()) + "<" + StringUtil.join(ClosureUtil.forEach(typeArguments, new TypeToString()), ", ") + ">"; } if (type.isPrimitiveType()) { PrimitiveType primitiveType = (PrimitiveType) type; return primitiveType.getPrimitiveTypeCode().toString(); } if (type.isQualifiedType()) { QualifiedType qualifiedType = (QualifiedType) type; return qualifiedType.getName().getFullyQualifiedName(); } if (type.isSimpleType()) { SimpleType simpleType = (SimpleType) type; return simpleType.getName().getFullyQualifiedName(); } if (type.isWildcardType()) { WildcardType wildcardType = (WildcardType) type; Type boundType = wildcardType.getBound(); if (boundType != null) { if (wildcardType.isUpperBound()) { return "? extends " + asString(boundType); } else { return "? super " + asString(boundType); } } else { return "?"; } } return "(unknown type)"; }
From source file:com.motorola.studio.android.model.java.JavaClass.java
License:Apache License
/** * Adds an empty block to a method declaration * /*ww w . j av a 2 s. c o m*/ * @param method The method declaration * @param returnType The method return type. If the method does not have one, use null */ @SuppressWarnings("unchecked") protected void addEmptyBlock(MethodDeclaration method) { Expression expression = null; Block emptyBlock = ast.newBlock(); ReturnStatement returnStatement = ast.newReturnStatement(); Type returnType = method.getReturnType2(); if (returnType instanceof PrimitiveType) { PrimitiveType pType = (PrimitiveType) returnType; if (pType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) { expression = ast.newBooleanLiteral(false); } else if (pType.getPrimitiveTypeCode() != PrimitiveType.VOID) { expression = ast.newNumberLiteral("0"); } } else { expression = ast.newNullLiteral(); } if (expression != null) { returnStatement.setExpression(expression); emptyBlock.statements().add(returnStatement); } method.setBody(emptyBlock); }
From source file:com.tsc9526.monalisa.plugin.eclipse.generator.ParameterInitialization.java
License:Open Source License
private String getInitParameters(Type t, String v) { Code code = PrimitiveType.VOID; String initValue = null;/*from w w w . j ava2 s . co m*/ if (t.isPrimitiveType()) { PrimitiveType pt = (PrimitiveType) t; code = pt.getPrimitiveTypeCode(); initValue = primitiveCodeInit.get(code); } else if (t.isSimpleType()) { String name = ((SimpleType) t).getName().toString(); if (name.startsWith("java.lang.")) { name = name.substring(10); } code = primitiveShortNameToCode.get(name); initValue = primitiveCodeInit.get(code); if (initValue == null) { ITypeBinding bind = t.resolveBinding(); String xs = objectParameters.get(bind.getBinaryName()); if (xs != null) { initValue = "new " + xs + "()"; } else if (bind.isClass()) { initValue = " new " + t + "()"; } else { //interface, enum ... } } } else if (t.isArrayType()) { initValue = "new " + t + "{}"; } else { ITypeBinding bind = t.resolveBinding(); String xs = objectParameters.get(bind.getBinaryName()); if (xs != null) { initValue = "new " + xs + "()"; } else if (bind.isClass()) { initValue = " new " + t + "()"; } } return initValue; }