本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.isAnonymous方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.isAnonymous方法的具體用法?Java ITypeBinding.isAnonymous怎麽用?Java ITypeBinding.isAnonymous使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.isAnonymous方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
static void createName(ITypeBinding type, boolean includePackage,
List<String> list) {
ITypeBinding baseType = type;
if (type.isArray()) {
baseType = type.getElementType();
}
if (!baseType.isPrimitive() && !baseType.isNullType()) {
ITypeBinding declaringType = baseType.getDeclaringClass();
if (declaringType != null) {
createName(declaringType, includePackage, list);
} else if (includePackage && !baseType.getPackage().isUnnamed()) {
String[] components = baseType.getPackage().getNameComponents();
for (int i = 0; i < components.length; i++) {
list.add(components[i]);
}
}
}
if (!baseType.isAnonymous()) {
list.add(type.getName());
} else {
list.add("$local$"); //$NON-NLS-1$
}
}
示例2: createName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void createName(ITypeBinding type, boolean includePackage, List<String> list) {
ITypeBinding baseType= type;
if (type.isArray()) {
baseType= type.getElementType();
}
if (!baseType.isPrimitive() && !baseType.isNullType()) {
ITypeBinding declaringType= baseType.getDeclaringClass();
if (declaringType != null) {
createName(declaringType, includePackage, list);
} else if (includePackage && !baseType.getPackage().isUnnamed()) {
String[] components= baseType.getPackage().getNameComponents();
for (int i= 0; i < components.length; i++) {
list.add(components[i]);
}
}
}
if (!baseType.isAnonymous()) {
list.add(type.getName());
} else {
list.add("$local$"); //$NON-NLS-1$
}
}
示例3: normalizeTypeBinding
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Normalizes a type binding received from an expression to a type binding that can be used inside a
* declaration signature, but <em>not</em> as type of a declaration (use {@link #normalizeForDeclarationUse(ITypeBinding, AST)} for that).
* <p>
* Anonymous types are normalized to the super class or interface. For
* null or void bindings, <code>null</code> is returned.
* </p>
*
* @param binding the binding to normalize
* @return the normalized binding, can be <code>null</code>
*
* @see #normalizeForDeclarationUse(ITypeBinding, AST)
*/
public static ITypeBinding normalizeTypeBinding(ITypeBinding binding) {
if (binding != null && !binding.isNullType() && !isVoidType(binding)) {
if (binding.isAnonymous()) {
ITypeBinding[] baseBindings= binding.getInterfaces();
if (baseBindings.length > 0) {
return baseBindings[0];
}
return binding.getSuperclass();
}
if (binding.isCapture()) {
return binding.getWildcard();
}
return binding;
}
return null;
}
示例4: getSimpleName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static String getSimpleName(ITypeBinding itb) {
if (itb.isNested()) {
if (itb.isAnonymous()) {
String binname = itb.getBinaryName();
int index = binname.indexOf('$');
String name = binname.substring(index + 1, binname.length());
return getSimpleName(itb.getDeclaringClass()) + "#" + name;
} else {
return getSimpleName(itb.getDeclaringClass()) + "#"
+ itb.getName();
}
} else {
return itb.getName();
}
}
示例5: addNewFieldProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addNewFieldProposals(ICompilationUnit cu, CompilationUnit astRoot, ITypeBinding binding,
ITypeBinding declaringTypeBinding, SimpleName simpleName, boolean isWriteAccess,
Collection<CUCorrectionProposal> proposals) throws JavaModelException {
// new variables
ICompilationUnit targetCU;
ITypeBinding senderDeclBinding;
if (binding != null) {
senderDeclBinding= binding.getTypeDeclaration();
targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, senderDeclBinding);
} else { // binding is null for accesses without qualifier
senderDeclBinding= declaringTypeBinding;
targetCU= cu;
}
if (!senderDeclBinding.isFromSource() || targetCU == null) {
return;
}
boolean mustBeConst= ASTResolving.isInsideModifiers(simpleName);
addNewFieldForType(targetCU, binding, senderDeclBinding, simpleName, isWriteAccess, mustBeConst, proposals);
if (binding == null && senderDeclBinding.isNested()) {
ASTNode anonymDecl= astRoot.findDeclaringNode(senderDeclBinding);
if (anonymDecl != null) {
ITypeBinding bind= Bindings.getBindingOfParentType(anonymDecl.getParent());
if (!bind.isAnonymous()) {
addNewFieldForType(targetCU, bind, bind, simpleName, isWriteAccess, mustBeConst, proposals);
}
}
}
}
示例6: addNewFieldForType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding,
ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst,
Collection<CUCorrectionProposal> proposals) {
String name= simpleName.getIdentifier();
String nameLabel= BasicElementLabels.getJavaElementName(name);
String label;
if (senderDeclBinding.isEnum() && !isWriteAccess) {
label = Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST,
simpleName, senderDeclBinding, 10));
} else {
if (!mustBeConst) {
if (binding == null) {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
} else {
label = Messages.format(
CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
}
int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_FIELD_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_FIELD;
proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD,
simpleName, senderDeclBinding, fieldRelevance));
}
if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
if (binding == null) {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
} else {
label = Messages.format(
CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description,
new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
}
int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_CONSTANT_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_CONSTANT;
proposals.add(new NewVariableCorrectionProposal(label, targetCU,
NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance));
}
}
}
示例7: addNewMethodProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addNewMethodProposals(ICompilationUnit cu, CompilationUnit astRoot, Expression sender,
List<Expression> arguments, boolean isSuperInvocation, ASTNode invocationNode, String methodName,
Collection<CUCorrectionProposal> proposals) throws JavaModelException {
ITypeBinding nodeParentType= Bindings.getBindingOfParentType(invocationNode);
ITypeBinding binding= null;
if (sender != null) {
binding= sender.resolveTypeBinding();
} else {
binding= nodeParentType;
if (isSuperInvocation && binding != null) {
binding= binding.getSuperclass();
}
}
if (binding != null && binding.isFromSource()) {
ITypeBinding senderDeclBinding= binding.getTypeDeclaration();
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, senderDeclBinding);
if (targetCU != null) {
String label;
ITypeBinding[] parameterTypes= getParameterTypes(arguments);
if (parameterTypes != null) {
String sig = ASTResolving.getMethodSignature(methodName, parameterTypes, false);
boolean is18OrHigher= JavaModelUtil.is18OrHigher(targetCU.getJavaProject());
boolean isSenderBindingInterface= senderDeclBinding.isInterface();
if (nodeParentType == senderDeclBinding) {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_description, sig);
} else {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_other_description, new Object[] { sig, BasicElementLabels.getJavaElementName(senderDeclBinding.getName()) } );
}
if (is18OrHigher || !isSenderBindingInterface
|| (nodeParentType != senderDeclBinding && (!(sender instanceof SimpleName) || !((SimpleName) sender).getIdentifier().equals(senderDeclBinding.getName())))) {
proposals.add(new NewMethodCorrectionProposal(label, targetCU, invocationNode, arguments,
senderDeclBinding, IProposalRelevance.CREATE_METHOD));
}
if (senderDeclBinding.isNested() && cu.equals(targetCU) && sender == null && Bindings.findMethodInHierarchy(senderDeclBinding, methodName, (ITypeBinding[]) null) == null) { // no covering method
ASTNode anonymDecl= astRoot.findDeclaringNode(senderDeclBinding);
if (anonymDecl != null) {
senderDeclBinding= Bindings.getBindingOfParentType(anonymDecl.getParent());
isSenderBindingInterface= senderDeclBinding.isInterface();
if (!senderDeclBinding.isAnonymous()) {
if (is18OrHigher || !isSenderBindingInterface) {
String[] args = new String[] { sig,
ASTResolving.getTypeSignature(senderDeclBinding) };
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createmethod_other_description, args);
proposals.add(new NewMethodCorrectionProposal(label, targetCU, invocationNode,
arguments, senderDeclBinding, IProposalRelevance.CREATE_METHOD));
}
}
}
}
}
}
}
}