org.eclipse.jdt.internal.compiler.lookup.MethodScope Java Examples

The following examples show how to use org.eclipse.jdt.internal.compiler.lookup.MethodScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeSnippetThisReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: FunctionalExpression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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.
}
 
Example #3
Source File: CodeSnippetQualifiedNameReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: CodeSnippetThisReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: Extractor.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
    Annotation[] annotations = fieldDeclaration.annotations;
    if (hasRelevantAnnotations(annotations)) {
        FieldBinding fieldBinding = fieldDeclaration.binding;
        if (fieldBinding == null) {
            return false;
        }

        String fqn = getFqn(scope);
        ClassKind kind = scope.referenceContext instanceof TypeDeclaration ?
                ClassKind.forType((TypeDeclaration) scope.referenceContext) :
                ClassKind.CLASS;
        Item item = FieldItem.create(fqn, kind, fieldBinding);
        if (item != null && fqn != null) {
            addItem(fqn, item);
            addAnnotations(annotations, item);
        }
    }
    return false;
}
 
Example #6
Source File: NodeSearcher.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean visit(
	FieldDeclaration fieldDeclaration,
	MethodScope scope) {
		if (fieldDeclaration.declarationSourceStart <= this.position
			&& this.position <= fieldDeclaration.declarationSourceEnd) {
				this.found = fieldDeclaration;
				return false;
		}
		return true;
}
 
Example #7
Source File: LambdaExpression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
	}
}
 
Example #8
Source File: ExceptionHandlingFlowContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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]);
		}
	}
}
 
Example #9
Source File: NodeSearcher.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean visit(Initializer initializer, MethodScope scope) {
	if (initializer.declarationSourceStart <= this.position
		&& this.position <= initializer.declarationSourceEnd) {
			this.found = initializer;
			return false;
	}
	return true;
}
 
Example #10
Source File: HandleBuilder.java    From EasyMPermission with MIT License 5 votes vote down vote up
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));
		}
	}
}
 
Example #11
Source File: Extractor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
private static String getFqn(@NonNull MethodScope scope) {
    ClassScope classScope = findClassScope(scope);
    if (classScope != null) {
        return getFqn(classScope);
    }

    return null;
}
 
Example #12
Source File: SourceElementNotifier.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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();
				}
			}
	}
}
 
Example #13
Source File: SelectionRequestor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
}
 
Example #14
Source File: EclipseSingularsRecipes.java    From EasyMPermission with MIT License 5 votes vote down vote up
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);
	}
}
 
Example #15
Source File: AnnotationDiscoveryVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #16
Source File: ASTVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
	return true; // do nothing by default, keep traversing
}
 
Example #17
Source File: CompilationUnitDeclaration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void traverse(ASTVisitor visitor, CompilationUnitScope unitScope, boolean skipOnError) {
	if (skipOnError && this.ignoreFurtherInvestigation)
		return;
	try {
		if (visitor.visit(this, this.scope)) {
			if (this.types != null && isPackageInfo()) {
	            // resolve synthetic type declaration
				final TypeDeclaration syntheticTypeDeclaration = this.types[0];
				// resolve javadoc package if any
				final MethodScope methodScope = syntheticTypeDeclaration.staticInitializerScope;
				// Don't traverse in null scope and invite trouble a la bug 252555.
				if (this.javadoc != null && methodScope != null) {
					this.javadoc.traverse(visitor, methodScope);
				}
				// Don't traverse in null scope and invite trouble a la bug 252555.
				if (this.currentPackage != null && methodScope != null) {
					final Annotation[] annotations = this.currentPackage.annotations;
					if (annotations != null) {
						int annotationsLength = annotations.length;
						for (int i = 0; i < annotationsLength; i++) {
							annotations[i].traverse(visitor, methodScope);
						}
					}
				}
			}
			if (this.currentPackage != null) {
				this.currentPackage.traverse(visitor, this.scope);
			}
			if (this.imports != null) {
				int importLength = this.imports.length;
				for (int i = 0; i < importLength; i++) {
					this.imports[i].traverse(visitor, this.scope);
				}
			}
			if (this.types != null) {
				int typesLength = this.types.length;
				for (int i = 0; i < typesLength; i++) {
					this.types[i].traverse(visitor, this.scope);
				}
			}
		}
		visitor.endVisit(this, this.scope);
	} catch (AbortCompilationUnit e) {
		// ignore
	}
}
 
Example #18
Source File: ExplicitConstructorCall.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor call code generation
 *
 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
 */
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
	if ((this.bits & ASTNode.IsReachable) == 0) {
		return;
	}
	try {
		((MethodScope) currentScope).isConstructorCall = true;

		int pc = codeStream.position;
		codeStream.aload_0();

		MethodBinding codegenBinding = this.binding.original();
		ReferenceBinding targetType = codegenBinding.declaringClass;

		// special name&ordinal argument generation for enum constructors
		if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) {
			codeStream.aload_1(); // pass along name param as name arg
			codeStream.iload_2(); // pass along ordinal param as ordinal arg
		}
		// handling innerclass constructor invocation
		// handling innerclass instance allocation - enclosing instance arguments
		if (targetType.isNestedType()) {
			codeStream.generateSyntheticEnclosingInstanceValues(
				currentScope,
				targetType,
				(this.bits & ASTNode.DiscardEnclosingInstance) != 0 ? null : this.qualification,
				this);
		}
		// generate arguments
		generateArguments(this.binding, this.arguments, currentScope, codeStream);

		// handling innerclass instance allocation - outer local arguments
		if (targetType.isNestedType()) {
			codeStream.generateSyntheticOuterArgumentValues(
				currentScope,
				targetType,
				this);
		}
		if (this.syntheticAccessor != null) {
			// synthetic accessor got some extra arguments appended to its signature, which need values
			for (int i = 0,
				max = this.syntheticAccessor.parameters.length - codegenBinding.parameters.length;
				i < max;
				i++) {
				codeStream.aconst_null();
			}
			codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */, this.typeArguments);
		} else {
			codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */, this.typeArguments);
		}
		codeStream.recordPositionsFrom(pc, this.sourceStart);
	} finally {
		((MethodScope) currentScope).isConstructorCall = false;
	}
}
 
Example #19
Source File: ExplicitConstructorCall.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
	// must verify that exceptions potentially thrown by this expression are caught in the method.

	try {
		((MethodScope) currentScope).isConstructorCall = true;

		// process enclosing instance
		if (this.qualification != null) {
			flowInfo =
				this.qualification
					.analyseCode(currentScope, flowContext, flowInfo)
					.unconditionalInits();
		}
		// process arguments
		if (this.arguments != null) {
			boolean analyseResources = currentScope.compilerOptions().analyseResourceLeaks;
			for (int i = 0, max = this.arguments.length; i < max; i++) {
				flowInfo =
					this.arguments[i]
						.analyseCode(currentScope, flowContext, flowInfo)
						.unconditionalInits();
				if (analyseResources) {
					// if argument is an AutoCloseable insert info that it *may* be closed (by the target constructor, i.e.)
					flowInfo = FakedTrackingVariable.markPassedToOutside(currentScope, this.arguments[i], flowInfo, flowContext, false);
				}
				this.arguments[i].checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
			}
			analyseArguments(currentScope, flowContext, flowInfo, this.binding, this.arguments);
		}

		ReferenceBinding[] thrownExceptions;
		if ((thrownExceptions = this.binding.thrownExceptions) != Binding.NO_EXCEPTIONS) {
			if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6
				thrownExceptions = currentScope.environment().convertToRawTypes(this.binding.thrownExceptions, true, true);
			}				
			// check exceptions
			flowContext.checkExceptionHandlers(
				thrownExceptions,
				(this.accessMode == ExplicitConstructorCall.ImplicitSuper)
					? (ASTNode) currentScope.methodScope().referenceContext
					: (ASTNode) this,
				flowInfo,
				currentScope);
		}
		manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
		manageSyntheticAccessIfNecessary(currentScope, flowInfo);
		return flowInfo;
	} finally {
		((MethodScope) currentScope).isConstructorCall = false;
	}
}
 
Example #20
Source File: SingleNameReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public TypeBinding checkFieldAccess(BlockScope scope) {
	FieldBinding fieldBinding = (FieldBinding) this.binding;
	this.constant = fieldBinding.constant();

	this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
	this.bits |= Binding.FIELD;
	MethodScope methodScope = scope.methodScope();
	if (fieldBinding.isStatic()) {
		// check if accessing enum static field in initializer
		ReferenceBinding declaringClass = fieldBinding.declaringClass;
		if (declaringClass.isEnum()) {
			SourceTypeBinding sourceType = scope.enclosingSourceType();
			if (this.constant == Constant.NotAConstant
					&& !methodScope.isStatic
					&& (TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body
					&& methodScope.isInsideInitializerOrConstructor()) {
				scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
			}
		}
	} else {
		if (scope.compilerOptions().getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
			scope.problemReporter().unqualifiedFieldAccess(this, fieldBinding);
		}
		// must check for the static status....
		if (methodScope.isStatic) {
			scope.problemReporter().staticFieldAccessToNonStaticVariable(this, fieldBinding);
			return fieldBinding.type;
		} else {
			scope.tagAsAccessingEnclosingInstanceStateOf(fieldBinding.declaringClass, false /* type variable access */);
		}
	}

	if (isFieldUseDeprecated(fieldBinding, scope, this.bits))
		scope.problemReporter().deprecatedField(fieldBinding, this);

	if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
			&& TypeBinding.equalsEquals(methodScope.enclosingSourceType(), fieldBinding.original().declaringClass)
			&& methodScope.lastVisibleFieldID >= 0
			&& fieldBinding.id >= methodScope.lastVisibleFieldID
			&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
		scope.problemReporter().forwardReference(this, 0, fieldBinding);
		this.bits |= ASTNode.IgnoreNoEffectAssignCheck;
	}
	return fieldBinding.type;

}
 
Example #21
Source File: Reference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
static void reportOnlyUselesslyReadLocal(BlockScope currentScope, LocalVariableBinding localBinding, boolean valueRequired) {
	if (localBinding.declaration == null)
		return;  // secret local
	if ((localBinding.declaration.bits & ASTNode.IsLocalDeclarationReachable) == 0)
		return;  // declaration is unreachable
	if (localBinding.useFlag >= LocalVariableBinding.USED)
		return;  // we're only interested in cases with only compound access (negative count)

	if (valueRequired) {
		// access is relevant
		localBinding.useFlag = LocalVariableBinding.USED;
		return;
	} else {
		localBinding.useFlag++;
		if (localBinding.useFlag != LocalVariableBinding.UNUSED) // have all negative counts been consumed?
			return; // still waiting to see more usages of this kind
	}
	// at this point we know we have something to report
	if (localBinding.declaration instanceof Argument) {
		// check compiler options to report against unused arguments
		MethodScope methodScope = currentScope.methodScope();
		if (methodScope != null && !methodScope.isLambdaScope()) { // lambda must be congruent with the descriptor.
			MethodBinding method = ((AbstractMethodDeclaration)methodScope.referenceContext()).binding;
			
			boolean shouldReport = !method.isMain();
			if (method.isImplementing()) {
				shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenImplementingAbstract;
			} else if (method.isOverriding()) {
				shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenOverridingConcrete;
			}
			
			if (shouldReport) {
				// report the case of an argument that is unread except through a special operator
				currentScope.problemReporter().unusedArgument(localBinding.declaration);
			}
		}
	} else {
		// report the case of a local variable that is unread except for a special operator
		currentScope.problemReporter().unusedLocalVariable(localBinding.declaration);
	}
	localBinding.useFlag = LocalVariableBinding.USED; // don't report again
}
 
Example #22
Source File: LambdaExpression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public MethodScope getScope() {
	return this.scope;
}
 
Example #23
Source File: SelectionOnArgumentName.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public TypeBinding bind(MethodScope scope, TypeBinding typeBinding, boolean used) {

		super.bind(scope, typeBinding, used);
		throw new SelectionNodeFound(this.binding);
	}
 
Example #24
Source File: ASTVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public boolean visit(Initializer initializer, MethodScope scope) {
	return true; // do nothing by default, keep traversing
}
 
Example #25
Source File: UnresolvedReferenceNameFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void endVisit(Initializer initializer, MethodScope methodScope) {
	endVisitPreserved(initializer.bodyStart, initializer.bodyEnd);
	popParent();
}
 
Example #26
Source File: ASTVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void endVisit(Initializer initializer, MethodScope scope) {
	// do nothing by default
}
 
Example #27
Source File: ASTVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
	// do nothing by default
}
 
Example #28
Source File: CompletionOnFieldName.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void resolve(MethodScope initializationScope) {
	super.resolve(initializationScope);

	throw new CompletionNodeFound(this, initializationScope);
}
 
Example #29
Source File: SetGeneratedByVisitor.java    From EasyMPermission with MIT License 4 votes vote down vote up
@Override public boolean visit(Initializer node, MethodScope scope) {
	fixPositions(setGeneratedBy(node, source));
	return super.visit(node, scope);
}
 
Example #30
Source File: CompletionOnArgumentName.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public TypeBinding bind(MethodScope scope, TypeBinding typeBinding, boolean used) {

		super.bind(scope, typeBinding, used);
		throw new CompletionNodeFound(this, scope);
	}