List of usage examples for org.eclipse.jdt.core.dom IMethodBinding isSynthetic
public boolean isSynthetic();
From source file:com.google.devtools.j2cpp.gen.CppImplementationGenerator.java
License:Open Source License
private void printStaticInterface(TypeDeclaration node) { // Print implementation for static constants, if any. boolean needsPrinting = false; List<MethodDeclaration> methods = Lists.newArrayList(node.getMethods()); for (MethodDeclaration m : methods) { if (isInterfaceConstantAccessor(Types.getMethodBinding(m))) { needsPrinting = true;// www. j a v a 2s .com break; } } if (needsPrinting) { printf("\n@implementation %s\n\n", NameTable.getFullName(node)); printStaticVars(Lists.newArrayList(node.getFields())); for (MethodDeclaration m : methods) { IMethodBinding binding = Types.getMethodBinding(m); if (binding.isSynthetic() || isInterfaceConstantAccessor(binding)) { printMethod(m); } } println("@end"); } }
From source file:com.google.devtools.j2cpp.types.GeneratedMethodBinding.java
License:Open Source License
/** * Clone a method binding, so parameters can be added to it. *//*from w ww . j a v a 2 s .c o m*/ public GeneratedMethodBinding(IMethodBinding m) { this(m.getName(), m.getModifiers(), m.getReturnType(), m.getDeclaringClass(), m.isConstructor(), m.isVarargs(), m.isSynthetic()); for (ITypeBinding paramType : m.getParameterTypes()) { parameters.add(new GeneratedVariableBinding(paramType, false, true, m.getDeclaringClass(), m)); } }
From source file:com.google.devtools.j2objc.gen.MetadataGenerator.java
License:Apache License
private String getMethodMetadata(IMethodBinding method) { if (method.isSynthetic()) { return null; }/*from w w w.j a v a 2 s . c o m*/ String methodName = method instanceof GeneratedMethodBinding ? ((GeneratedMethodBinding) method).getJavaName() : method.getName(); String selector = nameTable.getMethodSelector(method); if (selector.equals(methodName)) { methodName = null; // Reduce redundant data. } int modifiers = getMethodModifiers(method); String returnTypeStr = method.isConstructor() ? null : getTypeName(method.getReturnType()); return String.format(" { \"%s\", %s, %s, 0x%x, %s, %s },\n", selector, cStr(methodName), cStr(returnTypeStr), modifiers, cStr(getThrownExceptions(method)), cStr(SignatureGenerator.createMethodTypeSignature(method))); }
From source file:com.google.devtools.j2objc.gen.MetadataGenerator.java
License:Apache License
/** * Returns the modifiers for a specified method, including internal ones. * All method modifiers are defined in the JVM specification, table 4.5. */// w w w . j ava 2 s. c o m private static int getMethodModifiers(IMethodBinding type) { int modifiers = type.getModifiers(); if (type.isVarargs()) { modifiers |= BindingUtil.ACC_VARARGS; } if (type.isSynthetic()) { modifiers |= BindingUtil.ACC_SYNTHETIC; } return modifiers; }
From source file:org.autorefactor.refactoring.rules.ReplaceQualifiedNamesBySimpleNamesRefactoring.java
License:Open Source License
private void importStaticTypesAndMembersFromType(ImportDeclaration node) { final IBinding binding = node.resolveBinding(); if (binding == null) { return;//from ww w .j a v a 2 s . co m } if (binding.getKind() != TYPE) { throw new NotImplementedException(node, "for a binding of kind " + binding.getKind()); } final ITypeBinding typeBinding = (ITypeBinding) binding; final String typeName = typeBinding.getQualifiedName(); for (IMethodBinding method : typeBinding.getDeclaredMethods()) { if (canAdd(method.getModifiers(), method.isSynthetic())) { QName qname = QName.valueOf(typeName, method.getName()); methods.addName(FQN.fromImport(qname, true)); } } for (IVariableBinding field : typeBinding.getDeclaredFields()) { if (canAdd(field.getModifiers(), field.isSynthetic())) { QName qname = QName.valueOf(typeName, field.getName()); fields.addName(FQN.fromImport(qname, true)); } } for (ITypeBinding memberType : typeBinding.getDeclaredTypes()) { if (canAdd(memberType.getModifiers(), memberType.isSynthetic())) { QName qname = QName.valueOf(memberType.getQualifiedName()); types.addName(FQN.fromImport(qname, true)); } } }
From source file:org.eclipse.scout.sdk.saml.importer.internal.jdt.imports.ScopeAnalyzer.java
License:Open Source License
/** * Collects all elements available in a type and its hierarchy * //from ww w .ja v a 2 s. com * @param binding * The type binding * @param flags * Flags defining the elements to report * @param requestor * the requestor to which all results are reported * @return return <code>true</code> if the requestor has reported the binding as found and no further results are * required */ private boolean addInherited(ITypeBinding binding, int flags, IBindingRequestor requestor) { if (!fTypesVisited.add(binding)) { return false; } if (hasFlag(VARIABLES, flags)) { IVariableBinding[] variableBindings = binding.getDeclaredFields(); for (int i = 0; i < variableBindings.length; i++) { if (requestor.acceptBinding(variableBindings[i])) return true; } } if (hasFlag(METHODS, flags)) { IMethodBinding[] methodBindings = binding.getDeclaredMethods(); for (int i = 0; i < methodBindings.length; i++) { IMethodBinding curr = methodBindings[i]; if (!curr.isSynthetic() && !curr.isConstructor()) { if (requestor.acceptBinding(curr)) return true; } } } if (hasFlag(TYPES, flags)) { ITypeBinding[] typeBindings = binding.getDeclaredTypes(); for (int i = 0; i < typeBindings.length; i++) { ITypeBinding curr = typeBindings[i]; if (requestor.acceptBinding(curr)) return true; } } ITypeBinding superClass = binding.getSuperclass(); if (superClass != null) { if (addInherited(superClass, flags, requestor)) // recursive return true; } else if (binding.isArray()) { if (addInherited(fRoot.getAST().resolveWellKnownType("java.lang.Object"), flags, requestor)) //$NON-NLS-1$ return true; } ITypeBinding[] interfaces = binding.getInterfaces(); // includes looking for methods: abstract, unimplemented methods for (int i = 0; i < interfaces.length; i++) { if (addInherited(interfaces[i], flags, requestor)) // recursive return true; } return false; }
From source file:org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.java
License:Open Source License
/** * @since 2.4/* ww w . j ava 2s . c om*/ */ protected void createMethods(ITypeBinding typeBinding, String handleIdentifier, List<String> path, StringBuilder qualifiedName, JvmDeclaredType result) { resolveMembers.start(); IMethodBinding[] declaredMethods = typeBinding.getDeclaredMethods(); if (declaredMethods.length > 0) { int length = qualifiedName.length(); InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers(); String[] subpath = subpath(path); boolean intf = typeBinding.isInterface() && !typeBinding.isAnnotation(); for (IMethodBinding method : declaredMethods) { if (!method.isSynthetic() && !"<clinit>".equals(method.getName())) { if (method.isConstructor()) { members.addUnique(createConstructor(qualifiedName, handleIdentifier, subpath, method)); } else { JvmOperation operation = createOperation(qualifiedName, handleIdentifier, subpath, method); if (typeBinding.isAnnotation()) { setDefaultValue(operation, method); } else if (intf && !operation.isAbstract() && !operation.isStatic()) { operation.setDefault(true); } members.addUnique(operation); } qualifiedName.setLength(length); } } } resolveMembers.stop(); }
From source file:org.eclipselabs.nullness.NullnessAssertionInserter.java
License:Open Source License
private boolean isEffectivelySynthetic(IMethodBinding methodBinding) { return methodBinding.isSynthetic() || (Bindings.getInternalBinding(methodBinding) instanceof SyntheticMethodBinding); }
From source file:org.summer.dsl.model.types.access.jdt.JdtBasedTypeFactory.java
License:Open Source License
/** * @since 2.4//from www . j a v a 2s . co m */ protected void createMethods(ITypeBinding typeBinding, String handleIdentifier, List<String> path, StringBuilder qualifiedName, JvmDeclaredType result) { resolveMembers.start(); IMethodBinding[] declaredMethods = typeBinding.getDeclaredMethods(); if (declaredMethods.length > 0) { int length = qualifiedName.length(); InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers(); String[] subpath = subpath(path); for (IMethodBinding method : declaredMethods) { if (!method.isSynthetic() && !"<clinit>".equals(method.getName())) { if (method.isConstructor()) { members.addUnique(createConstructor(qualifiedName, handleIdentifier, subpath, method)); } else { JvmOperation operation = createOperation(qualifiedName, handleIdentifier, subpath, method); if (typeBinding.isAnnotation()) { setDefaultValue(operation, method); } members.addUnique(operation); } qualifiedName.setLength(length); } } } resolveMembers.stop(); }