本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getDeclaringClass方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getDeclaringClass方法的具體用法?Java ITypeBinding.getDeclaringClass怎麽用?Java ITypeBinding.getDeclaringClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getDeclaringClass方法的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: getTopLevelType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static ITypeBinding getTopLevelType(ITypeBinding type) {
ITypeBinding parent= type.getDeclaringClass();
while (parent != null) {
type= parent;
parent= type.getDeclaringClass();
}
return type;
}
示例4: findNullnessDefault
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Answer the annotation binding representing a nullness default
* effective at the point denoted by 'contextBinding'.
* @param contextBinding method binding or type binding denoting the location of interest
* @param javaProject the containing java project, consulted for the actual name of
* the annotation used for nullness defaults (default: <code>@NonNullByDefault</code>).
* @return binding for the effective nullness default annotation
* or null if no nullness default is effective at the context location.
*/
public static IAnnotationBinding findNullnessDefault(IBinding contextBinding, IJavaProject javaProject) {
if (JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true))) {
String annotationName= javaProject.getOption(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, true);
while (contextBinding != null) {
for (IAnnotationBinding annotation : contextBinding.getAnnotations()) {
ITypeBinding annotationType= annotation.getAnnotationType();
if (annotationType != null && annotationType.getQualifiedName().equals(annotationName)) {
return annotation;
}
}
// travel out:
switch (contextBinding.getKind()) {
case IBinding.METHOD:
IMethodBinding methodBinding= (IMethodBinding) contextBinding;
contextBinding= methodBinding.getDeclaringMember();
if (contextBinding == null) {
contextBinding= methodBinding.getDeclaringClass();
}
break;
case IBinding.VARIABLE:
IVariableBinding variableBinding= (IVariableBinding) contextBinding;
contextBinding= variableBinding.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= variableBinding.getDeclaringClass();
}
break;
case IBinding.TYPE:
ITypeBinding currentClass= (ITypeBinding) contextBinding;
contextBinding= currentClass.getDeclaringMember();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringClass();
if (contextBinding == null) {
contextBinding= currentClass.getPackage();
}
}
}
break;
default:
contextBinding= null;
break;
}
}
}
return null;
}
示例5: addQualifierToOuterProposal
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addQualifierToOuterProposal(IInvocationContext context, MethodInvocation invocationNode,
IMethodBinding binding, Collection<CUCorrectionProposal> proposals) {
ITypeBinding declaringType= binding.getDeclaringClass();
ITypeBinding parentType= Bindings.getBindingOfParentType(invocationNode);
ITypeBinding currType= parentType;
boolean isInstanceMethod= !Modifier.isStatic(binding.getModifiers());
while (currType != null && !Bindings.isSuperType(declaringType, currType)) {
if (isInstanceMethod && Modifier.isStatic(currType.getModifiers())) {
return;
}
currType= currType.getDeclaringClass();
}
if (currType == null || currType == parentType) {
return;
}
ASTRewrite rewrite= ASTRewrite.create(invocationNode.getAST());
String label = Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_changetoouter_description,
ASTResolving.getTypeSignature(currType));
ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(),
rewrite, IProposalRelevance.QUALIFY_WITH_ENCLOSING_TYPE);
ImportRewrite imports= proposal.createImportRewrite(context.getASTRoot());
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(invocationNode, imports);
AST ast= invocationNode.getAST();
String qualifier= imports.addImport(currType, importRewriteContext);
Name name= ASTNodeFactory.newName(ast, qualifier);
Expression newExpression;
if (isInstanceMethod) {
ThisExpression expr= ast.newThisExpression();
expr.setQualifier(name);
newExpression= expr;
} else {
newExpression= name;
}
rewrite.set(invocationNode, MethodInvocation.EXPRESSION_PROPERTY, newExpression, null);
proposals.add(proposal);
}
示例6: getDomainParamsDecl
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* return declared domain parameters includes OWNER!
*/
public static List<DomainParams> getDomainParamsDecl(ITypeBinding tb, AnnotationDatabase annoDB) {
if (tb.isNested()) {
ITypeBinding declaringClass = tb.getDeclaringClass();
return getDomainParamsDecl(declaringClass, annoDB);
}
List<DomainParams> result = new ArrayList<DomainParams>();
result.add(DomainParams.create(Constants.OWNER));
List<ICrystalAnnotation> annots = annoDB.getAnnosForType(tb);
if (annots == null || annots.isEmpty()) {
// Try to load XML Loader.
String key = tb.getErasure().getKey();
TypeAnnotationInfo typeDecl = TypeAnnotationInfo.getBinding(key);
if (typeDecl != null) {
for (String domParam : typeDecl.getParameters()) {
result.add(DomainParams.create(domParam));
}
return result;
}
}
for (ICrystalAnnotation iCrystalAnnotation : annots) {
if (iCrystalAnnotation.getName().endsWith(Constants.DOMAIN_PARAMS)) {
Object[] annot = (Object[]) iCrystalAnnotation.getObject("value");
for (int i = 0; i < annot.length; i++) {
result.add(DomainParams.create((String) annot[i]));
}
return result;
}
}
return result;
}
示例7: getDomainParamsDecl2
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<String> getDomainParamsDecl2(ITypeBinding tb, AnnotationDatabase annoDB) {
if (tb.isNested()) {
ITypeBinding declaringClass = tb.getDeclaringClass();
return getDomainParamsDecl2(declaringClass, annoDB);
}
List<String> result = new ArrayList<String>();
result.add(Constants.OWNER);
List<ICrystalAnnotation> annots = annoDB.getAnnosForType(tb);
if (annots == null || annots.isEmpty()) {
// Try to load XML Loader.
String key = tb.getErasure().getKey();
TypeAnnotationInfo typeDecl = TypeAnnotationInfo.getBinding(key);
if (typeDecl != null) {
for (String domParam : typeDecl.getParameters()) {
result.add(domParam);
}
return result;
}
}
for (ICrystalAnnotation iCrystalAnnotation : annots) {
if (iCrystalAnnotation.getName().endsWith(Constants.DOMAIN_PARAMS)) {
Object[] annot = (Object[]) iCrystalAnnotation.getObject("value");
for (int i = 0; i < annot.length; i++) {
result.add((String) annot[i]);
}
return result;
}
}
return result;
}