当前位置: 首页>>代码示例>>Java>>正文


Java MethodBinding.isConstructor方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.MethodBinding.isConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java MethodBinding.isConstructor方法的具体用法?Java MethodBinding.isConstructor怎么用?Java MethodBinding.isConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.compiler.lookup.MethodBinding的用法示例。


在下文中一共展示了MethodBinding.isConstructor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConstructors

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
@Override
@NonNull
public Iterable<ResolvedMethod> getConstructors() {
    if (mBinding instanceof ReferenceBinding) {
        ReferenceBinding cls = (ReferenceBinding) mBinding;
        MethodBinding[] methods = cls.getMethods(TypeConstants.INIT);
        if (methods != null) {
            int count = methods.length;
            List<ResolvedMethod> result = Lists.newArrayListWithExpectedSize(count);
            for (MethodBinding method : methods) {
                if (method.isConstructor()) {
                    result.add(new EcjResolvedMethod(method));
                }
            }
            return result;
        }
    }

    return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:EcjParser.java

示例2: getKind

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
@Override
public ElementKind getKind() {
	MethodBinding binding = (MethodBinding)_binding;
	if (binding.isConstructor()) {
		return ElementKind.CONSTRUCTOR;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.CLINIT)) {
		return ElementKind.STATIC_INIT;
	}
	else if (CharOperation.equals(binding.selector, TypeConstants.INIT)) {
		return ElementKind.INSTANCE_INIT;
	}
	else {
		return ElementKind.METHOD;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:ExecutableElementImpl.java

示例3: tooManyParametersForSyntheticMethod

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void tooManyParametersForSyntheticMethod(AbstractMethodDeclaration method) {
	MethodBinding binding = method.binding;
	String selector = null;
	if (binding.isConstructor()) {
		selector = new String(binding.declaringClass.sourceName());
	} else {
		selector = new String(method.selector);
	}
	this.handle(
		IProblem.TooManyParametersForSyntheticMethod,
		new String[] {selector, typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
		new String[] {selector, typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
		ProblemSeverities.AbortMethod | ProblemSeverities.Error | ProblemSeverities.Fatal,
		method.sourceStart,
		method.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:ProblemReporter.java

示例4: unnecessaryTypeArgumentsForMethodInvocation

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void unnecessaryTypeArgumentsForMethodInvocation(MethodBinding method, TypeBinding[] genericTypeArguments, TypeReference[] typeArguments) {
	String methodName = method.isConstructor()
		? new String(method.declaringClass.shortReadableName())
		: new String(method.selector);
	this.handle(
			method.isConstructor()
				? IProblem.UnusedTypeArgumentsForConstructorInvocation
				: IProblem.UnusedTypeArgumentsForMethodInvocation,
		new String[] {
				methodName,
		        typesAsString(method, false),
		        new String(method.declaringClass.readableName()),
		        typesAsString(genericTypeArguments, false) },
		new String[] {
				methodName,
		        typesAsString(method, true),
		        new String(method.declaringClass.shortReadableName()),
		        typesAsString(genericTypeArguments, true) },
		typeArguments[0].sourceStart,
		typeArguments[typeArguments.length-1].sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:ProblemReporter.java

示例5: javadocDeprecatedMethod

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
	boolean isConstructor = method.isConstructor();
	int severity = computeSeverity(isConstructor ? IProblem.JavadocUsingDeprecatedConstructor : IProblem.JavadocUsingDeprecatedMethod);
	if (severity == ProblemSeverities.Ignore) return;
	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
		if (isConstructor) {
			this.handle(
				IProblem.JavadocUsingDeprecatedConstructor,
				new String[] {new String(method.declaringClass.readableName()), typesAsString(method, false)},
				new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method, true)},
				severity,
				location.sourceStart,
				location.sourceEnd);
		} else {
			this.handle(
				IProblem.JavadocUsingDeprecatedMethod,
				new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
				new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
				severity,
				location.sourceStart,
				location.sourceEnd);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:ProblemReporter.java

示例6: getReceiverType

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public TypeMirror getReceiverType(MethodBinding binding) {
	if (binding != null) {
		if (binding.receiver != null) {
			return _env.getFactory().newTypeMirror(binding.receiver);
		}
		if (binding.declaringClass != null) {
			if (!binding.isStatic() && (!binding.isConstructor() || binding.declaringClass.isMemberType())) {
				return _env.getFactory().newTypeMirror(binding.declaringClass);	
			}
		}
	}
	return NoTypeImpl.NO_TYPE_NONE;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:Factory.java

示例7: forbiddenReference

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
/** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
 * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
public void forbiddenReference(MethodBinding method, ASTNode location,
		byte classpathEntryType, String classpathEntryName, int problemId) {
	int severity = computeSeverity(problemId);
	if (severity == ProblemSeverities.Ignore) return;
	if (method.isConstructor())
		this.handle(
			problemId,
			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
			getElaborationId(IProblem.ForbiddenReference, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
			new String[] {
				classpathEntryName,
				new String(method.shortReadableName())},
			severity,
			location.sourceStart,
			location.sourceEnd);
	else
		this.handle(
			problemId,
			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
			getElaborationId(IProblem.ForbiddenReference, (byte) (METHOD_ACCESS | classpathEntryType)),
			new String[] {
				classpathEntryName,
				new String(method.shortReadableName()),
		        new String(method.declaringClass.shortReadableName())},
		    severity,
			location.sourceStart,
			location.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:31,代码来源:ProblemReporter.java

示例8: matchConstructor

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
protected int matchConstructor(MethodBinding constructor) {
	if (!constructor.isConstructor()) return IMPOSSIBLE_MATCH;

	// declaring type, simple name has already been matched by matchIndexEntry()
	int level = resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification, constructor.declaringClass);
	if (level == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH;

	// parameter types
	int parameterCount = this.pattern.parameterCount;
	if (parameterCount > -1) {
		if (constructor.parameters == null) return INACCURATE_MATCH;
		if (parameterCount != constructor.parameters.length) return IMPOSSIBLE_MATCH;
		for (int i = 0; i < parameterCount; i++) {
			// TODO (frederic) use this call to refine accuracy on parameter types
//			int newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], this.pattern.parametersTypeArguments[i], 0, constructor.parameters[i]);
			int newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], constructor.parameters[i]);
			if (level > newLevel) {
				if (newLevel == IMPOSSIBLE_MATCH) {
//					if (isErasureMatch) {
//						return ERASURE_MATCH;
//					}
					return IMPOSSIBLE_MATCH;
				}
				level = newLevel; // can only be downgraded
			}
		}
	}
	return level;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:ConstructorLocator.java

示例9: isPertinentToApplicability

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public boolean isPertinentToApplicability(TypeBinding targetType, MethodBinding method) {
	if (targetType instanceof TypeVariableBinding) {
		if (method != null) { // when called from type inference
			if (((TypeVariableBinding)targetType).declaringElement == method)
				return false;
			if (method.isConstructor() && ((TypeVariableBinding)targetType).declaringElement == method.declaringClass)
				return false;
		} else { // for internal calls
			TypeVariableBinding typeVariable = (TypeVariableBinding) targetType;
			if (typeVariable.declaringElement instanceof MethodBinding)
				return false;
		}
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:FunctionalExpression.java

示例10: invocationTargetType

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public TypeBinding invocationTargetType() {
	if (this.expectedType == null) return null;
	// when during inference this expression mimics as an invocationSite,
	// we simulate an *invocation* of this functional expression,
	// where the expected type of the expression is the return type of the sam:
	MethodBinding sam = this.expectedType.getSingleAbstractMethod(this.enclosingScope, true);
	if (sam != null) {
		if (sam.isConstructor())
			return sam.declaringClass;
		else
			return sam.returnType;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:FunctionalExpression.java

示例11: safeVarargsOnNonFinalInstanceMethod

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void safeVarargsOnNonFinalInstanceMethod(MethodBinding method) {
	String [] arguments = new String[] { new String(method.isConstructor() ? method.declaringClass.shortReadableName() : method.selector)}; 
	this.handle(
		IProblem.SafeVarargsOnNonFinalInstanceMethod,
		arguments,
		arguments,
		method.sourceStart(),
		method.sourceEnd());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ProblemReporter.java

示例12: incompatibleReturnType

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void incompatibleReturnType(ReferenceExpression expression, MethodBinding method, TypeBinding returnType) {
	if (method.isConstructor()) {
		this.handle(IProblem.ConstructionTypeMismatch,
				new String[] { new String(method.declaringClass.readableName()), new String(returnType.readableName())},
				new String[] { new String(method.declaringClass.shortReadableName()), new String(returnType.shortReadableName())},
				expression.sourceStart,
				expression.sourceEnd);
		
	} else {
		StringBuffer buffer = new StringBuffer();
		StringBuffer shortBuffer = new StringBuffer();
		TypeBinding [] parameters = method.parameters;
		for (int i = 0, length = parameters.length; i < length; i++) {
			if (i != 0) {
				buffer.append(", "); //$NON-NLS-1$
				shortBuffer.append(", "); //$NON-NLS-1$
			}
			buffer.append(new String(parameters[i].readableName()));
			shortBuffer.append(new String(parameters[i].shortReadableName()));
		}
		String selector = new String(method.selector);
		this.handle(IProblem.IncompatibleMethodReference,
				new String[] { selector, buffer.toString(), new String(method.declaringClass.readableName()), new String(method.returnType.readableName()), new String(returnType.readableName())},
				new String[] { selector, shortBuffer.toString(), new String(method.declaringClass.shortReadableName()), new String(method.returnType.shortReadableName()), new String(returnType.shortReadableName())},
				expression.sourceStart,
				expression.sourceEnd);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:ProblemReporter.java

示例13: addAllMethodBindings0

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
private static void addAllMethodBindings0(List<BindingTuple> list, TypeBinding binding, Set<String> banList, char[] fieldName, ASTNode responsible) throws DelegateRecursion {
	if (binding instanceof SourceTypeBinding) ((SourceTypeBinding) binding).scope.environment().globalOptions.storeAnnotations = true;
	if (binding == null) return;
	
	TypeBinding inner;
	
	if (binding instanceof ParameterizedTypeBinding) {
		inner = ((ParameterizedTypeBinding) binding).genericType();
	} else {
		inner = binding;
	}
	
	if (inner instanceof SourceTypeBinding) {
		ClassScope cs = ((SourceTypeBinding)inner).scope;
		if (cs != null) {
			try {
				Reflection.classScopeBuildFieldsAndMethodsMethod.invoke(cs);
			} catch (Exception e) {
				// See 'Reflection' class for why we ignore this exception.
			}
		}
	}
	
	if (binding instanceof ReferenceBinding) {
		ReferenceBinding rb = (ReferenceBinding) binding;
		MethodBinding[] availableMethods = rb.availableMethods();
		FieldBinding[] availableFields = rb.availableFields();
		failIfContainsAnnotation(binding, availableMethods); 
		failIfContainsAnnotation(binding, availableFields); 
		
		MethodBinding[] parameterizedSigs = availableMethods;
		MethodBinding[] baseSigs = parameterizedSigs;
		if (binding instanceof ParameterizedTypeBinding) {
			baseSigs = ((ParameterizedTypeBinding)binding).genericType().availableMethods();
			if (baseSigs.length != parameterizedSigs.length) {
				// The last known state of eclipse source says this can't happen, so we rely on it,
				// but if this invariant is broken, better to go with 'arg0' naming instead of crashing.
				baseSigs = parameterizedSigs;
			}
		}
		for (int i = 0; i < parameterizedSigs.length; i++) {
			MethodBinding mb = parameterizedSigs[i];
			String sig = printSig(mb);
			if (mb.isStatic()) continue;
			if (mb.isBridge()) continue;
			if (mb.isConstructor()) continue;
			if (mb.isDefaultAbstract()) continue;
			if (!mb.isPublic()) continue;
			if (mb.isSynthetic()) continue;
			if (!banList.add(sig)) continue; // If add returns false, it was already in there.
			BindingTuple pair = new BindingTuple(mb, baseSigs[i], fieldName, responsible);
			list.add(pair);
		}
		addAllMethodBindings0(list, rb.superclass(), banList, fieldName, responsible);
		ReferenceBinding[] interfaces = rb.superInterfaces();
		if (interfaces != null) {
			for (ReferenceBinding iface : interfaces) addAllMethodBindings0(list, iface, banList, fieldName, responsible);
		}
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:61,代码来源:PatchDelegate.java

示例14: addMembers

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
/**
 * Add the members of a type to the maps of subtypes, fields, and methods.  Add only those
 * which are non-private and which are not overridden by an already-discovered member.
 * For fields, add them all; javac implementation does not take field hiding into account.
 * @param binding the type whose members will be added to the lists
 * @param ignoreVisibility if true, all members will be added regardless of whether they
 * are private, overridden, etc.
 * @param types a map of type simple name to type binding
 * @param fields a list of field bindings
 * @param methods a map of method simple name to set of method bindings with that name
 */
private void addMembers(ReferenceBinding binding, boolean ignoreVisibility, Map<String, ReferenceBinding> types,
		List<FieldBinding> fields, Map<String, Set<MethodBinding>> methods)
{
	for (ReferenceBinding subtype : binding.memberTypes()) {
		if (ignoreVisibility || !subtype.isPrivate()) {
			String name = new String(subtype.sourceName());
			if (null == types.get(name)) {
				types.put(name, subtype);
			}
		}
	}
	for (FieldBinding field : binding.fields()) {
		if (ignoreVisibility || !field.isPrivate()) {
			fields.add(field);
		}
	}
	for (MethodBinding method : binding.methods()) {
		if (!method.isSynthetic() && (ignoreVisibility || (!method.isPrivate() && !method.isConstructor()))) {
			String methodName = new String(method.selector);
			Set<MethodBinding> sameNamedMethods = methods.get(methodName);
			if (null == sameNamedMethods) {
				// New method name.  Create a set for it and add it to the list.
				// We don't expect many methods with same name, so only 4 slots:
				sameNamedMethods = new HashSet<MethodBinding>(4);
				methods.put(methodName, sameNamedMethods);
				sameNamedMethods.add(method);
			}
			else {
				// We already have a method with this name.  Is this method overridden?
				boolean unique = true;
				if (!ignoreVisibility) {
					for (MethodBinding existing : sameNamedMethods) {
						MethodVerifier verifier = _env.getLookupEnvironment().methodVerifier();
						if (verifier.doesMethodOverride(existing, method)) {
							unique = false;
							break;
						}
					}
				}
				if (unique) {
					sameNamedMethods.add(method);
				}
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:ElementsImpl.java

示例15: unsafeRawGenericMethodInvocation

import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
public void unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes) {
	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
	boolean isConstructor = rawMethod.isConstructor();
	int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawGenericConstructorInvocation : IProblem.UnsafeRawGenericMethodInvocation);
	if (severity == ProblemSeverities.Ignore) return;
    if (isConstructor) {
		this.handle(
			IProblem.UnsafeRawGenericConstructorInvocation, // The generic constructor {0}({1}) of type {2} is applied to non-parameterized type arguments ({3})
			new String[] {
				new String(rawMethod.declaringClass.sourceName()),
				typesAsString(rawMethod.original(), false),
				new String(rawMethod.declaringClass.readableName()),
				typesAsString(argumentTypes, false),
			 },
			new String[] {
				new String(rawMethod.declaringClass.sourceName()),
				typesAsString(rawMethod.original(), true),
				new String(rawMethod.declaringClass.shortReadableName()),
				typesAsString(argumentTypes, true),
			 },
			severity,
			location.sourceStart,
			location.sourceEnd);
    } else {
		this.handle(
			IProblem.UnsafeRawGenericMethodInvocation,
			new String[] {
				new String(rawMethod.selector),
				typesAsString(rawMethod.original(), false),
				new String(rawMethod.declaringClass.readableName()),
				typesAsString(argumentTypes, false),
			 },
			new String[] {
				new String(rawMethod.selector),
				typesAsString(rawMethod.original(), true),
				new String(rawMethod.declaringClass.shortReadableName()),
				typesAsString(argumentTypes, true),
			 },
			severity,
			location.sourceStart,
			location.sourceEnd);
    }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:ProblemReporter.java


注:本文中的org.eclipse.jdt.internal.compiler.lookup.MethodBinding.isConstructor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。