private ConstructorDeclaration addConstructor(EclipseNode singletonClass, TypeDeclaration astNode) { ConstructorDeclaration constructor = new ConstructorDeclaration(astNode.compilationResult); constructor.modifiers = AccPrivate; constructor.selector = astNode.name; constructor.sourceStart = astNode.sourceStart; constructor.sourceEnd = astNode.sourceEnd; constructor.thrownExceptions = null; constructor.typeParameters = null; constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = astNode.sourceStart; constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = astNode.sourceEnd; constructor.arguments = null; EclipseHandlerUtil.injectMethod(singletonClass, constructor); return constructor; } }
/** * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#analyseCode(org.eclipse.jdt.internal.compiler.lookup.ClassScope, org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext, org.eclipse.jdt.internal.compiler.flow.FlowInfo) * @deprecated use instead {@link #analyseCode(ClassScope, InitializationFlowContext, FlowInfo, int)} */ public void analyseCode(ClassScope classScope, InitializationFlowContext initializerFlowContext, FlowInfo flowInfo) { analyseCode(classScope, initializerFlowContext, flowInfo, FlowInfo.REACHABLE); }
int argumentsLength = argumentTypes.length; ConstructorDeclaration constructor = new ConstructorDeclaration(this.compilationResult); constructor.selector = new char[] { 'x' }; //no maining constructor.sourceStart = this.sourceStart; constructor.bindArguments(); constructor.constructorCall.resolve(constructor.scope);
if (isRecursive(null /*lazy initialized visited list*/)) { this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall); analyseArguments(classScope.environment(), flowInfo, this.arguments, this.binding); } else if (field.isNonNull() || field.type.isFreeTypeVariable()) { FieldDeclaration fieldDecl = this.scope.referenceType().declarationOf(field.original()); if (!isValueProvidedUsingAnnotation(fieldDecl)) this.scope.problemReporter().uninitializedNonNullField( field,
if (isRecursive(null /*lazy initialized visited list*/)) { this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall); analyseArguments(flowInfo, this.arguments, this.binding); else analyseArguments18(flowInfo, this.arguments, this.binding); } else if (field.isNonNull()) { FieldDeclaration fieldDecl = this.scope.referenceType().declarationOf(field.original()); if (!isValueProvidedUsingAnnotation(fieldDecl)) this.scope.problemReporter().uninitializedNonNullField( field,
public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) { this.handle( IProblem.InterfaceCannotHaveConstructors, NoArgument, NoArgument, constructor.sourceStart, constructor.sourceEnd, constructor, constructor.compilationResult()); } public void interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl) {
public StringBuffer printBody(int indent, StringBuffer output) { output.append(" {"); //$NON-NLS-1$ if (this.constructorCall != null) { output.append('\n'); this.constructorCall.printStatement(indent, output); } if (this.statements != null) { for (int i = 0; i < this.statements.length; i++) { output.append('\n'); this.statements[i].printStatement(indent, output); } } output.append('\n'); printIndent(indent == 0 ? 0 : indent - 1, output).append('}'); return output; }
public void unhandledException(TypeBinding exceptionType, ASTNode location) { boolean insideDefaultConstructor = (this.referenceContext instanceof ConstructorDeclaration) && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall) && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper); this.handle( insideDefaultConstructor ? IProblem.UnhandledExceptionInDefaultConstructor : (insideImplicitConstructorCall ? IProblem.UndefinedConstructorInImplicitConstructorCall : IProblem.UnhandledException), new String[] {new String(exceptionType.readableName())}, new String[] {new String(exceptionType.shortReadableName())}, location.sourceStart, location.sourceEnd); } public void unhandledWarningToken(Expression token) {
public boolean isRecursive(ArrayList visited) { if (this.binding == null || this.constructorCall == null || this.constructorCall.binding == null || this.constructorCall.isSuperAccess() || !this.constructorCall.binding.isValidBinding()) { return false; } ConstructorDeclaration targetConstructor = ((ConstructorDeclaration)this.scope.referenceType().declarationOf(this.constructorCall.binding.original())); if (targetConstructor == null) return false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=358762 if (this == targetConstructor) return true; // direct case if (visited == null) { // lazy allocation visited = new ArrayList(1); } else { int index = visited.indexOf(this); if (index >= 0) return index == 0; // only blame if directly part of the cycle } visited.add(this); return targetConstructor.isRecursive(visited); }
internalGenerateCode(classScope, classFile); } catch (AbortMethod e) { if (e.compilationResult == CodeStream.RESTART_IN_WIDE_MODE) { classFile.methodCount--; internalGenerateCode(classScope, classFile); // restart method generation } catch (AbortMethod e2) { int problemsLength;
generateSyntheticFieldInitializationsIfNecessary(this.scope, codeStream, declaringClass); generateSyntheticFieldInitializationsIfNecessary(this.scope, codeStream, declaringClass);
if (isRecursive(null /*lazy initialized visited list*/)) { this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall); analyseArguments(flowInfo);
int argumentsLength = argumentTypes.length; ConstructorDeclaration constructor = new ConstructorDeclaration(this.compilationResult); constructor.selector = new char[] { 'x' }; //no maining constructor.sourceStart = this.sourceStart; constructor.bindArguments(); constructor.constructorCall.resolve(constructor.scope);
if (isRecursive(null /*lazy initialized visited list*/)) { this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall); analyseArguments(classScope.environment(), flowInfo, this.arguments, this.binding); } else if (field.isNonNull() || field.type.isFreeTypeVariable()) { FieldDeclaration fieldDecl = this.scope.referenceType().declarationOf(field.original()); if (!isValueProvidedUsingAnnotation(fieldDecl)) this.scope.problemReporter().uninitializedNonNullField( field,
if (isRecursive(null /*lazy initialized visited list*/)) { this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall); analyseArguments(flowInfo, this.arguments, this.binding); else analyseArguments18(flowInfo, this.arguments, this.binding); } else if (field.isNonNull()) { FieldDeclaration fieldDecl = this.scope.referenceType().declarationOf(field.original()); if (!isValueProvidedUsingAnnotation(fieldDecl)) this.scope.problemReporter().uninitializedNonNullField( field,
public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) { this.handle( IProblem.InterfaceCannotHaveConstructors, NoArgument, NoArgument, constructor.sourceStart, constructor.sourceEnd, constructor, constructor.compilationResult()); } public void interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl) {
public StringBuffer printBody(int indent, StringBuffer output) { output.append(" {"); //$NON-NLS-1$ if (this.constructorCall != null) { output.append('\n'); this.constructorCall.printStatement(indent, output); } if (this.statements != null) { for (int i = 0; i < this.statements.length; i++) { output.append('\n'); this.statements[i].printStatement(indent, output); } } output.append('\n'); printIndent(indent == 0 ? 0 : indent - 1, output).append('}'); return output; }
public void unhandledException(TypeBinding exceptionType, ASTNode location) { boolean insideDefaultConstructor = (this.referenceContext instanceof ConstructorDeclaration) && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall) && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper); this.handle( insideDefaultConstructor ? IProblem.UnhandledExceptionInDefaultConstructor : (insideImplicitConstructorCall ? IProblem.UndefinedConstructorInImplicitConstructorCall : IProblem.UnhandledException), new String[] {new String(exceptionType.readableName())}, new String[] {new String(exceptionType.shortReadableName())}, location.sourceStart, location.sourceEnd); } public void unhandledWarningToken(Expression token) {
public boolean isRecursive(ArrayList visited) { if (this.binding == null || this.constructorCall == null || this.constructorCall.binding == null || this.constructorCall.isSuperAccess() || !this.constructorCall.binding.isValidBinding()) { return false; } ConstructorDeclaration targetConstructor = ((ConstructorDeclaration)this.scope.referenceType().declarationOf(this.constructorCall.binding.original())); if (this == targetConstructor) return true; // direct case if (visited == null) { // lazy allocation visited = new ArrayList(1); } else { int index = visited.indexOf(this); if (index >= 0) return index == 0; // only blame if directly part of the cycle } visited.add(this); return targetConstructor.isRecursive(visited); }
try { problemResetPC = classFile.contentsOffset; internalGenerateCode(classScope, classFile); restart = false; } catch (AbortMethod e) {