Lines 4126-4209
Link Here
|
4126 |
return false; |
4126 |
return false; |
4127 |
} |
4127 |
} |
4128 |
|
4128 |
|
4129 |
/* |
|
|
4130 |
* Print comments to get proper line number |
4131 |
*/ |
4132 |
this.scribe.printComment(); |
4133 |
int line = this.scribe.line; |
4134 |
|
4135 |
this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); |
4136 |
|
4137 |
if (this.scribe.line > line) { |
4138 |
// annotations introduced new line, but this is not a line wrapping |
4139 |
// see 158267 |
4140 |
line = this.scribe.line; |
4141 |
} |
4142 |
this.scribe.space(); |
4143 |
|
4144 |
TypeParameter[] typeParameters = methodDeclaration.typeParameters; |
4145 |
if (typeParameters != null) { |
4146 |
this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_parameters); |
4147 |
if (this.preferences.insert_space_after_opening_angle_bracket_in_type_parameters) { |
4148 |
this.scribe.space(); |
4149 |
} |
4150 |
int length = typeParameters.length; |
4151 |
for (int i = 0; i < length - 1; i++) { |
4152 |
typeParameters[i].traverse(this, methodDeclaration.scope); |
4153 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_parameters); |
4154 |
if (this.preferences.insert_space_after_comma_in_type_parameters) { |
4155 |
this.scribe.space(); |
4156 |
} |
4157 |
} |
4158 |
typeParameters[length - 1].traverse(this, methodDeclaration.scope); |
4159 |
if (isClosingGenericToken()) { |
4160 |
this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_parameters); |
4161 |
} |
4162 |
if (this.preferences.insert_space_after_closing_angle_bracket_in_type_parameters) { |
4163 |
this.scribe.space(); |
4164 |
} |
4165 |
} |
4166 |
|
4167 |
/* |
4129 |
/* |
4168 |
* Print the method return type |
4130 |
* Print comments to get proper line number |
4169 |
*/ |
4131 |
*/ |
4170 |
final TypeReference returnType = methodDeclaration.returnType; |
4132 |
this.scribe.printComment(); |
|
|
4133 |
int line = this.scribe.line; |
4134 |
|
4135 |
// Create alignment |
4136 |
Alignment methodDeclAlignment = this.scribe.createAlignment( |
4137 |
"methodDeclaration",//$NON-NLS-1$ |
4138 |
this.preferences.alignment_for_method_declaration, |
4139 |
Alignment.R_INNERMOST, |
4140 |
3, |
4141 |
this.scribe.scanner.currentPosition); |
4142 |
this.scribe.enterAlignment(methodDeclAlignment); |
4143 |
boolean ok = false; |
4171 |
final MethodScope methodDeclarationScope = methodDeclaration.scope; |
4144 |
final MethodScope methodDeclarationScope = methodDeclaration.scope; |
|
|
4145 |
do { |
4146 |
try { |
4172 |
|
4147 |
|
4173 |
if (returnType != null) { |
4148 |
this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); |
4174 |
returnType.traverse(this, methodDeclarationScope); |
4149 |
int fragmentIndex = 0; |
4175 |
} |
4150 |
this.scribe.alignFragment(methodDeclAlignment, fragmentIndex); |
4176 |
/* |
4151 |
|
4177 |
* Print the method name |
4152 |
if (this.scribe.line > line) { |
4178 |
*/ |
4153 |
// annotations introduced new line, but this is not a line wrapping |
4179 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
4154 |
// see 158267 |
|
|
4155 |
line = this.scribe.line; |
4156 |
} |
4157 |
this.scribe.space(); |
4158 |
|
4159 |
TypeParameter[] typeParameters = methodDeclaration.typeParameters; |
4160 |
if (typeParameters != null) { |
4161 |
this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_parameters); |
4162 |
if (this.preferences.insert_space_after_opening_angle_bracket_in_type_parameters) { |
4163 |
this.scribe.space(); |
4164 |
} |
4165 |
int length = typeParameters.length; |
4166 |
for (int i = 0; i < length - 1; i++) { |
4167 |
typeParameters[i].traverse(this, methodDeclaration.scope); |
4168 |
this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_parameters); |
4169 |
if (this.preferences.insert_space_after_comma_in_type_parameters) { |
4170 |
this.scribe.space(); |
4171 |
} |
4172 |
} |
4173 |
typeParameters[length - 1].traverse(this, methodDeclaration.scope); |
4174 |
if (isClosingGenericToken()) { |
4175 |
this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_parameters); |
4176 |
} |
4177 |
if (this.preferences.insert_space_after_closing_angle_bracket_in_type_parameters) { |
4178 |
this.scribe.space(); |
4179 |
} |
4180 |
this.scribe.alignFragment(methodDeclAlignment, ++fragmentIndex); |
4181 |
} |
4180 |
|
4182 |
|
4181 |
formatMethodArguments( |
4183 |
/* |
4182 |
methodDeclaration, |
4184 |
* Print the method return type |
4183 |
this.preferences.insert_space_before_opening_paren_in_method_declaration, |
4185 |
*/ |
4184 |
this.preferences.insert_space_between_empty_parens_in_method_declaration, |
4186 |
final TypeReference returnType = methodDeclaration.returnType; |
4185 |
this.preferences.insert_space_before_closing_paren_in_method_declaration, |
4187 |
|
4186 |
this.preferences.insert_space_after_opening_paren_in_method_declaration, |
4188 |
if (returnType != null) { |
4187 |
this.preferences.insert_space_before_comma_in_method_declaration_parameters, |
4189 |
returnType.traverse(this, methodDeclarationScope); |
4188 |
this.preferences.insert_space_after_comma_in_method_declaration_parameters, |
4190 |
} |
4189 |
this.preferences.alignment_for_parameters_in_method_declaration); |
4191 |
this.scribe.alignFragment(methodDeclAlignment, ++fragmentIndex); |
4190 |
|
4192 |
|
4191 |
/* |
4193 |
/* |
4192 |
* Check for extra dimensions |
4194 |
* Print the method name |
4193 |
*/ |
4195 |
*/ |
4194 |
int extraDimensions = getDimensions(); |
4196 |
this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true); |
4195 |
if (extraDimensions != 0) { |
4197 |
|
4196 |
for (int i = 0; i < extraDimensions; i++) { |
4198 |
// Format arguments |
4197 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET); |
4199 |
formatMethodArguments( |
4198 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET); |
4200 |
methodDeclaration, |
4199 |
} |
4201 |
this.preferences.insert_space_before_opening_paren_in_method_declaration, |
4200 |
} |
4202 |
this.preferences.insert_space_between_empty_parens_in_method_declaration, |
|
|
4203 |
this.preferences.insert_space_before_closing_paren_in_method_declaration, |
4204 |
this.preferences.insert_space_after_opening_paren_in_method_declaration, |
4205 |
this.preferences.insert_space_before_comma_in_method_declaration_parameters, |
4206 |
this.preferences.insert_space_after_comma_in_method_declaration_parameters, |
4207 |
this.preferences.alignment_for_parameters_in_method_declaration); |
4208 |
|
4209 |
/* |
4210 |
* Check for extra dimensions |
4211 |
*/ |
4212 |
int extraDimensions = getDimensions(); |
4213 |
if (extraDimensions != 0) { |
4214 |
for (int i = 0; i < extraDimensions; i++) { |
4215 |
this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET); |
4216 |
this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET); |
4217 |
} |
4218 |
} |
4201 |
|
4219 |
|
4202 |
formatThrowsClause( |
4220 |
// Format throws |
4203 |
methodDeclaration, |
4221 |
formatThrowsClause( |
4204 |
this.preferences.insert_space_before_comma_in_method_declaration_throws, |
4222 |
methodDeclaration, |
4205 |
this.preferences.insert_space_after_comma_in_method_declaration_throws, |
4223 |
this.preferences.insert_space_before_comma_in_method_declaration_throws, |
4206 |
this.preferences.alignment_for_throws_clause_in_method_declaration); |
4224 |
this.preferences.insert_space_after_comma_in_method_declaration_throws, |
|
|
4225 |
this.preferences.alignment_for_throws_clause_in_method_declaration); |
4226 |
ok = true; |
4227 |
} catch (AlignmentException e) { |
4228 |
this.scribe.redoAlignment(e); |
4229 |
} |
4230 |
} while (!ok); |
4231 |
this.scribe.exitAlignment(methodDeclAlignment, true); |
4207 |
|
4232 |
|
4208 |
if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract() && ((methodDeclaration.modifiers & ExtraCompilerModifiers.AccSemicolonBody) == 0)) { |
4233 |
if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract() && ((methodDeclaration.modifiers & ExtraCompilerModifiers.AccSemicolonBody) == 0)) { |
4209 |
/* |
4234 |
/* |
Lines 4249-4254
Link Here
|
4249 |
} |
4274 |
} |
4250 |
return false; |
4275 |
return false; |
4251 |
} |
4276 |
} |
|
|
4277 |
|
4252 |
public boolean visit(NormalAnnotation annotation, BlockScope scope) { |
4278 |
public boolean visit(NormalAnnotation annotation, BlockScope scope) { |
4253 |
this.scribe.printNextToken(TerminalTokens.TokenNameAT); |
4279 |
this.scribe.printNextToken(TerminalTokens.TokenNameAT); |
4254 |
if (this.preferences.insert_space_after_at_in_annotation) { |
4280 |
if (this.preferences.insert_space_after_at_in_annotation) { |