List of usage examples for org.eclipse.jdt.core.dom SimpleName IDENTIFIER_PROPERTY
SimplePropertyDescriptor IDENTIFIER_PROPERTY
To view the source code for org.eclipse.jdt.core.dom SimpleName IDENTIFIER_PROPERTY.
Click Source Link
From source file:com.google.devtools.j2cpp.util.NameTable.java
License:Open Source License
/** * Returns a SimpleName for an identifier that may not be a legal * Java identifier but is for iOS. For example, JDT doesn't allow * Java keywords such as "class" to be used as names. *///from w w w . j a va 2 s . c om public static SimpleName unsafeSimpleName(String identifier, AST ast) { SimpleName name = ast.newSimpleName("foo"); try { Field field = SimpleName.class.getDeclaredField("identifier"); field.setAccessible(true); Class<?>[] argTypes = new Class[] { SimplePropertyDescriptor.class }; Object[] args = new Object[] { SimpleName.IDENTIFIER_PROPERTY }; Method preValueChange = ASTNode.class.getDeclaredMethod("preValueChange", argTypes); Method postValueChange = ASTNode.class.getDeclaredMethod("postValueChange", argTypes); preValueChange.setAccessible(true); postValueChange.setAccessible(true); preValueChange.invoke(name, args); field.set(name, identifier); postValueChange.invoke(name, args); } catch (Exception e) { // should never happen, since only the one known class is manipulated e.printStackTrace(); System.exit(1); } return name; }
From source file:org.moe.natjgen.FieldEditor.java
License:Apache License
public String getName() { SimpleName name = (SimpleName) getRewrite().get(getFirstFragment(), VariableDeclarationFragment.NAME_PROPERTY); if (name != null) { return (String) getRewrite().get(name, SimpleName.IDENTIFIER_PROPERTY); }//w w w . j ava 2s .c om return null; }
From source file:org.moe.natjgen.InitializerEditor.java
License:Apache License
@SuppressWarnings("unchecked") public boolean hasNatJRegister() { Block block = (Block) getRewrite().get(decl, Initializer.BODY_PROPERTY); if (block == null) { return false; }/*from ww w . ja v a 2s . c o m*/ ListRewrite block_stmts = getRewrite().getListRewrite(block, Block.STATEMENTS_PROPERTY); for (Statement stmt : (List<Statement>) block_stmts.getRewrittenList()) { if (stmt instanceof ExpressionStatement) { Expression expr = (Expression) getRewrite().get(stmt, ExpressionStatement.EXPRESSION_PROPERTY); if (expr instanceof MethodInvocation) { Expression cls = (Expression) getRewrite().get(expr, MethodInvocation.EXPRESSION_PROPERTY); if (!(cls instanceof SimpleName)) { continue; } String identifier = (String) getRewrite().get(cls, SimpleName.IDENTIFIER_PROPERTY); if (!identifier.equals(Constants.NatJ) && !identifier.equals(Constants.NatJFQ)) { continue; } SimpleName method = (SimpleName) getRewrite().get(expr, MethodInvocation.NAME_PROPERTY); String methodId = (String) getRewrite().get(method, SimpleName.IDENTIFIER_PROPERTY); if (methodId.equals(Constants.NatJRegisterMethod)) { return true; } } } } return false; }
From source file:org.moe.natjgen.MethodEditor.java
License:Apache License
public String getName() { SimpleName name = (SimpleName) getRewrite().get(methodDecl, MethodDeclaration.NAME_PROPERTY); if (name != null) { return (String) getRewrite().get(name, SimpleName.IDENTIFIER_PROPERTY); }//w w w . j a v a2s. com return null; }