本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.MethodScope类的典型用法代码示例。如果您正苦于以下问题:Java MethodScope类的具体用法?Java MethodScope怎么用?Java MethodScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodScope类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了MethodScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAccess
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public boolean checkAccess(BlockScope scope, ReferenceBinding thisType) {
// this/super cannot be used in constructor call
MethodScope methodScope = scope.methodScope();
if (this.evaluationContext.isConstructorCall) {
methodScope.problemReporter().fieldsOrThisBeforeConstructorInvocation(this);
return false;
}
// static may not refer to this/super
if (this.evaluationContext.declaringTypeName == null || this.evaluationContext.isStatic) {
methodScope.problemReporter().errorThisSuperInStatic(this);
return false;
}
scope.tagAsAccessingEnclosingInstanceStateOf(thisType, false /* type variable access */);
return true;
}
示例2: resolveType
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {
// implicit this
this.constant = Constant.NotAConstant;
ReferenceBinding snippetType = scope.enclosingSourceType();
MethodScope methodScope = scope.methodScope();
if (!this.isImplicit && !checkAccess(scope, snippetType)) {
return null;
}
this.delegateThis = scope.getField(snippetType, DELEGATE_THIS, this);
if (this.delegateThis == null || !this.delegateThis.isValidBinding()) {
// should not happen
// if this happen we should report illegal access to this in a static context
methodScope.problemReporter().errorThisSuperInStatic(this);
return null;
}
return this.resolvedType = this.delegateThis.type;
}
示例3: checkFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public TypeBinding checkFieldAccess(BlockScope scope) {
FieldBinding fieldBinding = (FieldBinding) this.binding;
MethodScope methodScope = scope.methodScope();
TypeBinding declaringClass = fieldBinding.original().declaringClass;
// check for forward references
if ((this.indexOfFirstFieldBinding == 1 || declaringClass.isEnum())
&& TypeBinding.equalsEquals(methodScope.enclosingSourceType(), declaringClass)
&& methodScope.lastVisibleFieldID >= 0
&& fieldBinding.id >= methodScope.lastVisibleFieldID
&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
}
this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
this.bits |= Binding.FIELD;
return getOtherFieldBindings(scope);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:CodeSnippetQualifiedNameReference.java
示例4: recordFunctionalType
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public int recordFunctionalType(Scope scope) {
while (scope != null) {
switch (scope.kind) {
case Scope.METHOD_SCOPE :
ReferenceContext context = ((MethodScope) scope).referenceContext;
if (context instanceof LambdaExpression) {
LambdaExpression expression = (LambdaExpression) context;
if (expression != expression.original) // fake universe.
return 0;
}
break;
case Scope.COMPILATION_UNIT_SCOPE :
CompilationUnitDeclaration unit = ((CompilationUnitScope) scope).referenceContext;
return unit.record(this);
}
scope = scope.parent;
}
return 0; // not reached.
}
示例5: resolveType
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {
// implicit this
this.constant = Constant.NotAConstant;
TypeBinding snippetType = null;
MethodScope methodScope = scope.methodScope();
if (!this.isImplicit && !checkAccess(methodScope)) {
return null;
}
snippetType = scope.enclosingSourceType();
this.delegateThis = scope.getField(snippetType, DELEGATE_THIS, this);
if (this.delegateThis == null || !this.delegateThis.isValidBinding()) {
// should not happen
// if this happen we should report illegal access to this in a static context
methodScope.problemReporter().errorThisSuperInStatic(this);
return null;
}
return this.resolvedType = this.delegateThis.type;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:CodeSnippetThisReference.java
示例6: checkFieldAccess
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public TypeBinding checkFieldAccess(BlockScope scope) {
FieldBinding fieldBinding = (FieldBinding) this.binding;
MethodScope methodScope = scope.methodScope();
TypeBinding declaringClass = fieldBinding.original().declaringClass;
// check for forward references
if ((this.indexOfFirstFieldBinding == 1 || declaringClass.isEnum())
&& methodScope.enclosingSourceType() == declaringClass
&& methodScope.lastVisibleFieldID >= 0
&& fieldBinding.id >= methodScope.lastVisibleFieldID
&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
}
this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
this.bits |= Binding.FIELD;
return getOtherFieldBindings(scope);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:CodeSnippetQualifiedNameReference.java
示例7: generateBuilderFields
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public void generateBuilderFields(EclipseNode builderType, List<BuilderFieldData> builderFields, ASTNode source) {
List<EclipseNode> existing = new ArrayList<EclipseNode>();
for (EclipseNode child : builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
top:
for (BuilderFieldData bfd : builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType));
} else {
for (EclipseNode exists : existing) {
char[] n = ((FieldDeclaration) exists.get()).name;
if (Arrays.equals(n, bfd.name)) {
bfd.createdFields.add(exists);
continue top;
}
}
FieldDeclaration fd = new FieldDeclaration(bfd.name, 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
bfd.createdFields.add(injectFieldAndMarkGenerated(builderType, fd));
}
}
}
示例8: setGeneratedByRecursive
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public void setGeneratedByRecursive(ASTNode target) {
SetGeneratedByVisitor visitor = new SetGeneratedByVisitor(source);
if (target instanceof AbstractMethodDeclaration) {
((AbstractMethodDeclaration) target).traverse(visitor, (ClassScope) null);
} else if (target instanceof FieldDeclaration) {
((FieldDeclaration) target).traverse(visitor, (MethodScope) null);
} else {
target.traverse(visitor, null);
}
}
示例9: visit
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
@Override
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
Annotation[] annotations = fieldDeclaration.annotations;
if (annotations != null) {
FieldBinding fieldBinding = fieldDeclaration.binding;
if (fieldBinding == null) {
return false;
}
((SourceTypeBinding) fieldBinding.declaringClass).resolveTypeFor(fieldBinding);
this.resolveAnnotations(scope, annotations, fieldBinding);
}
return false;
}
示例10: visit
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.Initializer, org.eclipse.jdt.internal.compiler.lookup.MethodScope)
*/
public boolean visit(Initializer initializer, MethodScope scope) {
if (initializer.isStatic()) {
this.scribe.printNextToken(TerminalTokens.TokenNamestatic);
}
initializer.block.traverse(this, scope);
return false;
}
示例11: findLocalElement
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
protected IJavaElement findLocalElement(int pos, MethodScope scope) {
if (scope != null && scope.isLambdaScope()) {
IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope());
LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext();
if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) {
org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression);
return lambdaElement.getMethod();
}
return parent;
}
return findLocalElement(pos);
}
示例12: visitIfNeeded
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
private void visitIfNeeded(FieldDeclaration field, TypeDeclaration declaringType) {
if (this.localDeclarationVisitor != null
&& (field.bits & ASTNode.HasLocalType) != 0) {
if (field.initialization != null) {
try {
this.localDeclarationVisitor.pushDeclaringType(declaringType);
field.initialization.traverse(this.localDeclarationVisitor, (MethodScope) null);
} finally {
this.localDeclarationVisitor.popDeclaringType();
}
}
}
}
示例13: visit
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public boolean visit(
FieldDeclaration fieldDeclaration,
MethodScope scope) {
if (fieldDeclaration.declarationSourceStart <= this.position
&& this.position <= fieldDeclaration.declarationSourceEnd) {
this.found = fieldDeclaration;
return false;
}
return true;
}
示例14: complainIfUnusedExceptionHandlers
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public void complainIfUnusedExceptionHandlers(AbstractMethodDeclaration method) {
MethodScope scope = method.scope;
// can optionally skip overriding methods
if ((method.binding.modifiers & (ExtraCompilerModifiers.AccOverriding | ExtraCompilerModifiers.AccImplementing)) != 0
&& !scope.compilerOptions().reportUnusedDeclaredThrownExceptionWhenOverriding) {
return;
}
// report errors for unreachable exception handlers
TypeBinding[] docCommentReferences = null;
int docCommentReferencesLength = 0;
if (scope.compilerOptions().
reportUnusedDeclaredThrownExceptionIncludeDocCommentReference &&
method.javadoc != null &&
method.javadoc.exceptionReferences != null &&
(docCommentReferencesLength = method.javadoc.exceptionReferences.length) > 0) {
docCommentReferences = new TypeBinding[docCommentReferencesLength];
for (int i = 0; i < docCommentReferencesLength; i++) {
docCommentReferences[i] = method.javadoc.exceptionReferences[i].resolvedType;
}
}
nextHandledException: for (int i = 0, count = this.handledExceptions.length; i < count; i++) {
int index = this.indexes.get(this.handledExceptions[i]);
if ((this.isReached[index / ExceptionHandlingFlowContext.BitCacheSize] & 1 << (index % ExceptionHandlingFlowContext.BitCacheSize)) == 0) {
for (int j = 0; j < docCommentReferencesLength; j++) {
if (TypeBinding.equalsEquals(docCommentReferences[j], this.handledExceptions[i])) {
continue nextHandledException;
}
}
scope.problemReporter().unusedDeclaredThrownException(
this.handledExceptions[index],
method,
method.thrownExceptions[index]);
}
}
}
示例15: tagAsHavingIgnoredMandatoryErrors
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public void tagAsHavingIgnoredMandatoryErrors(int problemId) {
switch (problemId) {
// 15.27.3 requires exception throw related errors to not influence congruence. Other errors should. Also don't abort shape analysis.
case IProblem.UnhandledExceptionOnAutoClose:
case IProblem.UnhandledExceptionInDefaultConstructor:
case IProblem.UnhandledException:
return;
/* The following structural problems can occur only because of target type imposition. Filter, so we can distinguish inherent errors
in explicit lambdas. This is to help decide whether to proceed with data/control flow analysis to discover shape. In case of inherent
errors, we will not call analyze code as it is not prepared to analyze broken programs.
*/
case IProblem.VoidMethodReturnsValue:
case IProblem.ShouldReturnValueHintMissingDefault:
case IProblem.ShouldReturnValue:
case IProblem.ReturnTypeMismatch:
case IProblem.IncompatibleLambdaParameterType:
case IProblem.lambdaParameterTypeMismatched:
case IProblem.lambdaSignatureMismatched:
case IProblem.LambdaDescriptorMentionsUnmentionable:
case IProblem.TargetTypeNotAFunctionalInterface:
case IProblem.illFormedParameterizationOfFunctionalInterface:
case IProblem.MultipleFunctionalInterfaces:
case IProblem.NoGenericLambda:
return;
default:
this.original.hasIgnoredMandatoryErrors = true;
MethodScope enclosingLambdaScope = this.scope == null ? null : this.scope.enclosingLambdaScope();
while (enclosingLambdaScope != null) {
LambdaExpression enclosingLambda = (LambdaExpression) enclosingLambdaScope.referenceContext;
if (enclosingLambda.original != enclosingLambda)
enclosingLambda.original.hasIgnoredMandatoryErrors = true;
enclosingLambdaScope = enclosingLambdaScope.enclosingLambdaScope();
}
return;
}
}