本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.MethodScope类的典型用法代码示例。如果您正苦于以下问题:Java MethodScope类的具体用法?Java MethodScope怎么用?Java MethodScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodScope类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了MethodScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:CodeSnippetThisReference.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CodeSnippetThisReference.java
示例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.
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:FunctionalExpression.java
示例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));
}
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:29,代码来源:HandleBuilder.java
示例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);
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:12,代码来源:EclipseSingularsRecipes.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:AnnotationDiscoveryVisitor.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CodeFormatterVisitor.java
示例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);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:SelectionRequestor.java
示例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();
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:SourceElementNotifier.java
示例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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:NodeSearcher.java
示例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]);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:ExceptionHandlingFlowContext.java
示例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;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:LambdaExpression.java
示例16: methodHasMissingSwitchDefault
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
private boolean methodHasMissingSwitchDefault() {
MethodScope methodScope = null;
if (this.referenceContext instanceof Block) {
methodScope = ((Block)this.referenceContext).scope.methodScope();
} else if (this.referenceContext instanceof AbstractMethodDeclaration) {
methodScope = ((AbstractMethodDeclaration)this.referenceContext).scope;
}
return methodScope != null && methodScope.hasMissingSwitchDefault;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ProblemReporter.java
示例17: checkAccess
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
public boolean checkAccess(MethodScope methodScope) {
// this/super cannot be used in constructor call
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;
}
return true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:15,代码来源:CodeSnippetThisReference.java
示例18: 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 (docCommentReferences[j] == this.handledExceptions[i]) {
continue nextHandledException;
}
}
scope.problemReporter().unusedDeclaredThrownException(
this.handledExceptions[index],
method,
method.thrownExceptions[index]);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:37,代码来源:ExceptionHandlingFlowContext.java
示例19: endVisit
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
@Override
public void endVisit(FieldDeclaration x, MethodScope scope) {
try {
JExpression initialization = pop(x.initialization);
JField field = typeMap.get(x.binding);
if (field instanceof JEnumField) {
// An enum field must be initialized!
assert (initialization instanceof JNewInstance);
}
if (initialization != null) {
SourceInfo info = makeSourceInfo(x);
JExpression instance = null;
if (!x.isStatic()) {
instance = makeThisRef(info);
}
// JDeclarationStatement's ctor sets up the field's initializer.
JStatement decl =
new JDeclarationStatement(info, new JFieldRef(info, instance, field, curClass.type),
initialization);
// will either be init or clinit
curMethod.body.getBlock().addStmt(decl);
}
popMethodInfo();
} catch (Throwable e) {
throw translateException(x, e);
}
}
开发者ID:WeTheInternet,项目名称:xapi,代码行数:29,代码来源:GwtAstBuilder.java
示例20: visit
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; //导入依赖的package包/类
@Override
public boolean visit(FieldDeclaration x, MethodScope scope) {
try {
assert !typeMap.get(x.binding).isExternal();
pushInitializerMethodInfo(x, scope);
return true;
} catch (Throwable e) {
throw translateException(x, e);
}
}
开发者ID:WeTheInternet,项目名称:xapi,代码行数:11,代码来源:GwtAstBuilder.java
注:本文中的org.eclipse.jdt.internal.compiler.lookup.MethodScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论