Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2001-08-22 16:39:44 +0000
committerPhilipe Mulet2001-08-22 16:39:44 +0000
commitba238895da0e9d116073a555bfb1c09f876bedf2 (patch)
tree69061fb728534c374a04080cf2e759ddd041f6c4
parenta1b8b888d8c8c040023fcd2856f96f5ad6c69b3e (diff)
downloadeclipse.jdt.core-ba238895da0e9d116073a555bfb1c09f876bedf2.tar.gz
eclipse.jdt.core-ba238895da0e9d116073a555bfb1c09f876bedf2.tar.xz
eclipse.jdt.core-ba238895da0e9d116073a555bfb1c09f876bedf2.zip
mixing case of properties filesv_0_129_01_(1_0_stream)_candidate133
-rw-r--r--org.eclipse.jdt.core/.classpath9
-rw-r--r--org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java207
-rw-r--r--org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java141
-rw-r--r--org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/Util.java97
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java2
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java2
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java10
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java4
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java8
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java433
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties58
-rw-r--r--org.eclipse.jdt.core/build.properties4
-rw-r--r--org.eclipse.jdt.core/changes.txt173
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java2202
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java76
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java11
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java12
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java4
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java10
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java9
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java8
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java7
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/CompletionOptions.java74
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java181
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/options.properties11
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java12
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java4
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java10
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java4
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java6
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java2
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java11
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java4804
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java816
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java668
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java19
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/HierarchyResolver.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java23
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java24
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java146
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java28
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java14
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java303
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java28
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java190
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java25
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java93
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java219
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java14
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java37
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java88
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java422
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java105
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java107
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java730
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ConfigurableProblems.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java40
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java37
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/options.properties84
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java54
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java1448
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java14
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java11
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java2033
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java103
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java19
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java58
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java1989
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java35
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java441
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java510
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalSymbols.java211
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rscbin34088 -> 35746 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rscbin33672 -> 35252 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rscbin1184 -> 1174 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rscbin2016 -> 2004 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rscbin618 -> 612 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemIrritants.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java60
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties235
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties61
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java2
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java148
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java4
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java26
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java13
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java20
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java2
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java28
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java26
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java100
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java22
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java2
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java6
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java40
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java3847
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java98
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java84
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties59
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java24
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java9
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java217
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.ini400
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java2102
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java48
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java16
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java20
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java16
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java282
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java14
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java14
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java44
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java17
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java426
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java86
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java224
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java7
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java18
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Problem.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java561
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java48
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetOutputLocationOperation.java59
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java968
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java34
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/DeltaKey.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMemberHandle.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMethodCollaboratorIndictment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractNode.java14
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ArrayTypeHandleImpl.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BatchImageBuilder.java11
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BuildNotifier.java24
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ClassOrInterfaceHandleImplSWH.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/CompilerCompilationUnit.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConstructorImpl.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConvertedCompilationResult.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java40
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DependencyGraph.java16
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldCollaboratorIndictment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldImpl.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageBuilderInternalException.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageContextImpl.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImpl.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImplSWH.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IncrementalImageBuilder.java37
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IndictmentSet.java18
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JCUNode.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaBuilder.java28
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaDevelopmentContextImpl.java34
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MarkerProblemReporter.java47
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodCollaboratorIndictment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodImpl.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ModifiedBuilderType.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NamespaceNode.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NewBuilderType.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NonStateSpecificHandleImpl.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OldBuilderType.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OrderedSet.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImpl.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImplSWH.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMap.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMapEntry.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PathMap.java14
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PrimitiveTypeHandleImpl.java38
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemDetailImpl.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemFactory.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemTable.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectBinaryOutput.java7
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectResourceCopier.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ReportCardImpl.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceElementTable.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceEntry.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceFragmentImpl.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateImpl.java200
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnap.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapConstantPool.java58
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapV5.java36
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeCollaboratorIndictment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeHierarchyIndictment.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImpl.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImplSWH.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeNode.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeStructureEntry.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/UnmodifiedBuilderType.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/WorkQueue.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ZipNode.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java24
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java19
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java20
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java26
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java22
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java22
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/lookup/ReferenceInfo.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties (renamed from org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Messages.properties)3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java14
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DiskCache.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java34
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java8
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LookupTable.java24
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringMatcher.java4
-rw-r--r--org.eclipse.jdt.core/plugin.jars1
-rw-r--r--org.eclipse.jdt.core/scripts/pluginUpdate.xml1
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java8
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java6
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/HashtableOfObject.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java12
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ObjectVector.java4
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java6
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java8
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java16
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java44
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java26
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java12
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java20
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java2
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java176
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java207
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java157
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java251
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java1313
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java61
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java158
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java195
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java26
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java120
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java63
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java29
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java280
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java309
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java204
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java54
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java128
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java160
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java426
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties6
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java20
449 files changed, 16255 insertions, 20821 deletions
diff --git a/org.eclipse.jdt.core/.classpath b/org.eclipse.jdt.core/.classpath
index 8762fa250c..51c65a57e7 100644
--- a/org.eclipse.jdt.core/.classpath
+++ b/org.eclipse.jdt.core/.classpath
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="lib" path="/org.eclipse.core.resources/resources.jar" sourcepath="/org.eclipse.core.resources/resourcessrc.zip"/>
+ <classpathentry kind="lib"
+ path="/org.eclipse.core.resources/resources.jar" sourcepath="/org.eclipse.core.resources/resourcessrc.zip"/>
<classpathentry kind="lib" path="/org.apache.xerces/xerces.jar"/>
- <classpathentry kind="lib" path="/org.eclipse.core.runtime/runtime.jar" sourcepath="/org.eclipse.core.runtime/runtimesrc.zip"/>
+ <classpathentry kind="lib"
+ path="/org.eclipse.core.runtime/runtime.jar" sourcepath="/org.eclipse.core.runtime/runtimesrc.zip"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
- <classpathentry kind="src" path="Eclipse Java Ant Compiler"/>
<classpathentry kind="src" path="Eclipse Java Batch Compiler"/>
<classpathentry kind="src" path="Eclipse Java Code Assist"/>
<classpathentry kind="src" path="Eclipse Java Compiler"/>
@@ -12,7 +13,5 @@
<classpathentry kind="src" path="Eclipse Java Evaluation"/>
<classpathentry kind="src" path="Eclipse Java Model"/>
<classpathentry kind="src" path="Eclipse Java Formatter"/>
- <classpathentry kind="lib" path="/org.eclipse.ant.core/ant.jar"/>
- <classpathentry kind="lib" path="/org.eclipse.ant.core/antsupport.jar" sourcepath="/org.eclipse.ant.core/antsupportsrc.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java b/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java
deleted file mode 100644
index 5e4b25e0dd..0000000000
--- a/org.eclipse.jdt.core/ant/org/eclipse/jdt/core/ant/Jdtcom.java
+++ /dev/null
@@ -1,207 +0,0 @@
-package org.eclipse.jdt.core.ant;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
-import org.apache.tools.ant.types.*;
-import org.eclipse.jdt.internal.compiler.batch.Main;
-import org.eclipse.jdt.internal.core.ant.*;
-
-public class Jdtcom extends MatchingTask {
- private Path src;
- private Path classpath;
- private File dest;
-
- private StringBuffer arguments;
-
- public Jdtcom(){
- arguments = new StringBuffer();
- }
-
- public void execute() throws BuildException {
- if(src == null)
- throw new BuildException(Util.bind("jdtcom.source")); //$NON-NLS-1$
- if(dest == null)
- throw new BuildException(Util.bind("jdtcom.destination")); //$NON-NLS-1$
-
- arguments.append(" -d "); //$NON-NLS-1$
- arguments.append(dest.getAbsolutePath());
-
- if(classpath != null){
- arguments.append(" -classpath "); //$NON-NLS-1$
- String[] classpathList = classpath.list();
- for(int i = 0 ; i < classpathList.length ; i++){
- File pathElement = project.resolveFile(classpathList[i]);
- if(!pathElement.exists())
- throw new BuildException(Util.bind("jdtcom.classpath",pathElement.getAbsolutePath())); //$NON-NLS-1$
- if(i != 0)
- arguments.append(";"); //$NON-NLS-1$
- arguments.append(pathElement);
- }
- }
-
- String[] srcList = src.list();
- for(int i = 0 ; i < srcList.length ; i++){
- File file = project.resolveFile(srcList[i]);
- if(!file.exists())
- throw new BuildException(Util.bind("jdtcom.sourcepath",file.getAbsolutePath())); //$NON-NLS-1$
- if(!file.isDirectory())
- throw new BuildException(Util.bind("jdtcom.sourcedir",file.getAbsolutePath())); //$NON-NLS-1$
- DirectoryScanner ds = getDirectoryScanner(file);
- String[] files = ds.getIncludedFiles();
- for(int j = 0; j < files.length ; j++){
- if(files[j].endsWith(".java")){ //$NON-NLS-1$
- arguments.append(" "); //$NON-NLS-1$
- arguments.append(new File(file,files[j]).getAbsolutePath());
- }
- }
- }
-
- try {
- Main.compile(arguments.toString(),new AntPrintWriter(this));
- }
- catch(Exception e){
- throw new BuildException("Jdtcom",e); //$NON-NLS-1$
- }
- log("FINISH"); //$NON-NLS-1$
- }
-
- public void setProceedonerror(boolean proceed){
- if(proceed)
- arguments.append(" -proceedOnError"); //$NON-NLS-1$
- }
-
- public void setTime(boolean time){
- if(time)
- arguments.append(" -time"); //$NON-NLS-1$
- }
-
- public void setVersion(boolean version){
- if(version)
- arguments.append(" -version"); //$NON-NLS-1$
- }
-
- public void setNoimporterror(boolean noimporterror){
- if(noimporterror)
- arguments.append(" -noImportError"); //$NON-NLS-1$
- }
-
- public void setVerbose(boolean verbose){
- if(verbose)
- arguments.append(" -verbose"); //$NON-NLS-1$
- }
-
- public void setReferenceinfo(boolean referenceinfo){
- if(referenceinfo)
- arguments.append(" -referenceInfo"); //$NON-NLS-1$
- }
-
- public void setPreservealllocals(boolean preservealllocals){
- if(preservealllocals)
- arguments.append(" -preserveAllLocals"); //$NON-NLS-1$
- }
-
- public void setTarget(String target){
- if (!target.equals("1.1") && !target.equals("1.2")) //$NON-NLS-2$ //$NON-NLS-1$
- throw new BuildException(Util.bind("jdtcom.target")); //$NON-NLS-1$
- arguments.append(" -target "); //$NON-NLS-1$
- arguments.append(target);
- }
-
- public void setLog(File log){
- try {
- new PrintWriter(new FileOutputStream(log.getAbsolutePath(), false));
- } catch(IOException e){
- throw new BuildException(Util.bind("jdtcom.log",log.getAbsolutePath())); //$NON-NLS-1$
- }
- arguments.append(" -log "); //$NON-NLS-1$
- arguments.append(log.getAbsolutePath());
- }
-
- public void setRepeat(int repeat){
- if(repeat < 0)
- throw new BuildException(Util.bind("jdtcom.repeat")); //$NON-NLS-1$
- arguments.append(" -repeat "); //$NON-NLS-1$
- arguments.append(String.valueOf(repeat));
- }
-
- public void setWarning(String warning){
- if(warning.equals("no")){ //$NON-NLS-1$
- arguments.append(" -nowarn"); //$NON-NLS-1$
- }
- else{
- StringTokenizer tokenizer = new StringTokenizer(warning, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (!token.equals("constructorName") && //$NON-NLS-1$
- !token.equals("packageDefaultMethod") && //$NON-NLS-1$
- !token.equals("maskedCatchBlocks") && //$NON-NLS-1$
- !token.equals("deprecation") && //$NON-NLS-1$
- !token.equals("unusedLocals") && //$NON-NLS-1$
- !token.equals("unusedArguments") && //$NON-NLS-1$
- !token.equals("syntheticAccess") && //$NON-NLS-1$
- !token.equals("nls")) //$NON-NLS-1$
- throw new BuildException(Util.bind("jdtcom.warning")); //$NON-NLS-1$
- }
- arguments.append(" -warn:"+warning); //$NON-NLS-1$
- }
- }
-
- public void setDebug(String debug){
- if(debug.equals("no")){ //$NON-NLS-1$
- arguments.append(" -g:none"); //$NON-NLS-1$
- }
- else if (debug.equals("all")){ //$NON-NLS-1$
- arguments.append(" -g"); //$NON-NLS-1$
- }
- else{
- StringTokenizer tokenizer = new StringTokenizer(debug, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (!token.equals("vars") && !token.equals("lines") && !token.equals("source")) //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
- throw new BuildException(Util.bind("jdtcom.debug")); //$NON-NLS-1$
- }
- arguments.append(" -g:"+debug); //$NON-NLS-1$
- }
- }
-
- public void setDestdir(File dest){
- this.dest = dest;
- }
-
- public void setClasspath(Path path){
- if (classpath == null) {
- classpath = path;
- }
- classpath.append(path);
- }
-
- public Path createClasspath() {
- if (classpath == null) {
- classpath = new Path(project);
- }
- return classpath.createPath();
- }
-
- public void setSrcdir(Path path){
- if (src == null) {
- src = path;
- }
- src.append(path);
- }
-
- public Path createSrc() {
- if (src == null) {
- src = new Path(project);
- }
- return src.createPath();
- }
-}
-
diff --git a/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java b/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java
deleted file mode 100644
index 32264f1137..0000000000
--- a/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/AntPrintWriter.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.eclipse.jdt.internal.core.ant;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.*;
-
-import org.apache.tools.ant.*;
-
-public class AntPrintWriter extends PrintWriter {
- private Task task;
- private String currentLine;
-
- public AntPrintWriter(Task t){
- super(System.out);
- task = t;
- currentLine = ""; //$NON-NLS-1$
- }
-
- public void flush() {
- task.log(currentLine);
- currentLine = ""; //$NON-NLS-1$
- }
-
- public void close() {
- flush();
- }
-
- public void write(int c) {
- currentLine += String.valueOf(c);
- }
-
- public void write(char buf[], int off, int len) {
- currentLine += new String(buf).substring(off,off+len);
- }
-
- public void write(char buf[]) {
- write(buf, 0, buf.length);
- }
-
-
- public void write(String s, int off, int len) {
- currentLine += s.substring(off,off+len);
- }
-
- public void write(String s) {
- write(s, 0, s.length());
- }
-
- public void print(boolean b) {
- write(b ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void print(char c) {
- write(String.valueOf(c));
- }
-
- public void print(int i) {
- write(String.valueOf(i));
- }
-
- public void print(long l) {
- write(String.valueOf(l));
- }
-
- public void print(float f) {
- write(String.valueOf(f));
- }
-
- public void print(double d) {
- write(String.valueOf(d));
- }
-
- public void print(char s[]) {
- write(s);
- }
-
-
- public void print(String s) {
- if (s == null) {
- s = "null"; //$NON-NLS-1$
- }
- write(s);
- }
-
- public void print(Object obj) {
- write(String.valueOf(obj));
- }
-
- public void println() {
- flush();
- }
-
- public void println(boolean x) {
- print(x);
- println();
- }
-
- public void println(char x) {
- print(x);
- println();
- }
-
- public void println(int x) {
- print(x);
- println();
- }
-
- public void println(long x) {
- print(x);
- println();
- }
-
- public void println(float x) {
- print(x);
- println();
- }
-
- public void println(double x) {
- print(x);
- println();
- }
-
- public void println(char x[]) {
- print(x);
- println();
- }
-
- public void println(String x) {
- print(x);
- println();
- }
-
- public void println(Object x) {
- print(x);
- println();
- }
-}
-
diff --git a/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/Util.java b/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/Util.java
deleted file mode 100644
index 83da97dca6..0000000000
--- a/org.eclipse.jdt.core/ant/org/eclipse/jdt/internal/core/ant/Util.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.eclipse.jdt.internal.core.ant;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-
-public class Util {
-
-
- /* Bundle containing messages */
- protected static ResourceBundle bundle;
- private final static String bundleName = "org.eclipse.jdt.internal.core.ant.Messages"; //$NON-NLS-1$
-
-
- static {
- relocalize();
- }
-
-/**
- * Lookup the message with the given ID in this catalog
- */
-public static String bind(String id) {
- return bind(id, (String[])null);
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
-public static String bind(String id, String[] bindings) {
- if (id == null)
- return "No message available"; //$NON-NLS-1$
- String message = null;
- try {
- message = bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully by just returning
- // the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
- }
- if (bindings == null)
- return message;
- int length = message.length();
- int start = -1;
- int end = length;
- StringBuffer output = new StringBuffer(80);
- while (true) {
- if ((end = message.indexOf('{', start)) > -1) {
- output.append(message.substring(start + 1, end));
- if ((start = message.indexOf('}', end)) > -1) {
- int index = -1;
- try {
- index = Integer.parseInt(message.substring(end + 1, start));
- output.append(bindings[index]);
- } catch (NumberFormatException nfe) {
- output.append(message.substring(end + 1, start + 1));
- } catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
- }
- } else {
- output.append(message.substring(end, length));
- break;
- }
- } else {
- output.append(message.substring(start + 1, length));
- break;
- }
- }
- return output.toString();
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
-public static String bind(String id, String binding) {
- return bind(id, new String[] {binding});
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
-public static String bind(String id, String binding1, String binding2) {
- return bind(id, new String[] {binding1, binding2});
-}
-
-/**
- * Creates a NLS catalog for the given locale.
- */
-public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
-}
-}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
index 959480fd08..6d1e55cd76 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
@@ -75,6 +75,6 @@ public NameEnvironmentAnswer readJavaFile(String fileName, char[][] packageName)
return new NameEnvironmentAnswer(new CompilationUnit(null, fullName));
}
public String toString() {
- return "ClasspathDirectory " + path; //$NON-NLS-1$
+ return "ClasspathDirectory "/*nonNLS*/ + path;
}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
index 70c5634b92..5bdafd41d9 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
@@ -80,6 +80,6 @@ public NameEnvironmentAnswer readJavaFile(String filename, char[][] packageName)
}
}
public String toString() {
- return "Classpath for jar file " + zipFile; //$NON-NLS-1$
+ return "Classpath for jar file "/*nonNLS*/ + zipFile;
}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
index b23c86baa9..bf7d5f5e4b 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
@@ -16,11 +16,11 @@ public CompilationUnit(char[] contents, String fileName) {
this.contents = contents;
this.fileName = fileName.toCharArray();
- int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$
- if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$
- start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$
+ int start = fileName.lastIndexOf("/"/*nonNLS*/) + 1;
+ if (start == 0 || start < fileName.lastIndexOf("\\"/*nonNLS*/))
+ start = fileName.lastIndexOf("\\"/*nonNLS*/) + 1;
- int end = fileName.lastIndexOf("."); //$NON-NLS-1$
+ int end = fileName.lastIndexOf("."/*nonNLS*/);
if (end == -1)
end = fileName.length();
@@ -70,6 +70,6 @@ public char[] getMainTypeName() {
return mainTypeName;
}
public String toString() {
- return "CompilationUnit[" + new String(fileName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "CompilationUnit["/*nonNLS*/ + new String(fileName) + "]"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
index b2ab53f2ac..b187763452 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
@@ -12,13 +12,13 @@ public class FileFinder {
public int counter = 0;
public void find(File f, String pattern, boolean verbose) {
if (verbose) {
- System.out.println(Main.bind("scanning.start",f.getAbsolutePath())); //$NON-NLS-1$
+ System.out.println(Main.bind("scanning.start"/*nonNLS*/,f.getAbsolutePath()));
}
find0(f, pattern, verbose);
System.arraycopy(resultFiles, 0, (resultFiles = new String[counter]), 0, counter);
if (verbose) {
System.out.println();
- System.out.println(Main.bind("scanning.done",f.getAbsolutePath())); //$NON-NLS-1$
+ System.out.println(Main.bind("scanning.done"/*nonNLS*/,f.getAbsolutePath()));
}
}
public void find0(File f, String pattern, boolean verbose) {
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index ed8fc7cd9e..265ca32871 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -37,7 +37,7 @@ public FileSystem(String[] classpathNames, String[] initialFileNames) {
if (file.isDirectory()) {
classpaths[i] = new ClasspathDirectory(file);
pathNames[i] = ((ClasspathDirectory) classpaths[i]).path;
- } else if (classpathNames[i].endsWith(".jar") | (classpathNames[i].endsWith(".zip"))) { //$NON-NLS-2$ //$NON-NLS-1$
+ } else if (classpathNames[i].endsWith(".jar"/*nonNLS*/) | (classpathNames[i].endsWith(".zip"/*nonNLS*/))) {
classpaths[i] = new ClasspathJar(file);
pathNames[i] = classpathNames[i].substring(0, classpathNames[i].lastIndexOf('.'));
}
@@ -65,7 +65,7 @@ public FileSystem(String[] classpathNames, String[] initialFileNames) {
for (int i = initialFileNames.length; --i >= 0;) {
String fileName = initialFileNames[i];
String matchingPathName = null;
- if (fileName.lastIndexOf(".") != -1) //$NON-NLS-1$
+ if (fileName.lastIndexOf("."/*nonNLS*/) != -1)
fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove trailing ".java"
fileName = convertPathSeparators(fileName);
@@ -101,8 +101,8 @@ private NameEnvironmentAnswer findClass(char[] name, char[][] packageName) {
return null; // looking for a file which we know was provided at the beginning of the compilation
String filename = new String(name);
- String binaryFilename = filename + ".class"; //$NON-NLS-1$
- String sourceFilename = filename + ".java"; //$NON-NLS-1$
+ String binaryFilename = filename + ".class"/*nonNLS*/;
+ String sourceFilename = filename + ".java"/*nonNLS*/;
for (int i = 0, length = classpaths.length; i < length; i++) {
Classpath classpath = classpaths[i];
boolean binaryExists = classpath.exists(binaryFilename, packageName);
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 69c3e2499c..e2216d4271 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -20,32 +20,27 @@ import java.io.*;
import java.util.*;
public class Main implements ConfigurableProblems, ProblemSeverities {
- private ConfigurableOption[] options;
- private static final String[] problemOption ={
- CompilerOptions.OPTION_ReportMethodWithConstructorName,
- CompilerOptions.OPTION_ReportHiddenCatchBlock,
- CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
- CompilerOptions.OPTION_ReportDeprecation,
- CompilerOptions.OPTION_ReportUnusedLocal,
- CompilerOptions.OPTION_ReportUnusedParameter,
- CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
- CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
- CompilerOptions.OPTION_ReportInvalidImport,
- CompilerOptions.OPTION_ReportUnreachableCode,
- CompilerOptions.OPTION_ReportAssertIdentifier,
- };
- private boolean noWarn = false;
-
PrintWriter out;
boolean systemExitWhenFinished = true;
boolean proceedOnError = false;
+ int warningMask =
+ ParsingOptionalError |
+ MethodWithConstructorName | OverriddenPackageDefaultMethod |
+ UsingDeprecatedAPI | MaskedCatchBlock |
+ UnusedLocalVariable | UnusedArgument |
+ TemporaryWarning | OverriddenPackageDefaultMethod |
+ AccessEmulation;
+ int debugMask = CompilerOptions.Lines | CompilerOptions.Source;
+ int targetJDK = CompilerOptions.JDK1_1;
boolean verbose = false;
boolean produceRefInfo = false;
+ boolean importProblemIsError = true;
boolean timer = false;
boolean showProgress = false;
public long time = 0;
long lineCount;
+ boolean preserveAllLocalVariables = false; // The unused and final local variables will be optimized
String[] filenames;
String[] classpaths;
@@ -56,8 +51,8 @@ public class Main implements ConfigurableProblems, ProblemSeverities {
int globalErrorsCount;
int globalWarningsCount;
- String versionID = "0.125.12 (jck1.3a)"; //$NON-NLS-1$
- private static final char[] CLASS_FILE_EXTENSION = ".class".toCharArray(); //$NON-NLS-1$
+ String versionID = "1.0NL"/*nonNLS*/;
+ private static final char[] CLASS_FILE_EXTENSION = ".class"/*nonNLS*/.toCharArray();
int exportedClassFilesCounter;
@@ -68,20 +63,16 @@ public class Main implements ConfigurableProblems, ProblemSeverities {
/* Bundle containing messages */
protected static ResourceBundle bundle;
- private final static String bundleName = "org.eclipse.jdt.internal.compiler.batch.Messages"; //$NON-NLS-1$
+ private final static String bundleName = "org.eclipse.jdt.internal.compiler.batch.Messages"/*nonNLS*/;
static {
- String ver = System.getProperty("java.version"); //$NON-NLS-1$
- JDK1_1 = ((ver != null) && ver.startsWith("1.1")); //$NON-NLS-1$
+ String ver = System.getProperty("java.version"/*nonNLS*/);
+ JDK1_1 = ((ver != null) && ver.startsWith("1.1"/*nonNLS*/));
relocalize();
}
-
- private boolean proceed = true;
-
protected Main(PrintWriter writer, boolean systemExitWhenFinished) {
this.out = writer;
this.systemExitWhenFinished = systemExitWhenFinished;
exportedClassFilesCounter = 0;
- options = Compiler.getDefaultOptions(Locale.getDefault());
}
/*
* Low-level API performing the actual compilation
@@ -90,73 +81,71 @@ protected void compile(String[] argv) {
// decode command line arguments
try {
configure(argv);
- if(proceed){
- if (showProgress) out.print(Main.bind("progress.compiling")); //$NON-NLS-1$
- for (int i = 0; i < repetitions; i++){
- globalProblemsCount = 0;
- globalErrorsCount = 0;
- globalWarningsCount = 0;
- lineCount = 0;
-
- if (repetitions > 1){
- out.flush();
- out.println(Main.bind("compile.repetition",String.valueOf(i+1),String.valueOf(repetitions))); //$NON-NLS-1$
+ if (showProgress) System.out.print(Main.bind("progress.compiling"/*nonNLS*/));
+ for (int i = 0; i < repetitions; i++){
+ globalProblemsCount = 0;
+ globalErrorsCount = 0;
+ globalWarningsCount = 0;
+ lineCount = 0;
+ if (repetitions > 1){
+ out.flush();
+ out.println(Main.bind("compile.repetition"/*nonNLS*/,String.valueOf(i+1),String.valueOf(repetitions)));
+ }
+ long startTime = System.currentTimeMillis();
+
+ // request compilation
+ performCompilation();
+ if (timer) {
+ time = System.currentTimeMillis() - startTime;
+ if (lineCount != 0){
+ out.println(Main.bind("compile.instantTime"/*nonNLS*/,new String[]{String.valueOf(lineCount),String.valueOf(time),String.valueOf((((int)((lineCount*10000.0)/time))/10.0))}));
+ } else {
+ out.println(Main.bind("compile.totalTime"/*nonNLS*/,String.valueOf(time)));
+
}
- long startTime = System.currentTimeMillis();
- // request compilation
- performCompilation();
- if (timer) {
-
- time = System.currentTimeMillis() - startTime;
- if (lineCount != 0){
- out.println(Main.bind("compile.instantTime",new String[]{String.valueOf(lineCount),String.valueOf(time),String.valueOf((((int)((lineCount*10000.0)/time))/10.0))})); //$NON-NLS-1$
- } else {
- out.println(Main.bind("compile.totalTime",String.valueOf(time))); //$NON-NLS-1$
- }
+ }
+ if (globalProblemsCount > 0) {
+ if (globalProblemsCount == 1) {
+ out.print(Main.bind("compile.oneProblem"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalProblems"/*nonNLS*/,String.valueOf(globalProblemsCount)));
}
- if (globalProblemsCount > 0) {
- if (globalProblemsCount == 1) {
- out.print(Main.bind("compile.oneProblem")); //$NON-NLS-1$
+ out.print(" ("/*nonNLS*/);
+ if (globalErrorsCount > 0) {
+ if (globalErrorsCount == 1) {
+ out.print(Main.bind("compile.oneError"/*nonNLS*/));
} else {
- out.print(Main.bind("compile.severalProblems",String.valueOf(globalProblemsCount))); //$NON-NLS-1$
+ out.print(Main.bind("compile.severalErrors"/*nonNLS*/,String.valueOf(globalErrorsCount)));
}
- out.print(" ("); //$NON-NLS-1$
+ }
+ if (globalWarningsCount > 0) {
if (globalErrorsCount > 0) {
- if (globalErrorsCount == 1) {
- out.print(Main.bind("compile.oneError")); //$NON-NLS-1$
- } else {
- out.print(Main.bind("compile.severalErrors",String.valueOf(globalErrorsCount))); //$NON-NLS-1$
- }
- }
- if (globalWarningsCount > 0) {
- if (globalErrorsCount > 0) {
- out.print(", "); //$NON-NLS-1$
- }
- if (globalWarningsCount == 1) {
- out.print(Main.bind("compile.oneWarning")); //$NON-NLS-1$
- } else {
- out.print(Main.bind("compile.severalWarnings",String.valueOf(globalWarningsCount))); //$NON-NLS-1$
- }
+ out.print(", "/*nonNLS*/);
}
- out.println(")"); //$NON-NLS-1$
- }
- if (exportedClassFilesCounter != 0 && (this.showProgress || this.timer || this.verbose)) {
- if (exportedClassFilesCounter == 1) {
- out.print(Main.bind("compile.oneClassFileGenerated")); //$NON-NLS-1$
+ if (globalWarningsCount == 1) {
+ out.print(Main.bind("compile.oneWarning"/*nonNLS*/));
} else {
- out.print(Main.bind("compile.severalClassFilesGenerated",String.valueOf(exportedClassFilesCounter))); //$NON-NLS-1$
+ out.print(Main.bind("compile.severalWarnings"/*nonNLS*/,String.valueOf(globalWarningsCount)));
}
}
+ out.println(")"/*nonNLS*/);
+ }
+ if (exportedClassFilesCounter != 0 && (this.showProgress || this.timer || this.verbose)) {
+ if (exportedClassFilesCounter == 1) {
+ out.print(Main.bind("compile.oneClassFileGenerated"/*nonNLS*/));
+ } else {
+ out.print(Main.bind("compile.severalClassFilesGenerated"/*nonNLS*/,String.valueOf(exportedClassFilesCounter)));
+ }
}
- if (showProgress) System.out.println();
}
+ if (showProgress) System.out.println();
if (systemExitWhenFinished){
out.flush();
System.exit(globalErrorsCount > 0 ? -1 : 0);
}
} catch (InvalidInputException e) {
out.println(e.getMessage());
- out.println("------------------------"); //$NON-NLS-1$
+ out.println("------------------------"/*nonNLS*/);
printUsage();
if (systemExitWhenFinished){
System.exit(-1);
@@ -206,7 +195,7 @@ public static void compile(String commandLine, PrintWriter writer) {
argv[count-1] += File.pathSeparator;
insideClasspath = true;
} else {
- tokenizer = new StringTokenizer(subCommandLine, File.pathSeparator + " "); //$NON-NLS-1$
+ tokenizer = new StringTokenizer(subCommandLine, File.pathSeparator + " "/*nonNLS*/);
while (tokenizer.hasMoreTokens()) {
if (count == argv.length) {
System.arraycopy(argv, 0, (argv = new String[count * 2]), 0, count);
@@ -235,7 +224,7 @@ public static void compile(String commandLine, PrintWriter writer) {
}
argv[count++] = commandLine.substring(startIndex, commandLine.length());
} else {
- tokenizer = new StringTokenizer(commandLine.substring(startIndex, commandLine.length()), File.pathSeparator + " "); //$NON-NLS-1$
+ tokenizer = new StringTokenizer(commandLine.substring(startIndex, commandLine.length()), File.pathSeparator + " "/*nonNLS*/);
while (tokenizer.hasMoreTokens()) {
if (count == argv.length) {
System.arraycopy(argv, 0, (argv = new String[count * 2]), 0, count);
@@ -248,31 +237,21 @@ public static void compile(String commandLine, PrintWriter writer) {
System.arraycopy(argv, 0, argv = new String[count], 0, count);
new Main(writer, false).compile(argv);
}
-private void setOptionValueIndex(String id,int valueIndex){
- for(int i = 0 ; i < options.length ; i++){
- if(options[i].getID().equals(id)){
- options[i].setValueIndex(valueIndex);
- return;
- }
- }
-}
-
/*
Decode the command line arguments
*/
private void configure(String[] argv) throws InvalidInputException {
if ((argv == null) || (argv.length == 0))
- throw new InvalidInputException(Main.bind("configure.noSourceFile")); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.noSourceFile"/*nonNLS*/));
final int InsideClasspath = 1;
final int InsideDestinationPath = 2;
final int TargetSetting = 4;
final int InsideLog = 8;
final int InsideRepetition = 16;
- final int InsideSource = 32;
final int Default = 0;
int DEFAULT_SIZE_CLASSPATH = 4;
- boolean warnOptionInUsed = false;
boolean noWarnOptionInUsed = false;
+ boolean warnOptionInUsed = false;
int pathCount = 0;
int index = -1, filesCount = 0, argCount = argv.length;
int mode = Default;
@@ -282,7 +261,7 @@ private void configure(String[] argv) throws InvalidInputException {
while (++index < argCount) {
String currentArg = argv[index].trim();
- if (currentArg.endsWith(".java")) { //$NON-NLS-1$
+ if (currentArg.endsWith(".java"/*nonNLS*/)) {
if (filenames == null) {
filenames = new String[argCount - index];
} else if (filesCount == filenames.length) {
@@ -293,189 +272,169 @@ private void configure(String[] argv) throws InvalidInputException {
mode = Default;
continue;
}
- if (currentArg.equals("-log")) { //$NON-NLS-1$
+ if (currentArg.equals("-log"/*nonNLS*/)) {
if (log != null)
- throw new InvalidInputException(Main.bind("configure.duplicateLog",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.duplicateLog"/*nonNLS*/,currentArg));
mode = InsideLog;
continue;
}
- if (currentArg.equals("-repeat")) { //$NON-NLS-1$
+ if (currentArg.equals("-repeat"/*nonNLS*/)) {
if (repetitions > 0)
- throw new InvalidInputException(Main.bind("configure.duplicateRepeat",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.duplicateRepeat"/*nonNLS*/,currentArg));
mode = InsideRepetition;
continue;
}
- if (currentArg.equals("-source")) { //$NON-NLS-1$
- mode = InsideSource;
- continue;
- }
- if (currentArg.equals("-d")) { //$NON-NLS-1$
+ if (currentArg.equals("-d"/*nonNLS*/)) {
if (destinationPath != null)
- throw new InvalidInputException(Main.bind("configure.duplicateOutputPath",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.duplicateOutputPath"/*nonNLS*/,currentArg));
mode = InsideDestinationPath;
continue;
}
- if (currentArg.equals("-classpath")) { //$NON-NLS-1$
+ if (currentArg.equals("-classpath"/*nonNLS*/)) {
if (pathCount > 0)
- throw new InvalidInputException(Main.bind("configure.duplicateClasspath",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.duplicateClasspath"/*nonNLS*/,currentArg));
classpaths = new String[DEFAULT_SIZE_CLASSPATH];
mode = InsideClasspath;
continue;
}
- if (currentArg.equals("-progress")) { //$NON-NLS-1$
+ if (currentArg.equals("-progress"/*nonNLS*/)) {
mode = Default;
showProgress = true;
continue;
}
- if (currentArg.equals("-proceedOnError")) { //$NON-NLS-1$
+ if (currentArg.equals("-proceedOnError"/*nonNLS*/)) {
mode = Default;
proceedOnError = true;
continue;
}
- if (currentArg.equals("-time")) { //$NON-NLS-1$
+ if (currentArg.equals("-time"/*nonNLS*/)) {
mode = Default;
timer = true;
continue;
}
- if (currentArg.equals("-version") || currentArg.equals("-v")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (currentArg.equals("-version"/*nonNLS*/) || currentArg.equals("-v"/*nonNLS*/)) {
versionIDRequired = true;
continue;
}
- if (currentArg.equals("-help")) { //$NON-NLS-1$
+ if (currentArg.equals("-help"/*nonNLS*/)) {
printUsageRequired = true;
continue;
}
- if (currentArg.equals("-noImportError")) { //$NON-NLS-1$
+ if (currentArg.equals("-noImportError"/*nonNLS*/)) {
mode = Default;
- setOptionValueIndex("org.eclipse.jdt.internal.compiler.Compiler.problemInvalidImport",2); //$NON-NLS-1$
+ importProblemIsError = false;
continue;
}
- if (currentArg.equals("-noExit")) { //$NON-NLS-1$
+ if (currentArg.equals("-noExit"/*nonNLS*/)) {
mode = Default;
systemExitWhenFinished = false;
continue;
}
- if (currentArg.equals("-verbose")) { //$NON-NLS-1$
+ if (currentArg.equals("-verbose"/*nonNLS*/)) {
mode = Default;
verbose = true;
continue;
}
- if (currentArg.equals("-referenceInfo")) { //$NON-NLS-1$
+ if (currentArg.equals("-referenceInfo"/*nonNLS*/)) {
mode = Default;
produceRefInfo = true;
continue;
}
- if (currentArg.startsWith("-g")) { //$NON-NLS-1$
+ if (currentArg.startsWith("-g"/*nonNLS*/)) {
mode = Default;
+ debugMask = 0; // reinitialize the default value
String debugOption = currentArg;
int length = currentArg.length();
if (length == 2) {
- setOptionValueIndex(CompilerOptions.OPTION_LocalVariableAttribute, 0);
- setOptionValueIndex(CompilerOptions.OPTION_LineNumberAttribute, 0);
- setOptionValueIndex(CompilerOptions.OPTION_SourceFileAttribute, 0);
+ debugMask = CompilerOptions.Lines | CompilerOptions.Vars | CompilerOptions.Source;
continue;
}
if (length > 3) {
- setOptionValueIndex(CompilerOptions.OPTION_LocalVariableAttribute, 1);
- setOptionValueIndex(CompilerOptions.OPTION_LineNumberAttribute, 1);
- setOptionValueIndex(CompilerOptions.OPTION_SourceFileAttribute, 1);
- if (length == 7 && debugOption.equals("-g:none")) //$NON-NLS-1$
+ if (length == 7 && debugOption.equals("-g:none"/*nonNLS*/))
continue;
- StringTokenizer tokenizer = new StringTokenizer(debugOption.substring(3, debugOption.length()), ","); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(debugOption.substring(3, debugOption.length()), ","/*nonNLS*/);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
- if (token.equals("vars")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_LocalVariableAttribute, 0);
- } else if (token.equals("lines")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_LineNumberAttribute, 0);
- } else if (token.equals("source")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_SourceFileAttribute, 0);
+ if (token.equals("vars"/*nonNLS*/)) {
+ debugMask |= CompilerOptions.Vars;
+ } else if (token.equals("lines"/*nonNLS*/)) {
+ debugMask |= CompilerOptions.Lines;
+ } else if (token.equals("source"/*nonNLS*/)) {
+ debugMask |= CompilerOptions.Source;
} else {
- throw new InvalidInputException(Main.bind("configure.invalidDebugOption",debugOption)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.invalidDebugOption"/*nonNLS*/,debugOption));
}
}
continue;
}
- throw new InvalidInputException(Main.bind("configure.invalidDebugOption",debugOption)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.invalidDebugOption"/*nonNLS*/,debugOption));
}
- if (currentArg.startsWith("-nowarn")) { //$NON-NLS-1$
+ if (currentArg.startsWith("-nowarn"/*nonNLS*/)) {
noWarnOptionInUsed = true;
- noWarn = true;
if (warnOptionInUsed)
- throw new InvalidInputException(Main.bind("configure.duplicateWarningConfiguration")); //$NON-NLS-1$
- mode = Default;
+ throw new InvalidInputException(Main.bind("configure.duplicateWarningConfiguration"/*nonNLS*/));
+ mode = Default;
+ warningMask = TemporaryWarning; // reinitialize the default value (still see TemporaryWarning)
continue;
}
- if (currentArg.startsWith("-warn")) { //$NON-NLS-1$
+ if (currentArg.startsWith("-warn"/*nonNLS*/)) {
warnOptionInUsed = true;
if (noWarnOptionInUsed)
- throw new InvalidInputException(Main.bind("configure.duplicateWarningConfiguration")); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.duplicateWarningConfiguration"/*nonNLS*/));
mode = Default;
String warningOption = currentArg;
int length = currentArg.length();
- if (length == 10 && warningOption.equals("-warn:none")) { //$NON-NLS-1$
- noWarn = true;
+ if (length == 10 && warningOption.equals("-warn:none"/*nonNLS*/)) {
+ warningMask = TemporaryWarning; // reinitialize the default value (still see TemporaryWarning)
continue;
}
if (length < 6)
- throw new InvalidInputException(Main.bind("configure.invalidWarningConfiguration",warningOption)); //$NON-NLS-1$
- StringTokenizer tokenizer = new StringTokenizer(warningOption.substring(6, warningOption.length()), ","); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.invalidWarningConfiguration"/*nonNLS*/,warningOption));
+ StringTokenizer tokenizer = new StringTokenizer(warningOption.substring(6, warningOption.length()), ","/*nonNLS*/);
int tokenCounter = 0;
-
- setOptionValueIndex(CompilerOptions.OPTION_ReportMethodWithConstructorName, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportHiddenCatchBlock, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportDeprecation, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportUnusedLocal, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportUnusedParameter, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, 2);
- setOptionValueIndex(CompilerOptions.OPTION_ReportAssertIdentifier, 2);
-
+ warningMask = 0; // reinitialize the default value
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
tokenCounter++;
- if (token.equals("constructorName")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportMethodWithConstructorName, 1);
- } else if (token.equals("packageDefaultMethod")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, 1);
- } else if (token.equals("maskedCatchBlocks")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportHiddenCatchBlock, 1);
- } else if (token.equals("deprecation")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportDeprecation, 1);
- } else if (token.equals("unusedLocals")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportUnusedLocal, 1);
- } else if (token.equals("unusedArguments")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportUnusedParameter, 1);
- } else if (token.equals("syntheticAccess")){ //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, 1);
- } else if (token.equals("nls")){ //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, 1);
- } else if (token.equals("assertIdentifier")){ //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_ReportAssertIdentifier, 1);
+ if (token.equals("constructorName"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.MethodWithConstructorName;
+ } else if (token.equals("packageDefaultMethod"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.OverriddenPackageDefaultMethod;
+ } else if (token.equals("maskedCatchBlocks"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.MaskedCatchBlock;
+ } else if (token.equals("deprecation"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.UsingDeprecatedAPI;
+ } else if (token.equals("unusedLocals"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.UnusedLocalVariable;
+ } else if (token.equals("unusedArguments"/*nonNLS*/)) {
+ warningMask |= CompilerOptions.UnusedArgument;
+ } else if (token.equals("syntheticAccess"/*nonNLS*/)){
+ warningMask |= CompilerOptions.AccessEmulation;
+ } else if (token.equals("nls"/*nonNLS*/)){
+ warningMask |= CompilerOptions.NonExternalizedString;
} else {
- throw new InvalidInputException(Main.bind("configure.invalidWarning",token)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.invalidWarning"/*nonNLS*/,token));
}
}
if (tokenCounter == 0)
- throw new InvalidInputException(Main.bind("configure.invalidWarningOption",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.invalidWarningOption"/*nonNLS*/,currentArg));
continue;
}
- if (currentArg.equals("-target")) { //$NON-NLS-1$
+ if (currentArg.equals("-target"/*nonNLS*/)) {
mode = TargetSetting;
continue;
}
- if (currentArg.equals("-preserveAllLocals")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_PreserveUnusedLocal, 0);
+ if (currentArg.equals("-preserveAllLocals"/*nonNLS*/)) {
+ preserveAllLocalVariables = true;
continue;
}
if (mode == TargetSetting) {
- if (currentArg.equals("1.1")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_TargetPlatform, 0);
- } else if (currentArg.equals("1.2")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_TargetPlatform, 1);
+ if (currentArg.equals("1.1"/*nonNLS*/)) {
+ targetJDK = CompilerOptions.JDK1_1;
+ } else if (currentArg.equals("1.2"/*nonNLS*/)) {
+ targetJDK = CompilerOptions.JDK1_2;
} else {
- throw new InvalidInputException(Main.bind("configure.targetJDK",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.targetJDK"/*nonNLS*/,currentArg));
}
mode = Default;
continue;
@@ -489,21 +448,10 @@ private void configure(String[] argv) throws InvalidInputException {
try {
repetitions = Integer.parseInt(currentArg);
if (repetitions <= 0){
- throw new InvalidInputException(Main.bind("configure.repetition",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.repetition"/*nonNLS*/,currentArg));
}
} catch(NumberFormatException e){
- throw new InvalidInputException(Main.bind("configure.repetition",currentArg)); //$NON-NLS-1$
- }
- mode = Default;
- continue;
- }
- if (mode == InsideSource){
- if (currentArg.equals("1.3")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_Source, 0);
- } else if (currentArg.equals("1.4")) { //$NON-NLS-1$
- setOptionValueIndex(CompilerOptions.OPTION_Source, 1);
- } else {
- throw new InvalidInputException(Main.bind("configure.source",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.repetition"/*nonNLS*/,currentArg));
}
mode = Default;
continue;
@@ -531,12 +479,12 @@ private void configure(String[] argv) throws InvalidInputException {
currentArg = currentArg.substring(0, currentArg.length() - File.separator.length());
File dir = new File(currentArg);
if (!dir.isDirectory())
- throw new InvalidInputException(Main.bind("configure.directoryNotExist",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.directoryNotExist"/*nonNLS*/,currentArg));
FileFinder finder = new FileFinder();
try{
- finder.find(dir, ".JAVA", verbose); //$NON-NLS-1$
+ finder.find(dir, ".JAVA"/*nonNLS*/, verbose);
} catch(Exception e){
- throw new InvalidInputException(Main.bind("configure.IOError",currentArg)); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.IOError"/*nonNLS*/,currentArg));
}
if (filenames != null) {
// some source files were specified explicitly
@@ -553,38 +501,27 @@ private void configure(String[] argv) throws InvalidInputException {
continue;
}
- if(noWarn){
- for(int i = 0; i < problemOption.length ; i++){
- for(int j = 0 ; j < options.length ; j++){
- if(options[j].getID().equals(problemOption[i]) && options[j].getValueIndex() == 1){
- options[j].setValueIndex(2);
- }
- }
- }
- }
/*
* Standalone options
*/
if (versionIDRequired) {
- out.println(Main.bind("configure.version",this.versionID)); //$NON-NLS-1$
+ out.println(Main.bind("configure.version"/*nonNLS*/,this.versionID));
out.println();
- proceed = false;
return;
}
if (printUsageRequired) {
printUsage();
- proceed = false;
return;
}
if (filesCount != 0)
System.arraycopy(filenames, 0, (filenames = new String[filesCount]), 0, filesCount);
if (pathCount == 0) {
- String classProp = System.getProperty("LFclasspath"); //$NON-NLS-1$
+ String classProp = System.getProperty("LFclasspath"/*nonNLS*/);
if ((classProp == null) || (classProp.length() == 0)) {
- out.println(Main.bind("configure.noClasspath")); //$NON-NLS-1$
- classProp = "."; //$NON-NLS-1$
+ out.println(Main.bind("configure.noClasspath"/*nonNLS*/));
+ classProp = "."/*nonNLS*/;
}
StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator);
classpaths = new String[tokenizer.countTokens()];
@@ -599,27 +536,26 @@ private void configure(String[] argv) throws InvalidInputException {
for (int i = 0, max = classpaths.length; i < max; i++) {
File file = new File(classpaths[i]);
if (!file.exists())
- throw new InvalidInputException(Main.bind("configure.incorrectClasspath",classpaths[i])); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.incorrectClasspath"/*nonNLS*/,classpaths[i]));
}
if (destinationPath == null) {
- destinationPath = System.getProperty("user.dir"); //$NON-NLS-1$
- } else if ("none".equals(destinationPath)) { //$NON-NLS-1$
+ destinationPath = System.getProperty("user.dir"/*nonNLS*/);
+ } else if ("none"/*nonNLS*/.equals(destinationPath)) {
destinationPath = null;
}
if (filenames == null)
- throw new InvalidInputException(Main.bind("configure.noSource")); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.noSource"/*nonNLS*/));
if (log != null){
try {
out = new PrintWriter(new FileOutputStream(log, false));
} catch(IOException e){
- throw new InvalidInputException(Main.bind("configure.cannotOpenLog")); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("configure.cannotOpenLog"/*nonNLS*/));
}
} else {
showProgress = false;
}
-
if (repetitions == 0) {
repetitions = 1;
}
@@ -648,22 +584,22 @@ protected ICompilerRequestor getBatchRequestor() {
if (problems[i] != null) {
globalProblemsCount++;
if (localErrorCount == 0)
- out.println("----------"); //$NON-NLS-1$
- out.print(globalProblemsCount + ". " + (problems[i].isError() ? Main.bind("requestor.error") : Main.bind("requestor.warning"))); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ out.println("----------"/*nonNLS*/);
+ out.print(globalProblemsCount + ". "/*nonNLS*/ + (problems[i].isError() ? Main.bind("requestor.error"/*nonNLS*/) : Main.bind("requestor.warning"/*nonNLS*/)));
if (problems[i].isError()) {
globalErrorsCount++;
} else {
globalWarningsCount++;
}
- out.print(" "); //$NON-NLS-1$
- out.print(Main.bind("requestor.in",new String(problems[i].getOriginatingFileName()))); //$NON-NLS-1$
+ out.print(" "/*nonNLS*/);
+ out.print(Main.bind("requestor.in"/*nonNLS*/,new String(problems[i].getOriginatingFileName())));
try {
out.println(((DefaultProblem)problems[i]).errorReportSource(compilationResult.compilationUnit));
out.println(problems[i].getMessage());
} catch (Exception e) {
- out.println(Main.bind("requestor.notRetrieveErrorMessage",problems[i].toString())); //$NON-NLS-1$
+ out.println(Main.bind("requestor.notRetrieveErrorMessage"/*nonNLS*/,problems[i].toString()));
}
- out.println("----------"); //$NON-NLS-1$
+ out.println("----------"/*nonNLS*/);
if (problems[i].isError())
localErrorCount++;
}
@@ -684,18 +620,19 @@ protected ICompilerRequestor getBatchRequestor() {
protected CompilationUnit[] getCompilationUnits() throws InvalidInputException {
int fileCount = filenames.length;
CompilationUnit[] units = new CompilationUnit[fileCount];
+
HashtableOfObject knownFileNames = new HashtableOfObject(fileCount);
for (int i = 0; i < fileCount; i++) {
char[] charName = filenames[i].toCharArray();
if (knownFileNames.get(charName) != null){
- throw new InvalidInputException(Main.bind("unit.more",filenames[i])); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("unit.more"/*nonNLS*/,filenames[i]));
} else {
knownFileNames.put(charName, charName);
}
File file = new File(filenames[i]);
if (!file.exists())
- throw new InvalidInputException(Main.bind("unit.missing",filenames[i])); //$NON-NLS-1$
+ throw new InvalidInputException(Main.bind("unit.missing"/*nonNLS*/,filenames[i]));
units[i] = new CompilationUnit(null, filenames[i]);
}
return units;
@@ -725,7 +662,13 @@ protected FileSystem getLibraryAccess() {
* Low-level API performing the actual compilation
*/
protected ConfigurableOption[] getOptions() {
- return options;
+ CompilerOptions options = new CompilerOptions();
+ options.produceDebugAttributes(debugMask);
+ options.preserveAllLocalVariables(preserveAllLocalVariables);
+ options.handleImportProblemAsError(importProblemIsError);
+ options.setWarningThreshold(warningMask);
+ options.setTargetJDK(targetJDK);
+ return options.getConfigurableOptions(Locale.getDefault());
}
protected IProblemFactory getProblemFactory() {
return new DefaultProblemFactory(Locale.getDefault());
@@ -761,7 +704,7 @@ protected void outputClassFiles(CompilationResult unitResult) {
} catch (IOException e) {
String fileName = destinationPath + new String(relativeName);
e.printStackTrace();
- System.out.println(Main.bind("output.noClassFileCreated",fileName)); //$NON-NLS-1$
+ System.out.println(Main.bind("output.noClassFileCreated"/*nonNLS*/,fileName));
}
exportedClassFilesCounter++;
}
@@ -779,15 +722,45 @@ protected void performCompilation() throws InvalidInputException {
getOptions(),
getBatchRequestor(),
getProblemFactory());
- CompilerOptions options = batchCompiler.options;
+ CompilerOptions options = batchCompiler.options;
// set the non-externally configurable options.
options.setVerboseMode(verbose);
options.produceReferenceInfo(produceRefInfo);
+
batchCompiler.compile(getCompilationUnits());
}
private void printUsage() {
- out.println(Main.bind("misc.usage",this.versionID)); //$NON-NLS-1$
+ out.println(Main.bind("misc.usage"/*nonNLS*/,this.versionID));
+ /*out.println(
+ "Eclipse Java Compiler "+ this.versionID + ", Copyright IBM Corp 2000\n\n" +
+ "Usage: <options> <source files | directories>\n\n" +
+ "where options include:\n" +
+ "-version or -v\tdisplays the version number (standalone option)\n" +
+ "-help\tdisplay this help message (standalone option)\n" +
+ "-noExit\tPrevent the compiler to call System.exit at the end of the compilation process\n" +
+ "-classpath <dir 1>;<dir 2>;...;<dir P>\n" +
+ "-d <dir>\tdestination directory\n\t\t, specified '-d none' if you don't want to dump files\n" +
+ "-verbose\tprint accessed/processed compilation units \n" +
+ "-time\t\tdisplay total compilation time" +
+ "\n\t\tand speed if line attributes are enabled\n" +
+ "-log <filename>\tspecify a log file for recording problems\n" +
+ "-progress\t\tshow progress (only in -log mode)\n" +
+ "-g[:<level>]\tspecify the level of details for debug attributes" +
+ "\n\t\t-g\tgenerate all debug info"+
+ "\n\t\t-g:none\tno debug info"+
+ "\n\t\t-g:{lines,vars,source}\tonly some debug info\n" +
+ "-nowarn\t\tdo not report warnings \n" +
+ "-warn:<mask>\tspecify the level of details for warnings\n" +
+ "\t\t-warn:none no warning\n"+
+ "\t\t-warn:{constructorName, packageDefaultMethod, deprecation,\n" +
+ "\t\t\tmaskedCatchBlocks, unusedLocals, unusedArguments, \n" +
+ "\t\t\tsyntheticAccess}\n" +
+ "-noImportError\tdo not report errors on incorrect imports\n" +
+ "-proceedOnError\tkeep compiling when error, \n\t\tdumping class files with problem methods\n" +
+ "-referenceInfo\tcompute reference info\n" +
+ "-preserveAllLocals\trequest code gen preserve all local variables\n" +
+ "-repeat <n>\trepeat compilation process for performance analysis\n");*/
out.flush();
}
@@ -811,14 +784,14 @@ public static String bind(String id) {
*/
public static String bind(String id, String[] bindings) {
if (id == null)
- return "No message available"; //$NON-NLS-1$
+ return "No message available"/*nonNLS*/;
String message = null;
try {
message = bundle.getString(id);
} catch (MissingResourceException e) {
// If we got an exception looking for the message, fail gracefully by just returning
// the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: "+id+" in: "+bundleName; //$NON-NLS-2$ //$NON-NLS-1$
+ return "Missing message: "/*nonNLS*/+id+" in: "/*nonNLS*/+bundleName;
}
if (bindings == null)
return message;
@@ -837,7 +810,7 @@ public static String bind(String id, String[] bindings) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
+ output.append("{missing "/*nonNLS*/ + Integer.toString(index) + "}"/*nonNLS*/);
}
} else {
output.append(message.substring(end, length));
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
new file mode 100644
index 0000000000..6d4bc76b7d
--- /dev/null
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -0,0 +1,58 @@
+### JavaBatchCompiler messages.
+
+### scanning
+scanning.start = Scanning of {0}
+scanning.done = Scanning of {0} DONE
+
+### progress
+progress.compiling = Compiling
+
+### compile
+compile.repetition = Repetition {0}/{1}
+compile.instantTime = Compiled {0} lines in {1} ms ({2} lines/s)
+compile.totalTime = Total compilation time: {0}
+compile.oneProblem = 1 problem
+compile.severalProblems = {0} problems
+compile.oneError = 1 error
+compile.severalErrors = {0} errors
+compile.oneWarning = 1 warning
+compile.severalWarnings = {0} warnings
+compile.oneClassFileGenerated = 1 .class file generated
+compile.severalClassFilesGenerated = {0} .class files generated
+
+### configure
+configure.noSourceFile = no source file specified
+configure.duplicateLog = duplicate log specification: {0}
+configure.duplicateRepeat = duplicate repeat specification: {0}
+configure.duplicateOutputPath = duplicate output path specification: {0}
+configure.duplicateClasspath = duplicate classpath specification: {0}
+configure.invalidDebugOption = invalid debug option: {0}
+configure.duplicateWarningConfiguration = duplicate usage of warning configuration
+configure.invalidWarningConfiguration = invalid warning configuration: {0}
+configure.invalidWarning = invalid warning: {0}
+configure.invalidWarningOption = invalid warning option: {0}
+configure.targetJDK = target JDK is either '1.1' or '1.2': {0}
+configure.repetition = repetition must be a positive integer: {0}
+configure.directoryNotExist = directory does not exist: {0}
+configure.IOError = i/o error : unable to retrieve .JAVA files in directory: {0}
+configure.version = Eclipse Java Compiler {0}, Copyright IBM Corp 2000
+configure.noClasspath = no classpath defined (LF_CLASSPATH), using default directory instead
+configure.incorrectClasspath = incorrect classpath: {0}
+configure.noSource = no source file specified
+configure.cannotOpenLog = cannot open .log file
+
+### requestor
+requestor.error = ERROR
+requestor.warning = WARNING
+requestor.in = in {0}
+requestor.notRetrieveErrorMessage = Cannot retrieve the error message for {0}
+
+### unit
+unit.more = File {0} is specified more than once
+unit.missing = File {0} is missing
+
+### output
+output.noClassFileCreated = No .class file created for file named {0} because of a IOException.
+
+### miscellaneous
+misc.usage = Eclipse Java Compiler {0}, Copyright IBM Corp 2000\n\nUsage: <options> <source files | directories>\n\nwhere options include:\n-version or -v\tdisplays the version number (standalone option)\n-help\tdisplay this help message (standalone option)\n-noExit\tPrevent the compiler to call System.exit at the end of the compilation process\n-classpath <dir 1>;<dir 2>;...;<dir P>\n-d <dir>\tdestination directory, specified '-d none' if you don't want to dump files\n-verbose\tprint accessed/processed compilation units \n-time\t\tdisplay total compilation time and speed if line attributes are enabled\n-log <filename>\tspecify a log file for recording problems\n-progress\t\tshow progress (only in -log mode)\n-g[:<level>]\tspecify the level of details for debug attributes\n\t\t-g\tgenerate all debug info\n\t\t-g:none\tno debug info\n\t\t-g:{lines,vars,source}\tonly some debug info\n-nowarn\t\tdo not report warnings \n-warn:<mask>\tspecify the level of details for warnings\n\t\t-warn:none no warning\n\t\t-warn:{constructorName, packageDefaultMethod, deprecation,\n\t\t\tmaskedCatchBlocks, unusedLocals, unusedArguments, \n\t\t\tsyntheticAccess}\n-noImportError\tdo not report errors on incorrect imports\n-proceedOnError\tkeep compiling when error, dumping class files with problem methods\n-referenceInfo\tcompute reference info\n-preserveAllLocals\trequest code gen preserve all local variables\n-repeat <n>\trepeat compilation process for performance analysis\n
diff --git a/org.eclipse.jdt.core/build.properties b/org.eclipse.jdt.core/build.properties
index f695e22679..58814ddfe1 100644
--- a/org.eclipse.jdt.core/build.properties
+++ b/org.eclipse.jdt.core/build.properties
@@ -4,7 +4,6 @@ build.includes= plugin.xml,\
build.properties,\
scripts/
-build.vaj.Eclipse\ Java\ Ant\ Compiler=Eclipse Java Ant Compiler
build.vaj.Eclipse\ Java\ Batch\ Compiler=Eclipse Java Batch Compiler
build.vaj.Eclipse\ Java\ Code\ Assist=Eclipse Java Code Assist
build.vaj.Eclipse\ Java\ Compiler=Eclipse Java Compiler
@@ -13,8 +12,7 @@ build.vaj.Eclipse\ Java\ Evaluation=Eclipse Java Evaluation
build.vaj.Eclipse\ Java\ Formatter=Eclipse Java Formatter
build.vaj.Eclipse\ Java\ Model=Eclipse Java Model
-source.jdtcore.jar = Eclipse Java Ant Compiler,\
- Eclipse Java Batch Compiler,\
+source.jdtcore.jar = Eclipse Java Batch Compiler,\
Eclipse Java Code Assist,\
Eclipse Java Formatter,\
Eclipse Java Compiler,\
diff --git a/org.eclipse.jdt.core/changes.txt b/org.eclipse.jdt.core/changes.txt
index 1be915b90d..02bc78201d 100644
--- a/org.eclipse.jdt.core/changes.txt
+++ b/org.eclipse.jdt.core/changes.txt
@@ -1,55 +1,14 @@
-STREAM: 2.0
+STREAM: 1.0 NL
-What's new in this drop (since 0.9)
+What's new in this drop
==================================================================================
* JCK1.3a compliant.
* All messages have been externalized.
- * Added 2 new APIs on JavaConventions for classpath validation.
- - IJavaModelStatus validateClasspath(IJavaProject project, IClasspathEntry[] classpath, IPath outputLocation)
- - IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment)
- * Ant Eclipse compiler task added (org.eclipse.jdt.core.ant.Jdtcom)
- * Assertions support enabled: by default the compiler is 1.3 compliant, but it can optionally be turned into source 1.4 mode cf. JavaCore options.
- * Added new APIs on JavaCore so as to change optional settings (compiler, formatter, codeassist, ...).
- - Description of available options is available in JavaCore.ini along with default values.
- - Option settings are globally kept on JavaCore.
-
-PRs Fixed in this Release (since 1.0NL stream)
-==================================================================================
-1GI6T4Y: ITPJCORE:WINNT - NPE in JavaModeManager retrieving workspace options
-1GE4ILR: ITPJCORE:ALL - Eval - Evaluation in Binary Project fails
-1GI3LLC: ITPJCORE:ALL - Incorrect formatting for the new keyword
-1GHU6O5: ITPJCORE:WINNT - RMIC test fail
-1GHH6O7: ITPJCORE:ALL - Need to tune the exception analysis for AssertStatement
-1GHUW7T: ITPJCORE:WIN2000 - Build Problem
-1GI3IG9: ITPJCORE:ALL - internal compiler error involving bogus method/field declaration
-1GHU4PK: ITPJCORE:WINNT - NoSuchMethodError when running program
-1GHONAX: ITPJCORE:WIN2000 - Compiler uses different name lookup for refactoring
-1GEJYAJ: ITPJCORE:WIN2000 - Compiler - Binding of QualifiedNameReference is null
-1GHFHWR: ITPJCORE:ALL - Assertions: CodeAssist and Selection need to be updated
-1GHFHXG: ITPJCORE:ALL - Assertions: Add optional warning on assert identifier
-1GCZ9VM: ITPJCORE:WIN2000 - DCR - Compiler - Batch compiler should be API
-1GHO6QR: ITPJCORE:WINNT - Code Assist - no method completion when return type is secondary one
-1GH0AU7: ITPJCORE:ALL - Eval - VerifyError in scrapbook page
-1GH2R62: ITPJCORE:WIN2000 - Typo in progress message
-1GGYL32: ITPJCORE:ALL - Default supertypes are not visible when qualified
-1GDFJK0: IVJIDT:WIN2000 - Using 'synchronized' produces invalid exception table values in class, causes "Illegal exception table range" exception, VAJ 3.5+
-1GGAK6G: ITPJCORE:ALL - Incorrect javadoc comment in JavaElement
-1GF9L3K: ITPDUI:ALL - Eval - Private array resolution failure
-1GF8KHX: ITPJUI:ALL - Invalid project build path should be warning, not error
-1GF7JIH: ITPJCORE:ALL - Exception when removing network drive
-1GEYBL9: ITPJUI:WINNT - Adding source folders on CP is very confusing
-1GEJAOT: ITPJUI:WINNT - JRE Source attachment set to path to does not exist
-1GEHZNB: ITPJUI:WINNT - smoke 114: formatter inserts extra tab in first line
-1GCZZT4: ITPJCORE:Fault-tolerance - missing constructor invocation could still answer the allocated type
-1GAU96P: ITPJCORE:WINNT - DCR - JM - JavaProject should provide a class path validation method
-1G7A1TL: ITPJCORE:WINNT - DCR - JM - Rules for classpath not specified
-1FVVWZT: ITPJCORE:ALL - JM - IBinaryType should implement getSourceFileName()
-
PRs Fixed in 1.0NL stream (since 0.9)
==================================================================================
1GGCYEU: ITPJCORE:ALL - Using Ant for build skip files
-1GH3218: ITPJUI:WIN - mnuemonic problems
+1GH3218: ITPJUI:WIN - mnemonic problems
1GGLLUG: ITPJCORE:WINNT - @deprecated does not work if it is followed by a TAB
1GG8T8H: ITPJCORE:ALL - JCK1.3a - dasg04203 - definitely assigned value before the third operand of the conditional operator ? :
1GG8T56: ITPJCORE:ALL - JCK1.3a - dasg04103 - definitely assigned value before the second operand of the conditional operator ? :
@@ -70,128 +29,4 @@ PRs Fixed in 1.0NL stream (since 0.9)
1GF9Y01: ITPCORE:WIN2000 - NPE when deleting everything in a java file and saving it.
1G2F1DT: ITPJCORE:WINNT - Error messages non NLS for JavaModelStatu
1GGCQZ3: ITPJCORE:ALL - NL problems in xml fil
-1GFIRSN: ITPJCORE:WINNT - Classpath - Should allow nesting in binary output when no source folder in on CP
-
-
-PRs Closed in this Release
-==================================================================================
-1GGRCGZ: ITPJUI:WIN2000 - Can't rename/copy/move/delete default package
-1GDRXHP: ITPDUI:WINNT - NPE inspecting local var
-1G7RAO5: ITPJCORE:ALL - Java Model Core Tests: JavaProjectTests>>testProjectClose() has been removed
-1GF7PZW: ITPJCORE:WINNT - Evaluation - Walkback reporting error on local variable type
-1GGLNOQ: ITPJCORE:WINNT - @deprecated does not work if it is followed by a TAB - use a space instead.
-1G295FE: ITPJCORE:ALL - Improve package fragment root management for java project
-1GFQ3FD: ITPJUI:WINNT - Non java resources do not show up under default package, but do under other packages
-1GFBJS9: ITPJUI:ALL - Unbound variable path task not removed
-1GF2LA7: ITPJCORE:WINNT - Adding classpath variable triggers many builds?
-1GEAHG1: ITPJCORE:WIN2000 - Positions of type and method declarations
-1GD57YY: ITPJCORE:WINNT - Unhandled exception in standalone compiler
-1GBPLAP: ITPJUI:WINNT - create class/package not allowed with umlaut
-1G82CEX: ITPJCORE:Adding evaluation support in debugger
-1G4GELA: ITPJCORE:WINNT - NPE: after restarting a crashed workbench
-1G3FV4S: ITPJCORE:WIN - DOMException when renaming constructor
-1G0K0OI: ITPCORE:ALL - Too many ICompilationUnits
-1FRTN67: ITPJCORE:ALL - JM - CodeAssist/TypeHierarchy optimization
-1FJOQSH: LFCOM:WINNT - usage of strictfp modifier
-1FFYDGD: LFCOM:ALL - Weird behavior on incorrect source
-1ETNYD2: IVJIDT:AIX - Format code with "Experminent with Code"
-1ETAM38: IVJIDT:AIX - Code Formatter does not put CR after comment end
-1GE906O: ITPJCORE:ALL - Having trouble getting projects to build properly - project properties noting getting set correctly
-1GE6V5W: ITPJCORE:WINNT - Problems saving workspace
-1GDXCY7: ITPJCORE:WIN2000 - Adding a project to build path doesn't trigger build in dependents
-1GAM4RI: ITPJCORE:WINNT - Errors did not go away after adding jars to buildpath
-1GAJBOB: ITPJUI:WINNT - Code Assist continues after entering blank
-1G4CLZM: ITPJUI:WINNT - 'Import Selection' - Set not found
-1G47HWU: ITPJUI:WINNT - Method Stub Generation: Error on methods throwing Exceptions
-1G3H21Z: ITPJCORE:ALL - Package fragment reorganization problems
-1FWCDYN: ITPJUI:WINNT - resources prematurely made local
-1FWAPGJ: ITPJCORE:ALL - Synchronization is confusing with Java builder
-1FW8MAI: ITPCORE:WIN2000 - Compiler does not recompile all the classes
-1FW6JQG: ITPUI:WINNT - Joining a team may have incorrect classpath
-1GEAX3R: ITPJCORE:WIN2000 - bad error message for ambiguous references
-1GDJ1QU: ITPJCORE:WINNT - NPE building project
-1GD0MLS: ITPJCORE:ALL - Stack traces in log of unknown origin
-1G0UYOQ: ITPJCORE:ALL - Different text range definitions
-1GFJ764: ITPJCORE:ALL - Inconpatible conditional operand types
-1GFBFV7: ITPJCORE:WINNT - Resource copy - should not copy nested internal JARs
-1GF9OW7: ITPJCORE:ALL - Build silently fails for reappearing deleted classes
-1GEOY41: ITPJCORE:WINNT - DeltaProcessor - createElements seems bogus
-1GENY3I: ITPJUI:WINNT - Rename Refactoring introduced compile errors
-1GEJC08: ITPJCORE:WIN2000 - Assertion failed in builder
-1GEI1SS: ITPJCORE:ALL - .java file outside of the classpath should be a compilation unit
-1GE6PGY: ITPJUI:ALL - Wrong class everywhere
-1GE2UUN: ITPDUI:IndexOutOfBounds during eval?
-1GE25VE: ITPJUI:WIN2000 - Cannot search on text selection
-1GDXD7U: ITPJCORE:WINNT - Search not working for projects
-1GDX5E3: ITPJCORE:WINNT - Assertion failed when rename Java Project
-1GDTT7B: ITPJCORE:WIN2000 - Classpath extension in jar manifest not respected
-1GDMMBJ: ITPDUI:WINNT - Stack trace on inspect
-1GDKLB6: ITPDUI:Linux - Inspect from editor broken in linux
-1GDJ3BJ: ITPJCORE:WINNT - Error while typing in editor
-1GDIUMQ: ITPJCORE:WINNT - Build time anomaly when doing incremental builds
-1GDG971: ITPJCORE:WIN2000 - Classpath changes aren't honored by the builder
-1GDDWFM: ITPJCORE:WINNT - Builder leaving bogus errors after auto-build + hand build
-1GDBL1B: ITPJCORE:WIN2000 - Throwable type hierarchy calculation is slow
-1GD4KY2: ITPJCORE:WINNT - False compile errors not going away when building by hand
-1GCTG65: ITPJUI:WIN2000 - Classpath file is copied to bin
-1GCR9MT: ITPJCORE:WINNT - ClassCastException creating a text file
-1GCP6LR: ITPJUI:WINNT - User must get feedback if .classpath file is manipulated
-1GCNFC2: ITPJCORE:ALL - ArrayIndeOutOfBoundsException in CodeAssist
-1GCN2N4: ITPJUI:WIN2000 - Walkback while organizing imports
-1GCFZPA: ITPJCORE:WINNT - Could SourceRange be public API?
-1GCFNQR: ITPJCORE:WINNT - How should the path in ITypeNameRequestor be used?
-1GCBQ2E: ITPJCORE:WINNT - how to efficiently find methods along 'the ripple'?
-1GBRLSV: ITPJCORE:WIN2000 - Question: how to I find an inner type
-1GBALN1: ITPJUI:Incorrect source for created class
-1GAUUQ9: ITPJCORE:WINNT - JavaBuilder doesn't handle internal exceptions during full build
-1GAP1QC: ITPJCORE:WINNT - JavaProject.configure creates invalid output path
-1GAML2O: ITPJCORE:WINNT - NPE during start-up
-1GALZ9N: ITPJCORE:WINNT - Compiler work being done on empty projects
-1GAJ82M: ITPJUI:WINNT - walkback when delete a jar from a java project
-1GAH7KH: ITPJCORE:WINNT - Reopened projects show the bin folder as a package
-1G86704: ITPJUI:WINNT - Drap'nDrop doesn't give operation progress
-1G840BE: ITPJUI:WINNT - code assist - only some keywords are recognized
-1G82D17: ITPJCORE:WINNT - getJavaModel(IWorkspace) looks like an accessor but it does creation
-1G58H14: ITPJCORE:WIN98 - OutOfMemoryException building a big workbench
-1G4W2XB: ITPJCORE:WIN98 - CodeAssist should not always report an error when no completion was found
-1G4U1CZ: ITPJCORE:WINNT - JavaDCDuplicateInnerClassName test is failing
-1G4ENQI: ITPJUI:WIN - NewInterface wizard adds wrong import for inner types
-1G4CKVG: ITPJCORE:WIN - Can't patch classes in jar
-1G426W6: ITPJCORE:WINNT - VerifyError running jre Eclipse 010 with the IBM 1.3 VM
-1G41GH7: ITPJCORE:WINNT - adding a project invokes a recompile
-1G3T0OO: ITPJCORE:WINNT - Invisible class in all possible super classes
-1G3MKWT: ITPJCORE:WIN - Would like more progress on java reorg operations
-1G3DP5Z: ITPJCORE:WIN - IPackageFragment.delete() doesn't delete resources
-1G31A03: ITPJCORE:WIN98 - Building vs. packaging
-1G2NW6V: ITPJUI:WIN2000 - Open on selection doesn't work for inner classes
-1G14M8E: ITPCOM:WINNT - Wrong completion when package name collides with a class name
-1G03GWJ: ITPJCORE:ALL - TypeHierarchy update tuning
-1FYEH7R: ITPJCORE:WINNT - CoreException running WorkingCopyTests with autobuild on
-1FY94XA: ITPJCORE:WINNT - JM - testWorkingCopyGeneral() tests randomly fail
-1FXOAS3: ITPJCORE:ALL - JDOM - remove deprecated method #findNode
-1FWYKB2: ITPJCORE:WIN98 - Feature: When I open a class file for a member type...
-1FWX73S: ITPJCORE:WINNT - Java Builder error when saving html file
-1FWWU28: ITPJCORE:WIN98 - Cannot access compilation unit - Reason: Java Image Builder
-1FWUZ9J: ITPJCORE:WINNT - Add autobuilding option to test suite
-1FWUXTH: ITPJCORE:WINNT - Java Image Builder error message no help
-1FWT5CP: ITPJCORE:ALL - Disable timestamps assertion failed
-1FWST7K: ITPJCORE:WINNT - SCENARIO B3 - error saving jsp
-1FWNLL4: ITPJCORE:WIN2000 - "Editing" internal jar results in ImageBuilderInternalException
-1FWN24W: ITPSRCEDIT:WIN - Get error message if class not saved - task list out of sync
-1FWHWGK: ITPJCORE:ALL - javadoc - warnings during javadoc generation
-1FW6M3U: ITPJCORE:WIN98 - JDOM cannot reproduce "import java. lang. *;"
-1FVU7O2: ITPJCORE:WINNT - JDOM cannot handle "import java.lang.* "
-1FVRW2A: ITPJCORE:WIN98 - Source text still accessible after manually deleting file
-1FVL59P: ITPJUI:WINNT - double clicking on task does not go to right place in source
-1FVII1P: ITPJCORE:ALL - JDOM - Import names reported by parser do not contain '.*'
-1FUNPVG: ITPJCORE:ALL - JavaDCChangeFromFullyQualifiedToImportTest1 is failing
-1FU4P4U: ITPJCORE:ALL - JM - factory should throw detailed exception if unable to create an element
-1FT78Y7: ITPJCORE:ALL - JM - Reference info is slow
-1FSZXSX: ITPCOM:WINNT - Do we need FieldEndPosition?
-1FRKC3T: ITPJCORE:ALL - JM - Incremental Reconciler
-1FRK6S7: ITPJCORE:ALL - JM - hook for builder to get/put binary types
-1FPCMAN: ITPJCORE:ALL - JM - Validating Save Operation
-1GFBCOU: ITPJCORE:WINNT - CodeCompletion - Code assist fails in a method with an incorrect return type
-1GF1VHY: ITPJCORE:ALL - JM - validateFieldName/PackageName should warn if uppercase
-1GEMNE8: ITPJCORE:WIN2000 - JM - JDT DeltaProcessor is very eager
-1FVXJPZ: ITPJCORE:WIN2000 - minor- review error messages \ No newline at end of file
+1GFIRSN: ITPJCORE:WINNT - Classpath - Should allow nesting in binary output when no source folder in on CP
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index f5b0f04ee6..fe8b2e04c2 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -24,10 +24,7 @@ import org.eclipse.jdt.internal.compiler.impl.*;
* It contains two public APIs used to call CodeAssist on a given source with
* a given environment, assisting position and storage (and possibly options).
*/
-public final class CompletionEngine
- extends Engine
- implements ISearchRequestor, TypeConstants {
- CompletionOptions options;
+public final class CompletionEngine extends Engine implements ISearchRequestor, TypeConstants {
CompletionParser parser;
ISearchableNameEnvironment nameEnvironment;
ICompletionRequestor requestor;
@@ -36,918 +33,773 @@ public final class CompletionEngine
char[] source;
boolean resolvingImports = false;
boolean insideQualifiedReference = false;
- int startPosition, actualCompletionPosition, endPosition;
+ int startPosition, endPosition;
HashtableOfObject knownPkgs = new HashtableOfObject(10);
- /*
- static final char[][] mainDeclarations =
- new char[][] {
- "package".toCharArray(),
- "import".toCharArray(),
- "abstract".toCharArray(),
- "final".toCharArray(),
- "public".toCharArray(),
- "class".toCharArray(),
- "interface".toCharArray()};
-
- static final char[][] modifiers = // may want field, method, type & member type modifiers
- new char[][] {
- "abstract".toCharArray(),
- "final".toCharArray(),
- "native".toCharArray(),
- "public".toCharArray(),
- "protected".toCharArray(),
- "private".toCharArray(),
- "static".toCharArray(),
- "strictfp".toCharArray(),
- "synchronized".toCharArray(),
- "transient".toCharArray(),
- "volatile".toCharArray()};
- */
- static final char[][] baseTypes = new char[][] { "boolean" //$NON-NLS-1$
-
- .toCharArray(), "byte" //$NON-NLS-1$
-
- .toCharArray(), "char" //$NON-NLS-1$
-
- .toCharArray(), "double" //$NON-NLS-1$
-
- .toCharArray(), "float" //$NON-NLS-1$
-
- .toCharArray(), "int" //$NON-NLS-1$
-
- .toCharArray(), "long" //$NON-NLS-1$
-
- .toCharArray(), "short" //$NON-NLS-1$
-
- .toCharArray(), "void" //$NON-NLS-1$
-
- .toCharArray()};
-
- static final char[] classField = "class" //$NON-NLS-1$
- .toCharArray();
- static final char[] lengthField = "length" //$NON-NLS-1$
- .toCharArray();
- static final char[] THIS = "this" //$NON-NLS-1$
- .toCharArray();
- /**
- * The CompletionEngine is responsible for computing source completions.
- *
- * It requires a searchable name environment, which supports some
- * specific search APIs, and a requestor to feed back the results to a UI.
- *
- * @param environment com.ibm.codeassist.java.api.ISearchableNameEnvironment
- * used to resolve type/package references and search for types/packages
- * based on partial names.
- *
- * @param requestor com.ibm.codeassist.java.api.ICompletionRequestor
- * since the engine might produce answers of various forms, the engine
- * is associated with a requestor able to accept all possible completions.
- *
- * @param options com.ibm.compiler.java.api.ConfigurableOptions
- * set of options used to configure the code assist engine.
- */
-
- public CompletionEngine(
- ISearchableNameEnvironment nameEnvironment,
- ICompletionRequestor requestor,
- ConfigurableOption[] settings) {
-
- this.requestor = requestor;
- this.nameEnvironment = nameEnvironment;
-
- options = new CompletionOptions(settings);
- CompilerOptions compilerOptions = new CompilerOptions(settings);
- ProblemReporter problemReporter =
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- compilerOptions,
- new DefaultProblemFactory(Locale.getDefault())) {
- public void record(IProblem problem, CompilationResult unitResult) {
- if (problem.getID() != ProblemIrritants.UnmatchedBracket) {
- unitResult.record(problem);
- CompletionEngine.this.requestor.acceptError(problem);
+/*
+ static final char[][] mainDeclarations =
+ new char[][] {
+ "package".toCharArray(),
+ "import".toCharArray(),
+ "abstract".toCharArray(),
+ "final".toCharArray(),
+ "public".toCharArray(),
+ "class".toCharArray(),
+ "interface".toCharArray()};
+
+ static final char[][] modifiers = // may want field, method, type & member type modifiers
+ new char[][] {
+ "abstract".toCharArray(),
+ "final".toCharArray(),
+ "native".toCharArray(),
+ "public".toCharArray(),
+ "protected".toCharArray(),
+ "private".toCharArray(),
+ "static".toCharArray(),
+ "strictfp".toCharArray(),
+ "synchronized".toCharArray(),
+ "transient".toCharArray(),
+ "volatile".toCharArray()};
+*/
+ static final char[][] baseTypes =
+ new char[][] {
+ "boolean"/*nonNLS*/.toCharArray(),
+ "byte"/*nonNLS*/.toCharArray(),
+ "char"/*nonNLS*/.toCharArray(),
+ "double"/*nonNLS*/.toCharArray(),
+ "float"/*nonNLS*/.toCharArray(),
+ "int"/*nonNLS*/.toCharArray(),
+ "long"/*nonNLS*/.toCharArray(),
+ "short"/*nonNLS*/.toCharArray(),
+ "void"/*nonNLS*/.toCharArray()};
+
+ static final char[] classField = "class"/*nonNLS*/.toCharArray();
+ static final char[] lengthField = "length"/*nonNLS*/.toCharArray();
+/**
+ * The CompletionEngine is responsible for computing source completions.
+ *
+ * It requires a searchable name environment, which supports some
+ * specific search APIs, and a requestor to feed back the results to a UI.
+ *
+ * @param environment com.ibm.codeassist.java.api.ISearchableNameEnvironment
+ * used to resolve type/package references and search for types/packages
+ * based on partial names.
+ *
+ * @param requestor com.ibm.codeassist.java.api.ICompletionRequestor
+ * since the engine might produce answers of various forms, the engine
+ * is associated with a requestor able to accept all possible completions.
+ *
+ * @param options com.ibm.compiler.java.api.ConfigurableOptions
+ * set of options used to configure the code assist engine.
+ */
+
+public CompletionEngine(
+ ISearchableNameEnvironment nameEnvironment, ICompletionRequestor requestor, ConfigurableOption[] settings) {
+
+ this.requestor = requestor;
+ this.nameEnvironment = nameEnvironment;
+
+ CompilerOptions options = new CompilerOptions(settings);
+ ProblemReporter problemReporter =
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory(Locale.getDefault())) {
+ public void record(IProblem problem, CompilationResult unitResult) {
+ if (problem.getID() != ProblemIrritants.UnmatchedBracket) {
+ unitResult.record(problem);
+ CompletionEngine.this.requestor.acceptError(problem);
+ }
}
- }
- };
+ };
- this.parser =
- new CompletionParser(problemReporter, compilerOptions.getAssertMode());
- this.lookupEnvironment =
- new LookupEnvironment(this, compilerOptions, problemReporter, nameEnvironment);
+ this.parser = new CompletionParser(problemReporter);
+ this.lookupEnvironment = new LookupEnvironment(this, options, problemReporter, nameEnvironment);
+}
+/**
+ * One result of the search consists of a new class.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.M".
+ * The default package is represented by an empty array.
+ */
+public void acceptClass(char[] packageName, char[] className, int modifiers) {
+ char[] completionName = CharOperation.concat(packageName, className, '.');
+ if (resolvingImports) {
+ completionName = CharOperation.concat(completionName, new char[] {';'});
+ } else if (!insideQualifiedReference) {
+ if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
+ if (packageName == null || packageName.length == 0)
+ if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ return; // ignore types from the default package from outside it
+ } else {
+ completionName = className;
+ }
}
- /**
- * One result of the search consists of a new class.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.M".
- * The default package is represented by an empty array.
- */
- public void acceptClass(char[] packageName, char[] className, int modifiers) {
- char[] completionName = CharOperation.concat(packageName, className, '.');
- if (resolvingImports) {
- completionName = CharOperation.concat(completionName, new char[] { ';' });
- } else
- if (!insideQualifiedReference) {
- if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
- if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
- return; // ignore types from the default package from outside it
- } else {
- completionName = className;
+
+ requestor.acceptClass(
+ packageName,
+ className,
+ completionName,
+ modifiers,
+ startPosition,
+ endPosition);
+}
+/**
+ * One result of the search consists of a new interface.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.I".
+ * The default package is represented by an empty array.
+ */
+public void acceptInterface(char[] packageName, char[] interfaceName, int modifiers) {
+ char[] completionName = CharOperation.concat(packageName, interfaceName, '.');
+ if (resolvingImports) {
+ completionName = CharOperation.concat(completionName, new char[] {';'});
+ } else if (!insideQualifiedReference) {
+ if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
+ if (packageName == null || packageName.length == 0)
+ if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ return; // ignore types from the default package from outside it
+ } else {
+ completionName = interfaceName;
+ }
+ }
+
+ requestor.acceptInterface(
+ packageName,
+ interfaceName,
+ completionName,
+ modifiers,
+ startPosition,
+ endPosition);
+}
+/**
+ * One result of the search consists of a new package.
+ *
+ * NOTE - All package names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * The default package is represented by an empty array.
+ */
+public void acceptPackage(char[] packageName) {
+ if (this.knownPkgs.containsKey(packageName)) return;
+ this.knownPkgs.put(packageName, this);
+ requestor.acceptPackage(
+ packageName,
+ resolvingImports ? CharOperation.concat(packageName, new char[] {'.', '*', ';'}) : packageName,
+ startPosition,
+ endPosition);
+}
+/**
+ * One result of the search consists of a new type.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.M".
+ * The default package is represented by an empty array.
+ */
+public void acceptType(char[] packageName, char[] typeName) {
+ char[] completionName = CharOperation.concat(packageName, typeName, '.');
+ if (resolvingImports) {
+ completionName = CharOperation.concat(completionName, new char[] {';'});
+ } else if (!insideQualifiedReference) {
+ if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
+ if (packageName == null || packageName.length == 0)
+ if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ return; // ignore types from the default package from outside it
+ } else {
+ completionName = typeName;
+ }
+ }
+
+ requestor.acceptType(
+ packageName,
+ typeName,
+ completionName,
+ startPosition,
+ endPosition);
+}
+private void complete(AstNode astNode, Binding qualifiedBinding, Scope scope) {
+ setSourceRange(astNode.sourceStart, astNode.sourceEnd); // defaults... some nodes will change these
+
+ if (astNode instanceof CompletionOnFieldType) {
+ CompletionOnSingleTypeReference type =
+ (CompletionOnSingleTypeReference) ((CompletionOnFieldType) astNode).type;
+ char[] token = type.token;
+ setSourceRange(type.sourceStart, type.sourceEnd);
+// findKeywords(token, modifiers, scope); // could be the start of a field, method or member type
+ findTypesAndPackages(token, scope);
+ } else if (astNode instanceof CompletionOnSingleNameReference) {
+ char[] token = ((CompletionOnSingleNameReference) astNode).token;
+ findVariablesAndMethods(token, scope);
+ findTypesAndPackages(token, scope); // can be the start of a qualified type name
+ } else if (astNode instanceof CompletionOnSingleTypeReference) {
+ char[] token = ((CompletionOnSingleTypeReference) astNode).token;
+ if (qualifiedBinding == null)
+ findTypesAndPackages(token, scope); // can be the start of a qualified type name
+ else
+ findMemberTypes(token, (ReferenceBinding) qualifiedBinding, scope);
+ } else if (astNode instanceof CompletionOnQualifiedNameReference) {
+ insideQualifiedReference = true;
+ CompletionOnQualifiedNameReference ref = (CompletionOnQualifiedNameReference) astNode;
+ char[] token = ref.completionIdentifier;
+ long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
+ if (qualifiedBinding instanceof VariableBinding) {
+ setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
+ TypeBinding receiverType = ((VariableBinding) qualifiedBinding).type;
+ if (receiverType != null)
+ findFieldsAndMethods(token, receiverType, scope);
+ } else if (qualifiedBinding instanceof ReferenceBinding) {
+ ReferenceBinding receiverType = (ReferenceBinding) qualifiedBinding;
+ setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
+ findMemberTypes(token, receiverType, scope);
+ findClassField(token, (TypeBinding) qualifiedBinding);
+ findFields(token, receiverType, scope, new ObjectVector(), true);
+ findMethods(token, null, receiverType, scope, new ObjectVector(), true, false);
+ } else if (qualifiedBinding instanceof PackageBinding) {
+ setSourceRange(astNode.sourceStart, (int) completionPosition); // replace to the end of the completion identifier
+ findTypesAndSubpackages(token, (PackageBinding) qualifiedBinding);
+ }
+ } else if (astNode instanceof CompletionOnQualifiedTypeReference) {
+ insideQualifiedReference = true;
+ CompletionOnQualifiedTypeReference ref = (CompletionOnQualifiedTypeReference) astNode;
+ char[] token = ref.completionIdentifier;
+ long completionPosition = ref.sourcePositions[ref.tokens.length]; // get the source positions of the completion identifier
+ if (qualifiedBinding instanceof ReferenceBinding) {
+ setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
+ findMemberTypes(token, (ReferenceBinding) qualifiedBinding, scope);
+ } else if (qualifiedBinding instanceof PackageBinding) {
+ setSourceRange(astNode.sourceStart, (int) completionPosition); // replace to the end of the completion identifier
+ findTypesAndSubpackages(token, (PackageBinding) qualifiedBinding);
+ }
+ } else if (astNode instanceof CompletionOnMemberAccess) {
+ CompletionOnMemberAccess access = (CompletionOnMemberAccess) astNode;
+ long completionPosition = access.nameSourcePosition;
+ setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
+ findFieldsAndMethods(access.token, (TypeBinding) qualifiedBinding, scope);
+ } else if (astNode instanceof CompletionOnMessageSend) {
+ CompletionOnMessageSend messageSend = (CompletionOnMessageSend) astNode;
+ TypeBinding[] argTypes = computeTypes(messageSend.arguments, (BlockScope) scope);
+ if (qualifiedBinding == null)
+ findMessageSends(messageSend.selector, argTypes, scope);
+ else
+ findMethods(messageSend.selector, argTypes, (ReferenceBinding) qualifiedBinding, scope, new ObjectVector(), false, true);
+ } else if (astNode instanceof CompletionOnExplicitConstructorCall) {
+ CompletionOnExplicitConstructorCall constructorCall = (CompletionOnExplicitConstructorCall) astNode;
+ TypeBinding[] argTypes = computeTypes(constructorCall.arguments, (BlockScope) scope);
+ findConstructors((ReferenceBinding) qualifiedBinding, argTypes, scope);
+ } else if (astNode instanceof CompletionOnQualifiedAllocationExpression) {
+ CompletionOnQualifiedAllocationExpression allocExpression = (CompletionOnQualifiedAllocationExpression) astNode;
+ TypeBinding[] argTypes = computeTypes(allocExpression.arguments, (BlockScope) scope);
+ findConstructors((ReferenceBinding) qualifiedBinding, argTypes, scope);
+ } else if (astNode instanceof CompletionOnClassLiteralAccess) {
+ char[] token = ((CompletionOnClassLiteralAccess) astNode).completionIdentifier;
+ findClassField(token, (TypeBinding) qualifiedBinding);
+ }
+}
+/**
+ * Ask the engine to compute a completion at the specified position
+ * of the given compilation unit.
+ *
+ * @return void
+ * completion results are answered through a requestor.
+ *
+ * @param unit com.ibm.compiler.java.api.env.ICompilationUnit
+ * the source of the current compilation unit.
+ *
+ * @param completionPosition int
+ * a position in the source where the completion is taking place.
+ * This position is relative to the source provided.
+ */
+public void complete(ICompilationUnit sourceUnit, int completionPosition) {
+ try {
+ int actualCompletionPosition = completionPosition - 1; // for now until we can change the UI.
+ CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
+ CompilationUnitDeclaration parsedUnit = parser.dietParse(sourceUnit, result, actualCompletionPosition);
+
+// boolean completionNodeFound = false;
+ if (parsedUnit != null) {
+ // scan the package & import statements first
+ if (parsedUnit.currentPackage instanceof CompletionOnPackageReference) {
+ findPackages((CompletionOnPackageReference) parsedUnit.currentPackage);
+ return;
+ }
+ ImportReference[] imports = parsedUnit.imports;
+ if (imports != null) {
+ for (int i = 0, length = imports.length; i < length; i++) {
+ ImportReference importReference = imports[i];
+ if (importReference instanceof CompletionOnImportReference) {
+ findImports((CompletionOnImportReference) importReference);
+ return;
+ }
}
}
- requestor.acceptClass(
- packageName,
- className,
- completionName,
- modifiers,
- startPosition,
- endPosition);
- }
- /**
- * One result of the search consists of a new interface.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.I".
- * The default package is represented by an empty array.
- */
- public void acceptInterface(
- char[] packageName,
- char[] interfaceName,
- int modifiers) {
- char[] completionName = CharOperation.concat(packageName, interfaceName, '.');
- if (resolvingImports) {
- completionName = CharOperation.concat(completionName, new char[] { ';' });
- } else
- if (!insideQualifiedReference) {
- if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
- if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
- return; // ignore types from the default package from outside it
- } else {
- completionName = interfaceName;
+ if (parsedUnit.types != null) {
+ try {
+ lookupEnvironment.buildTypeBindings(parsedUnit);
+ if ((unitScope = parsedUnit.scope) != null) {
+ source = sourceUnit.getContents();
+ lookupEnvironment.completeTypeBindings(parsedUnit, true);
+ parsedUnit.scope.faultInTypes();
+ parseMethod(parsedUnit, actualCompletionPosition);
+ parsedUnit.resolve();
+ }
+ } catch (CompletionNodeFound e) {
+// completionNodeFound = true;
+ if (e.astNode != null) // if null then we found a problem in the completion node
+ complete(e.astNode, e.qualifiedBinding, e.scope);
}
}
+ }
- requestor.acceptInterface(
- packageName,
- interfaceName,
- completionName,
- modifiers,
- startPosition,
- endPosition);
+/* Ignore package, import, class & interface keywords for now...
+ if (!completionNodeFound) {
+ if (parsedUnit == null || parsedUnit.types == null) {
+ // this is not good enough... can still be trying to define a second type
+ CompletionScanner scanner = (CompletionScanner) parser.scanner;
+ setSourceRange(scanner.completedIdentifierStart, scanner.completedIdentifierEnd);
+ findKeywords(scanner.completionIdentifier, mainDeclarations, null);
+ }
+ // currently have no way to know if extends/implements are possible keywords
+ }
+*/ } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D
+ } catch (InvalidCursorLocation e) { // may eventually report a usefull error
+ } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
+ } finally {
+ reset();
}
- /**
- * One result of the search consists of a new package.
- *
- * NOTE - All package names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * The default package is represented by an empty array.
- */
- public void acceptPackage(char[] packageName) {
- if (this.knownPkgs.containsKey(packageName))
- return;
- this.knownPkgs.put(packageName, this);
- requestor.acceptPackage(
- packageName,
- resolvingImports
- ? CharOperation.concat(packageName, new char[] { '.', '*', ';' })
- : packageName,
+}
+private TypeBinding[] computeTypes(Expression[] arguments, BlockScope scope) {
+ if (arguments == null) return null;
+
+ int argsLength = arguments.length;
+ TypeBinding[] argTypes = new TypeBinding[argsLength];
+ for (int a = argsLength; --a >= 0;)
+ argTypes[a] = arguments[a].resolveType(scope);
+ return argTypes;
+}
+private void findClassField(char[] token, TypeBinding receiverType) {
+ if (token == null) return;
+
+ if (token.length <= classField.length && CharOperation.prefixEquals(token, classField, false /* ignore case */))
+ requestor.acceptField(
+ NoChar,
+ NoChar,
+ classField,
+ NoChar,
+ NoChar,
+ classField,
+ CompilerModifiers.AccStatic | CompilerModifiers.AccPublic,
startPosition,
endPosition);
+}
+private void findConstructors(ReferenceBinding currentType, TypeBinding[] argTypes, Scope scope) {
+ // No visibility checks can be performed without the scope & invocationSite
+ MethodBinding[] methods = currentType.methods();
+ int minArgLength = argTypes == null ? 0 : argTypes.length;
+ next : for (int f = methods.length; --f >= 0;) {
+ MethodBinding constructor = methods[f];
+ if (constructor.isConstructor()) {
+ TypeBinding[] parameters = constructor.parameters;
+ int paramLength = parameters.length;
+ if (minArgLength > paramLength) continue next;
+ for (int a = minArgLength; --a >= 0;)
+ if (argTypes[a] != null) // can be null if it could not be resolved properly
+ if (!scope.areTypesCompatible(argTypes[a], constructor.parameters[a])) continue next;
+
+ char[][] parameterPackageNames = new char[paramLength][];
+ char[][] parameterTypeNames = new char[paramLength][];
+ for (int i = 0; i < paramLength; i++) {
+ TypeBinding type = parameters[i];
+ parameterPackageNames[i] = type.qualifiedPackageName();
+ parameterTypeNames[i] = type.qualifiedSourceName();
+ }
+ char[] completion = TypeConstants.NoChar; // nothing to insert - do not want to replace the existing selector & arguments
+ if (source == null || source.length <= endPosition || source[endPosition] != ')')
+ completion = new char[] {')'};
+ requestor.acceptMethod(
+ currentType.qualifiedPackageName(),
+ currentType.qualifiedSourceName(),
+ currentType.sourceName(),
+ parameterPackageNames,
+ parameterTypeNames,
+ TypeConstants.NoChar,
+ TypeConstants.NoChar,
+ completion,
+ constructor.modifiers,
+ endPosition,
+ endPosition);
+ }
}
- /**
- * One result of the search consists of a new type.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.M".
- * The default package is represented by an empty array.
- */
- public void acceptType(char[] packageName, char[] typeName) {
- char[] completionName = CharOperation.concat(packageName, typeName, '.');
- if (resolvingImports) {
- completionName = CharOperation.concat(completionName, new char[] { ';' });
- } else
- if (!insideQualifiedReference) {
- if (mustQualifyType(CharOperation.splitOn('.', packageName), completionName)) {
- if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
- return; // ignore types from the default package from outside it
- } else {
- completionName = typeName;
- }
+}
+// Helper method for findFields(char[], ReferenceBinding, Scope, ObjectVector, boolean)
+
+private void findFields(
+ char[] fieldName,
+ FieldBinding[] fields,
+ Scope scope,
+ ObjectVector fieldsFound,
+ boolean onlyStaticFields) {
+
+ // Inherited fields which are hidden by subclasses are filtered out
+ // No visibility checks can be performed without the scope & invocationSite
+
+ int fieldLength = fieldName.length;
+ next : for (int f = fields.length; --f >= 0;) {
+ FieldBinding field = fields[f];
+ if (onlyStaticFields && !field.isStatic()) continue next;
+ if (fieldLength > field.name.length) continue next;
+ if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */)) continue next;
+
+ for (int i = fieldsFound.size; --i >= 0;) {
+ FieldBinding otherField = (FieldBinding) fieldsFound.elementAt(i);
+ if (field == otherField) continue next;
+ if (CharOperation.equals(field.name, otherField.name, true)) {
+ if (field.declaringClass.isSuperclassOf(otherField.declaringClass)) continue next;
+ if (otherField.declaringClass.isInterface())
+ if (field.declaringClass.implementsInterface(otherField.declaringClass, true)) continue next;
}
+ }
- requestor.acceptType(
- packageName,
- typeName,
- completionName,
+ fieldsFound.add(field);
+ requestor.acceptField(
+ field.declaringClass.qualifiedPackageName(),
+ field.declaringClass.qualifiedSourceName(),
+ field.name,
+ field.type.qualifiedPackageName(),
+ field.type.qualifiedSourceName(),
+ field.name, // may include some qualification to resolve ambiguities
+ field.modifiers,
startPosition,
endPosition);
}
- private void complete(AstNode astNode, Binding qualifiedBinding, Scope scope) {
- setSourceRange(astNode.sourceStart, astNode.sourceEnd);
- // defaults... some nodes will change these
- if (astNode instanceof CompletionOnFieldType) {
- CompletionOnSingleTypeReference type =
- (CompletionOnSingleTypeReference) ((CompletionOnFieldType) astNode).type;
- char[] token = type.token;
- setSourceRange(type.sourceStart, type.sourceEnd);
- // findKeywords(token, modifiers, scope); // could be the start of a field, method or member type
- findTypesAndPackages(token, scope);
- } else
- if (astNode instanceof CompletionOnSingleNameReference) {
- char[] token = ((CompletionOnSingleNameReference) astNode).token;
- findVariablesAndMethods(
- token,
- scope,
- (CompletionOnSingleNameReference) astNode,
- scope);
- findTypesAndPackages(token, scope);
- // can be the start of a qualified type name
- } else
- if (astNode instanceof CompletionOnSingleTypeReference) {
- char[] token = ((CompletionOnSingleTypeReference) astNode).token;
- if (qualifiedBinding == null)
- findTypesAndPackages(token, scope);
- // can be the start of a qualified type name
- else
- findMemberTypes(
- token,
- (ReferenceBinding) qualifiedBinding,
- scope,
- scope.enclosingSourceType());
- } else
- if (astNode instanceof CompletionOnQualifiedNameReference) {
- insideQualifiedReference = true;
- CompletionOnQualifiedNameReference ref =
- (CompletionOnQualifiedNameReference) astNode;
- char[] token = ref.completionIdentifier;
- long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
- if (qualifiedBinding instanceof VariableBinding) {
- setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
- TypeBinding receiverType = ((VariableBinding) qualifiedBinding).type;
- if (receiverType != null)
- findFieldsAndMethods(token, receiverType, scope, ref,scope);
- } else
- if (qualifiedBinding instanceof ReferenceBinding) {
- ReferenceBinding receiverType = (ReferenceBinding) qualifiedBinding;
- setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
- findMemberTypes(token, receiverType, scope, scope.enclosingSourceType());
- findClassField(token, (TypeBinding) qualifiedBinding);
- findFields(
- token,
- receiverType,
- scope,
- new ObjectVector(),
- new ObjectVector(),
- true,
- ref,
- scope);
- findMethods(
- token,
- null,
- receiverType,
- scope,
- new ObjectVector(),
- true,
- false,
- ref);
- } else
- if (qualifiedBinding instanceof PackageBinding) {
- setSourceRange(astNode.sourceStart, (int) completionPosition);
- // replace to the end of the completion identifier
- findTypesAndSubpackages(token, (PackageBinding) qualifiedBinding);
- }
- } else
- if (astNode instanceof CompletionOnQualifiedTypeReference) {
- insideQualifiedReference = true;
- CompletionOnQualifiedTypeReference ref =
- (CompletionOnQualifiedTypeReference) astNode;
- char[] token = ref.completionIdentifier;
- long completionPosition = ref.sourcePositions[ref.tokens.length];
- // get the source positions of the completion identifier
- if (qualifiedBinding instanceof ReferenceBinding) {
- setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
- findMemberTypes(
- token,
- (ReferenceBinding) qualifiedBinding,
- scope,
- scope.enclosingSourceType());
- } else
- if (qualifiedBinding instanceof PackageBinding) {
- setSourceRange(astNode.sourceStart, (int) completionPosition);
- // replace to the end of the completion identifier
- findTypesAndSubpackages(token, (PackageBinding) qualifiedBinding);
- }
- } else
- if (astNode instanceof CompletionOnMemberAccess) {
- CompletionOnMemberAccess access = (CompletionOnMemberAccess) astNode;
- long completionPosition = access.nameSourcePosition;
- setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
- findFieldsAndMethods(
- access.token,
- (TypeBinding) qualifiedBinding,
- scope,
- access,
- scope);
- } else
- if (astNode instanceof CompletionOnMessageSend) {
- CompletionOnMessageSend messageSend = (CompletionOnMessageSend) astNode;
- TypeBinding[] argTypes =
- computeTypes(messageSend.arguments, (BlockScope) scope);
- if (qualifiedBinding == null)
- findMessageSends(messageSend.selector, argTypes, scope, messageSend);
- else
- findMethods(
- messageSend.selector,
- argTypes,
- (ReferenceBinding) qualifiedBinding,
- scope,
- new ObjectVector(),
- false,
- true,
- messageSend);
- } else
- if (astNode instanceof CompletionOnExplicitConstructorCall) {
- CompletionOnExplicitConstructorCall constructorCall =
- (CompletionOnExplicitConstructorCall) astNode;
- TypeBinding[] argTypes =
- computeTypes(constructorCall.arguments, (BlockScope) scope);
- findConstructors(
- (ReferenceBinding) qualifiedBinding,
- argTypes,
- scope,
- constructorCall);
- } else
- if (astNode instanceof CompletionOnQualifiedAllocationExpression) {
- CompletionOnQualifiedAllocationExpression allocExpression =
- (CompletionOnQualifiedAllocationExpression) astNode;
- TypeBinding[] argTypes =
- computeTypes(allocExpression.arguments, (BlockScope) scope);
- findConstructors(
- (ReferenceBinding) qualifiedBinding,
- argTypes,
- scope,
- allocExpression);
- } else
- if (astNode instanceof CompletionOnClassLiteralAccess) {
- char[] token = ((CompletionOnClassLiteralAccess) astNode).completionIdentifier;
- findClassField(token, (TypeBinding) qualifiedBinding);
- }
- }
- /**
- * Ask the engine to compute a completion at the specified position
- * of the given compilation unit.
- *
- * @return void
- * completion results are answered through a requestor.
- *
- * @param unit com.ibm.compiler.java.api.env.ICompilationUnit
- * the source of the current compilation unit.
- *
- * @param completionPosition int
- * a position in the source where the completion is taking place.
- * This position is relative to the source provided.
- */
- public void complete(ICompilationUnit sourceUnit, int completionPosition) {
- try {
- actualCompletionPosition = completionPosition - 1;
- // for now until we can change the UI.
- CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
- CompilationUnitDeclaration parsedUnit =
- parser.dietParse(sourceUnit, result, actualCompletionPosition);
-
- // boolean completionNodeFound = false;
- if (parsedUnit != null) {
- // scan the package & import statements first
- if (parsedUnit.currentPackage instanceof CompletionOnPackageReference) {
- findPackages((CompletionOnPackageReference) parsedUnit.currentPackage);
- return;
- }
- ImportReference[] imports = parsedUnit.imports;
- if (imports != null) {
- for (int i = 0, length = imports.length; i < length; i++) {
- ImportReference importReference = imports[i];
- if (importReference instanceof CompletionOnImportReference) {
- findImports((CompletionOnImportReference) importReference);
- return;
- }
- }
- }
+}
+private void findFields(
+ char[] fieldName,
+ ReferenceBinding receiverType,
+ Scope scope,
+ ObjectVector fieldsFound,
+ boolean onlyStaticFields) {
+
+ if (fieldName == null) return;
+
+ ReferenceBinding currentType = receiverType;
+ ReferenceBinding[][] interfacesToVisit = null;
+ int lastPosition = -1;
+ do {
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (interfacesToVisit == null)
+ interfacesToVisit = new ReferenceBinding[5][];
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
+ }
- if (parsedUnit.types != null) {
- try {
- lookupEnvironment.buildTypeBindings(parsedUnit);
- if ((unitScope = parsedUnit.scope) != null) {
- source = sourceUnit.getContents();
- lookupEnvironment.completeTypeBindings(parsedUnit, true);
- parsedUnit.scope.faultInTypes();
- parseMethod(parsedUnit, actualCompletionPosition);
- parsedUnit.resolve();
- }
- } catch (CompletionNodeFound e) {
- // completionNodeFound = true;
- if (e.astNode != null)
- // if null then we found a problem in the completion node
- complete(e.astNode, e.qualifiedBinding, e.scope);
+ findFields(fieldName, currentType.fields(), scope, fieldsFound, onlyStaticFields);
+ currentType = currentType.superclass();
+ } while (currentType != null);
+
+ if (interfacesToVisit != null) {
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding anInterface = interfaces[j];
+ if ((anInterface.tagBits & TagBits.InterfaceVisited) == 0) { // if interface as not already been visited
+ anInterface.tagBits |= TagBits.InterfaceVisited;
+
+ findFields(fieldName, anInterface.fields(), scope, fieldsFound, onlyStaticFields);
+
+ ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
+ }
- /* Ignore package, import, class & interface keywords for now...
- if (!completionNodeFound) {
- if (parsedUnit == null || parsedUnit.types == null) {
- // this is not good enough... can still be trying to define a second type
- CompletionScanner scanner = (CompletionScanner) parser.scanner;
- setSourceRange(scanner.completedIdentifierStart, scanner.completedIdentifierEnd);
- findKeywords(scanner.completionIdentifier, mainDeclarations, null);
- }
- // currently have no way to know if extends/implements are possible keywords
- }
- */
- } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D
- } catch (InvalidCursorLocation e) { // may eventually report a usefull error
- } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
- } finally {
- reset();
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
}
}
- private TypeBinding[] computeTypes(Expression[] arguments, BlockScope scope) {
- if (arguments == null)
- return null;
-
- int argsLength = arguments.length;
- TypeBinding[] argTypes = new TypeBinding[argsLength];
- for (int a = argsLength; --a >= 0;)
- argTypes[a] = arguments[a].resolveType(scope);
- return argTypes;
- }
- private void findClassField(char[] token, TypeBinding receiverType) {
- if (token == null)
- return;
+}
+private void findFieldsAndMethods(char[] token, TypeBinding receiverType, Scope scope) {
+ if (token == null) return;
- if (token.length <= classField.length
- && CharOperation.prefixEquals(token, classField, false /* ignore case */
- ))
+ if (receiverType.isBaseType()) return; // nothing else is possible with base types
+ if (receiverType.isArrayType()) {
+ if (token.length <= lengthField.length && CharOperation.prefixEquals(token, lengthField, false /* ignore case */))
requestor.acceptField(
NoChar,
NoChar,
- classField,
+ lengthField,
NoChar,
NoChar,
- classField,
- CompilerModifiers.AccStatic | CompilerModifiers.AccPublic,
+ lengthField,
+ CompilerModifiers.AccPublic,
startPosition,
endPosition);
+
+ receiverType = scope.getJavaLangObject();
}
- private void findConstructors(
- ReferenceBinding currentType,
- TypeBinding[] argTypes,
- Scope scope,
- InvocationSite invocationSite) {
- // No visibility checks can be performed without the scope & invocationSite
- MethodBinding[] methods = currentType.methods();
- int minArgLength = argTypes == null ? 0 : argTypes.length;
- next : for (int f = methods.length; --f >= 0;) {
- MethodBinding constructor = methods[f];
- if (constructor.isConstructor()) {
- if (options.checkVisibilitySensitive()
- && !constructor.canBeSeenBy(invocationSite, scope))
- continue next;
-
- TypeBinding[] parameters = constructor.parameters;
- int paramLength = parameters.length;
- if (minArgLength > paramLength)
- continue next;
- for (int a = minArgLength; --a >= 0;)
- if (argTypes[a] != null) // can be null if it could not be resolved properly
- if (!scope.areTypesCompatible(argTypes[a], constructor.parameters[a]))
- continue next;
-
- char[][] parameterPackageNames = new char[paramLength][];
- char[][] parameterTypeNames = new char[paramLength][];
- for (int i = 0; i < paramLength; i++) {
- TypeBinding type = parameters[i];
- parameterPackageNames[i] = type.qualifiedPackageName();
- parameterTypeNames[i] = type.qualifiedSourceName();
- }
- char[] completion = TypeConstants.NoChar;
- // nothing to insert - do not want to replace the existing selector & arguments
- if (source == null
- || source.length <= endPosition
- || source[endPosition] != ')')
- completion = new char[] { ')' };
- requestor.acceptMethod(
- currentType.qualifiedPackageName(),
- currentType.qualifiedSourceName(),
- currentType.sourceName(),
- parameterPackageNames,
- parameterTypeNames,
- TypeConstants.NoChar,
- TypeConstants.NoChar,
- completion,
- constructor.modifiers,
- endPosition,
- endPosition);
+
+ findFields(token, (ReferenceBinding) receiverType, scope, new ObjectVector(), false);
+ findMethods(token, null, (ReferenceBinding) receiverType, scope, new ObjectVector(), false, false);
+}
+private void findImports(CompletionOnImportReference importReference) {
+ char[] importName = CharOperation.concatWith(importReference.tokens, '.');
+ if (importName.length == 0) return;
+ resolvingImports = true;
+ setSourceRange(importReference.sourceStart, importReference.declarationSourceEnd); // want to replace the existing .*;
+ nameEnvironment.findPackages(importName, this);
+ nameEnvironment.findTypes(importName, this);
+}
+// what about onDemand types? Ignore them since it does not happen!
+// import p1.p2.A.*;
+private void findKeywords(char[] keyword, char[][] choices, Scope scope) {
+ int length = keyword.length;
+ if (length > 0)
+ for (int i = 0; i < choices.length; i++)
+ if (length <= choices[i].length && CharOperation.prefixEquals(keyword, choices[i], false /* ignore case */))
+ requestor.acceptKeyword(choices[i], startPosition, endPosition);
+}
+// Helper method for findMemberTypes(char[], ReferenceBinding, Scope)
+
+private void findMemberTypes(char[] typeName, ReferenceBinding[] memberTypes, ObjectVector typesFound) {
+
+ // Inherited member types which are hidden by subclasses are filtered out
+ // No visibility checks can be performed without the scope & invocationSite
+
+ int typeLength = typeName.length;
+ next : for (int m = memberTypes.length; --m >= 0;) {
+ ReferenceBinding memberType = memberTypes[m];
+// if (!wantClasses && memberType.isClass()) continue next;
+// if (!wantInterfaces && memberType.isInterface()) continue next;
+ if (typeLength > memberType.sourceName.length) continue next;
+ if (!CharOperation.prefixEquals(typeName, memberType.sourceName, false /* ignore case */)) continue next;
+
+ for (int i = typesFound.size; --i >= 0;) {
+ ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(i);
+ if (memberType == otherType) continue next;
+ if (CharOperation.equals(memberType.sourceName, otherType.sourceName, true)) {
+ if (memberType.enclosingType().isSuperclassOf(otherType.enclosingType())) continue next;
+ if (otherType.enclosingType().isInterface())
+ if (memberType.enclosingType().implementsInterface(otherType.enclosingType(), true)) continue next;
}
}
- }
- // Helper method for findFields(char[], ReferenceBinding, Scope, ObjectVector, boolean)
-
- private void findFields(
- char[] fieldName,
- FieldBinding[] fields,
- Scope scope,
- ObjectVector fieldsFound,
- ObjectVector localsFound,
- boolean onlyStaticFields,
- ReferenceBinding receiverType,
- InvocationSite invocationSite,
- Scope invocationScope) {
-
- // Inherited fields which are hidden by subclasses are filtered out
- // No visibility checks can be performed without the scope & invocationSite
-
- int fieldLength = fieldName.length;
- next : for (int f = fields.length; --f >= 0;) {
- FieldBinding field = fields[f];
- if (onlyStaticFields && !field.isStatic())
- continue next;
- if (fieldLength > field.name.length)
- continue next;
- if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */
- ))
- continue next;
-
- if (options.checkVisibilitySensitive()
- && !field.canBeSeenBy(receiverType, invocationSite, scope))
- continue next;
-
- for (int i = fieldsFound.size; --i >= 0;) {
- FieldBinding otherField = (FieldBinding) fieldsFound.elementAt(i);
- if (field == otherField)
- continue next;
- if (CharOperation.equals(field.name, otherField.name, true)) {
- if (field.declaringClass.isSuperclassOf(otherField.declaringClass))
- continue next;
- if (otherField.declaringClass.isInterface())
- if (field.declaringClass.implementsInterface(otherField.declaringClass, true))
- continue next;
- }
- }
- fieldsFound.add(field);
-
- for (int l = localsFound.size; --l >= 0;) {
- LocalVariableBinding local = (LocalVariableBinding) localsFound.elementAt(l);
- if (CharOperation.equals(field.name, local.name, true)) {
- char[] completion = field.name;
- SourceTypeBinding enclosing = scope.enclosingSourceType();
- if (field.isStatic()) {
- char[] name = enclosing.compoundName[enclosing.compoundName.length-1];
- completion = CharOperation.concat(name ,completion,'.');
- } else {;
- if(enclosing == invocationScope.enclosingSourceType()){
- completion = CharOperation.concat(THIS,completion,'.');
- } else {
- char[] name = enclosing.compoundName[enclosing.compoundName.length-1];
- if(!enclosing.isNestedType()){
- completion = CharOperation.concat(THIS,completion,'.');
- completion = CharOperation.concat(name,completion,'.');
- } else if (!enclosing.isAnonymousType()){
- completion = CharOperation.concat(THIS,completion,'.');
- int index = CharOperation.lastIndexOf('$',name);
- char[] shortName = CharOperation.subarray(name,index+1,name.length);
- completion = CharOperation.concat(shortName,completion,'.');
- }
- }
- }
- requestor
- .acceptField(
- field.declaringClass.qualifiedPackageName(),
- field.declaringClass.qualifiedSourceName(),
- field.name,
- field.type.qualifiedPackageName(),
- field.type.qualifiedSourceName(),
- completion,
- // may include some qualification to resolve ambiguities
- field.modifiers, startPosition, endPosition);
- continue next;
- }
- }
+ typesFound.add(memberType);
+ if (memberType.isClass())
+ requestor.acceptClass(
+ memberType.qualifiedPackageName(),
+ memberType.qualifiedSourceName(),
+ memberType.sourceName(),
+ memberType.modifiers,
+ startPosition,
+ endPosition);
+ else
+ requestor.acceptInterface(
+ memberType.qualifiedPackageName(),
+ memberType.qualifiedSourceName(),
+ memberType.sourceName(),
+ memberType.modifiers,
+ startPosition,
+ endPosition);
+ }
+}
+private void findMemberTypes(char[] typeName, ReferenceBinding currentType, Scope scope) {
+ if (typeName == null) return;
+ if (currentType.superInterfaces() == null) return; // we're trying to find a supertype
+
+ ObjectVector typesFound = new ObjectVector();
+ if (insideQualifiedReference || typeName.length == 0) { // do not search up the hierarchy
+ findMemberTypes(typeName, currentType.memberTypes(), typesFound);
+ return;
+ }
- requestor
- .acceptField(
- field.declaringClass.qualifiedPackageName(),
- field.declaringClass.qualifiedSourceName(),
- field.name,
- field.type.qualifiedPackageName(),
- field.type.qualifiedSourceName(),
- field.name,
- // may include some qualification to resolve ambiguities
- field.modifiers, startPosition, endPosition);
+ ReferenceBinding[][] interfacesToVisit = null;
+ int lastPosition = -1;
+ do {
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (interfacesToVisit == null)
+ interfacesToVisit = new ReferenceBinding[5][];
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
- }
- private void findFields(
- char[] fieldName,
- ReferenceBinding receiverType,
- Scope scope,
- ObjectVector fieldsFound,
- ObjectVector localsFound,
- boolean onlyStaticFields,
- InvocationSite invocationSite,
- Scope invocationScope) {
-
- if (fieldName == null)
- return;
-
- ReferenceBinding currentType = receiverType;
- ReferenceBinding[][] interfacesToVisit = null;
- int lastPosition = -1;
- do {
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (interfacesToVisit == null)
- interfacesToVisit = new ReferenceBinding[5][];
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
- findFields(
- fieldName,
- currentType.fields(),
- scope,
- fieldsFound,
- localsFound,
- onlyStaticFields,
- receiverType,
- invocationSite,
- invocationScope);
- currentType = currentType.superclass();
- } while (currentType != null);
-
- if (interfacesToVisit != null) {
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- ReferenceBinding anInterface = interfaces[j];
- if ((anInterface.tagBits & TagBits.InterfaceVisited) == 0) {
- // if interface as not already been visited
- anInterface.tagBits |= TagBits.InterfaceVisited;
-
- findFields(
- fieldName,
- anInterface.fields(),
- scope,
- fieldsFound,
- localsFound,
- onlyStaticFields,
- receiverType,
- invocationSite,
- invocationScope);
-
- ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+ findMemberTypes(typeName, currentType.memberTypes(), typesFound);
+ currentType = currentType.superclass();
+ } while (currentType != null);
+
+ if (interfacesToVisit != null) {
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding anInterface = interfaces[j];
+ if ((anInterface.tagBits & TagBits.InterfaceVisited) == 0) { // if interface as not already been visited
+ anInterface.tagBits |= TagBits.InterfaceVisited;
+
+ findMemberTypes(typeName, anInterface.memberTypes(), typesFound);
+
+ ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
+ }
- // bit reinitialization
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++)
- interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
- }
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
}
}
- private void findFieldsAndMethods(
- char[] token,
- TypeBinding receiverType,
- Scope scope,
- InvocationSite invocationSite,
- Scope invocationScope) {
- if (token == null)
- return;
-
- if (receiverType.isBaseType())
- return; // nothing else is possible with base types
- if (receiverType.isArrayType()) {
- if (token.length <= lengthField.length
- && CharOperation.prefixEquals(token, lengthField, false /* ignore case */
- ))
- requestor.acceptField(
- NoChar,
- NoChar,
- lengthField,
- NoChar,
- NoChar,
- lengthField,
- CompilerModifiers.AccPublic,
- startPosition,
- endPosition);
-
- receiverType = scope.getJavaLangObject();
+}
+private void findMessageSends(char[] token, TypeBinding[] argTypes, Scope scope) {
+ if (token == null) return;
+
+ boolean staticsOnly = false; // need to know if we're in a static context (or inside a constructor)
+ int tokenLength = token.length;
+ ObjectVector methodsFound = new ObjectVector();
+ done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
+ switch (scope.kind) {
+ case Scope.METHOD_SCOPE :
+ // handle the error case inside an explicit constructor call (see MethodScope>>findField)
+ MethodScope methodScope = (MethodScope) scope;
+ staticsOnly |= methodScope.isStatic | methodScope.isConstructorCall;
+ break;
+ case Scope.CLASS_SCOPE :
+ ClassScope classScope = (ClassScope) scope;
+ SourceTypeBinding enclosingType = classScope.referenceContext.binding;
+ findMethods(token, argTypes, enclosingType, classScope, methodsFound, staticsOnly, true);
+ staticsOnly |= enclosingType.isStatic();
+ break;
+ case Scope.COMPILATION_UNIT_SCOPE :
+ break done;
}
-
- findFields(
- token,
- (ReferenceBinding) receiverType,
- scope,
- new ObjectVector(),
- new ObjectVector(),
- false,
- invocationSite,
- invocationScope);
- findMethods(
- token,
- null,
- (ReferenceBinding) receiverType,
- scope,
- new ObjectVector(),
- false,
- false,
- invocationSite);
- }
- private void findImports(CompletionOnImportReference importReference) {
- char[] importName = CharOperation.concatWith(importReference.tokens, '.');
- if (importName.length == 0)
- return;
- resolvingImports = true;
- setSourceRange(
- importReference.sourceStart,
- importReference.declarationSourceEnd);
- // want to replace the existing .*;
- nameEnvironment.findPackages(importName, this);
- nameEnvironment.findTypes(importName, this);
- }
- // what about onDemand types? Ignore them since it does not happen!
- // import p1.p2.A.*;
- private void findKeywords(char[] keyword, char[][] choices, Scope scope) {
- int length = keyword.length;
- if (length > 0)
- for (int i = 0; i < choices.length; i++)
- if (length <= choices[i].length
- && CharOperation.prefixEquals(keyword, choices[i], false /* ignore case */
- ))
- requestor.acceptKeyword(choices[i], startPosition, endPosition);
+ scope = scope.parent;
}
- // Helper method for findMemberTypes(char[], ReferenceBinding, Scope)
-
- private void findMemberTypes(
- char[] typeName,
- ReferenceBinding[] memberTypes,
- ObjectVector typesFound,
- ReferenceBinding receiverType,
- SourceTypeBinding invocationType) {
-
- // Inherited member types which are hidden by subclasses are filtered out
- // No visibility checks can be performed without the scope & invocationSite
-
- int typeLength = typeName.length;
- next : for (int m = memberTypes.length; --m >= 0;) {
- ReferenceBinding memberType = memberTypes[m];
- // if (!wantClasses && memberType.isClass()) continue next;
- // if (!wantInterfaces && memberType.isInterface()) continue next;
- if (typeLength > memberType.sourceName.length)
- continue next;
- if (!CharOperation.prefixEquals(typeName, memberType.sourceName, false
- /* ignore case */
- ))
- continue next;
-
- if (options.checkVisibilitySensitive()
- && !memberType.canBeSeenBy(receiverType, invocationType))
- continue next;
-
- for (int i = typesFound.size; --i >= 0;) {
- ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(i);
- if (memberType == otherType)
- continue next;
- if (CharOperation.equals(memberType.sourceName, otherType.sourceName, true)) {
- if (memberType.enclosingType().isSuperclassOf(otherType.enclosingType()))
- continue next;
- if (otherType.enclosingType().isInterface())
- if (memberType
- .enclosingType()
- .implementsInterface(otherType.enclosingType(), true))
- continue next;
- }
+}
+// Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean)
+
+private void findMethods(
+ char[] methodName,
+ TypeBinding[] argTypes,
+ MethodBinding[] methods,
+ Scope scope,
+ ObjectVector methodsFound,
+// boolean noVoidReturnType, how do you know?
+ boolean onlyStaticMethods,
+ boolean exactMatch) {
+
+ // Inherited methods which are hidden by subclasses are filtered out
+ // No visibility checks can be performed without the scope & invocationSite
+
+ int methodLength = methodName.length;
+ int minArgLength = argTypes == null ? 0 : argTypes.length;
+ next : for (int f = methods.length; --f >= 0;) {
+ MethodBinding method = methods[f];
+ if (method.isConstructor()) continue next;
+// if (noVoidReturnType && method.returnType == BaseTypes.VoidBinding) continue next;
+ if (onlyStaticMethods && !method.isStatic()) continue next;
+ if (exactMatch) {
+ if (!CharOperation.equals(methodName, method.selector, false /* ignore case */)) continue next;
+ } else {
+ if (methodLength > method.selector.length) continue next;
+ if (!CharOperation.prefixEquals(methodName, method.selector, false /* ignore case */)) continue next;
+ }
+ if (minArgLength > method.parameters.length) continue next;
+ for (int a = minArgLength; --a >= 0;)
+ if (argTypes[a] != null) // can be null if it could not be resolved properly
+ if (!scope.areTypesCompatible(argTypes[a], method.parameters[a])) continue next;
+
+ for (int i = methodsFound.size; --i >= 0;) {
+ MethodBinding otherMethod = (MethodBinding) methodsFound.elementAt(i);
+ if (method == otherMethod) continue next;
+ if (CharOperation.equals(method.selector, otherMethod.selector, true) && method.areParametersEqual(otherMethod)) {
+ if (method.declaringClass.isSuperclassOf(otherMethod.declaringClass)) continue next;
+ if (otherMethod.declaringClass.isInterface())
+ if (method.declaringClass.implementsInterface(otherMethod.declaringClass, true)) continue next;
}
+ }
- typesFound.add(memberType);
- if (memberType.isClass())
- requestor.acceptClass(
- memberType.qualifiedPackageName(),
- memberType.qualifiedSourceName(),
- memberType.sourceName(),
- memberType.modifiers,
- startPosition,
- endPosition);
+ methodsFound.add(method);
+ int length = method.parameters.length;
+ char[][] parameterPackageNames = new char[length][];
+ char[][] parameterTypeNames = new char[length][];
+ for (int i = 0; i < length; i++) {
+ TypeBinding type = method.parameters[i];
+ parameterPackageNames[i] = type.qualifiedPackageName();
+ parameterTypeNames[i] = type.qualifiedSourceName();
+ }
+ char[] completion = TypeConstants.NoChar; // nothing to insert - do not want to replace the existing selector & arguments
+ if (!exactMatch) {
+ if (source != null && source.length > endPosition && source[endPosition] == '(')
+ completion = method.selector;
else
- requestor.acceptInterface(
- memberType.qualifiedPackageName(),
- memberType.qualifiedSourceName(),
- memberType.sourceName(),
- memberType.modifiers,
- startPosition,
- endPosition);
+ completion = CharOperation.concat(method.selector, new char[] {'(', ')'});
}
+ requestor.acceptMethod(
+ method.declaringClass.qualifiedPackageName(),
+ method.declaringClass.qualifiedSourceName(),
+ method.selector,
+ parameterPackageNames,
+ parameterTypeNames,
+ method.returnType.qualifiedPackageName(),
+ method.returnType.qualifiedSourceName(),
+ completion,
+ method.modifiers,
+ startPosition,
+ endPosition);
}
- private void findMemberTypes(
- char[] typeName,
- ReferenceBinding receiverType,
- Scope scope,
- SourceTypeBinding typeInvocation) {
-
- ReferenceBinding currentType = receiverType;
- if (typeName == null)
- return;
- if (currentType.superInterfaces() == null)
- return; // we're trying to find a supertype
-
- ObjectVector typesFound = new ObjectVector();
- if (insideQualifiedReference
- || typeName.length == 0) { // do not search up the hierarchy
- findMemberTypes(
- typeName,
- currentType.memberTypes(),
- typesFound,
- receiverType,
- typeInvocation);
- return;
- }
+}
+private void findMethods(
+ char[] selector,
+ TypeBinding[] argTypes,
+ ReferenceBinding receiverType,
+ Scope scope,
+ ObjectVector methodsFound,
+ boolean onlyStaticMethods,
+ boolean exactMatch) {
- ReferenceBinding[][] interfacesToVisit = null;
- int lastPosition = -1;
- do {
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (interfacesToVisit == null)
- interfacesToVisit = new ReferenceBinding[5][];
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+ if (selector == null) return;
- findMemberTypes(
- typeName,
- currentType.memberTypes(),
- typesFound,
- receiverType,
- typeInvocation);
- currentType = currentType.superclass();
- } while (currentType != null);
+ ReferenceBinding currentType = receiverType;
+ if (currentType.isInterface()) {
+ findMethods(selector, argTypes, currentType.methods(), scope, methodsFound, onlyStaticMethods, exactMatch);
- if (interfacesToVisit != null) {
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
+ int lastPosition = 0;
+ interfacesToVisit[lastPosition] = itsInterfaces;
+
for (int i = 0; i <= lastPosition; i++) {
ReferenceBinding[] interfaces = interfacesToVisit[i];
for (int j = 0, length = interfaces.length; j < length; j++) {
- ReferenceBinding anInterface = interfaces[j];
- if ((anInterface.tagBits & TagBits.InterfaceVisited) == 0) {
- // if interface as not already been visited
- anInterface.tagBits |= TagBits.InterfaceVisited;
-
- findMemberTypes(
- typeName,
- anInterface.memberTypes(),
- typesFound,
- receiverType,
- typeInvocation);
-
- ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ currentType = interfaces[j];
+ if ((currentType.tagBits & TagBits.InterfaceVisited) == 0) { // if interface as not already been visited
+ currentType.tagBits |= TagBits.InterfaceVisited;
+
+ findMethods(selector, argTypes, currentType.methods(), scope, methodsFound, onlyStaticMethods, exactMatch);
+
+ itsInterfaces = currentType.superInterfaces();
if (itsInterfaces != NoSuperInterfaces) {
if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
interfacesToVisit[lastPosition] = itsInterfaces;
}
}
@@ -961,499 +813,191 @@ public final class CompletionEngine
interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
}
}
+ currentType = scope.getJavaLangObject();
}
- private void findMessageSends(
- char[] token,
- TypeBinding[] argTypes,
- Scope scope,
- InvocationSite invocationSite) {
- if (token == null)
- return;
-
- boolean staticsOnly = false;
- // need to know if we're in a static context (or inside a constructor)
- int tokenLength = token.length;
- ObjectVector methodsFound = new ObjectVector();
- done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (scope.kind) {
- case Scope.METHOD_SCOPE :
- // handle the error case inside an explicit constructor call (see MethodScope>>findField)
- MethodScope methodScope = (MethodScope) scope;
- staticsOnly |= methodScope.isStatic | methodScope.isConstructorCall;
- break;
- case Scope.CLASS_SCOPE :
- ClassScope classScope = (ClassScope) scope;
- SourceTypeBinding enclosingType = classScope.referenceContext.binding;
- findMethods(
- token,
- argTypes,
- enclosingType,
- classScope,
- methodsFound,
- staticsOnly,
- true,
- invocationSite);
- staticsOnly |= enclosingType.isStatic();
- break;
- case Scope.COMPILATION_UNIT_SCOPE :
- break done;
- }
- scope = scope.parent;
- }
- }
- // Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean)
-
- private void findMethods(
- char[] methodName,
- TypeBinding[] argTypes,
- MethodBinding[] methods,
- Scope scope,
- ObjectVector methodsFound,
- // boolean noVoidReturnType, how do you know?
- boolean onlyStaticMethods,
- boolean exactMatch,
- TypeBinding receiverType,
- InvocationSite invocationSite) {
-
- // Inherited methods which are hidden by subclasses are filtered out
- // No visibility checks can be performed without the scope & invocationSite
-
- int methodLength = methodName.length;
- int minArgLength = argTypes == null ? 0 : argTypes.length;
- next : for (int f = methods.length; --f >= 0;) {
- MethodBinding method = methods[f];
- if (method.isConstructor())
- continue next;
- // if (noVoidReturnType && method.returnType == BaseTypes.VoidBinding) continue next;
- if (onlyStaticMethods && !method.isStatic())
- continue next;
-
- if (options.checkVisibilitySensitive()
- && !method.canBeSeenBy(receiverType, invocationSite, scope))
- continue next;
-
- if (exactMatch) {
- if (!CharOperation.equals(methodName, method.selector, false /* ignore case */
- ))
- continue next;
- } else {
- if (methodLength > method.selector.length)
- continue next;
- if (!CharOperation.prefixEquals(methodName, method.selector, false
- /* ignore case */
- ))
- continue next;
- }
- if (minArgLength > method.parameters.length)
- continue next;
- for (int a = minArgLength; --a >= 0;)
- if (argTypes[a] != null) // can be null if it could not be resolved properly
- if (!scope.areTypesCompatible(argTypes[a], method.parameters[a]))
- continue next;
-
- for (int i = methodsFound.size; --i >= 0;) {
- MethodBinding otherMethod = (MethodBinding) methodsFound.elementAt(i);
- if (method == otherMethod)
- continue next;
- if (CharOperation.equals(method.selector, otherMethod.selector, true)
- && method.areParametersEqual(otherMethod)) {
- if (method.declaringClass.isSuperclassOf(otherMethod.declaringClass))
- continue next;
- if (otherMethod.declaringClass.isInterface())
- if (method
- .declaringClass
- .implementsInterface(otherMethod.declaringClass, true))
- continue next;
- }
- }
- methodsFound.add(method);
- int length = method.parameters.length;
- char[][] parameterPackageNames = new char[length][];
- char[][] parameterTypeNames = new char[length][];
- for (int i = 0; i < length; i++) {
- TypeBinding type = method.parameters[i];
- parameterPackageNames[i] = type.qualifiedPackageName();
- parameterTypeNames[i] = type.qualifiedSourceName();
- }
- char[] completion = TypeConstants.NoChar;
- // nothing to insert - do not want to replace the existing selector & arguments
- if (!exactMatch) {
- if (source != null
- && source.length > endPosition
- && source[endPosition] == '(')
- completion = method.selector;
- else
- completion = CharOperation.concat(method.selector, new char[] { '(', ')' });
- }
- requestor.acceptMethod(
- method.declaringClass.qualifiedPackageName(),
- method.declaringClass.qualifiedSourceName(),
- method.selector,
- parameterPackageNames,
- parameterTypeNames,
- method.returnType.qualifiedPackageName(),
- method.returnType.qualifiedSourceName(),
- completion,
- method.modifiers,
- startPosition,
- endPosition);
- }
+ while (currentType != null) {
+ findMethods(selector, argTypes, currentType.methods(), scope, methodsFound, onlyStaticMethods, exactMatch);
+ currentType = currentType.superclass();
}
- private void findMethods(
- char[] selector,
- TypeBinding[] argTypes,
- ReferenceBinding receiverType,
- Scope scope,
- ObjectVector methodsFound,
- boolean onlyStaticMethods,
- boolean exactMatch,
- InvocationSite invocationSite) {
-
- if (selector == null)
- return;
-
- ReferenceBinding currentType = receiverType;
- if (currentType.isInterface()) {
- findMethods(
- selector,
- argTypes,
- currentType.methods(),
- scope,
- methodsFound,
- onlyStaticMethods,
- exactMatch,
- receiverType,
- invocationSite);
-
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
- int lastPosition = 0;
- interfacesToVisit[lastPosition] = itsInterfaces;
-
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- currentType = interfaces[j];
- if ((currentType.tagBits & TagBits.InterfaceVisited) == 0) {
- // if interface as not already been visited
- currentType.tagBits |= TagBits.InterfaceVisited;
-
- findMethods(
- selector,
- argTypes,
- currentType.methods(),
- scope,
- methodsFound,
- onlyStaticMethods,
- exactMatch,
- receiverType,
- invocationSite);
-
- itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+}
+private void findNestedTypes(char[] typeName, ReferenceBinding currentType, Scope scope) {
+ if (typeName == null) return;
+
+ int typeLength = typeName.length;
+ while (scope != null) { // done when a COMPILATION_UNIT_SCOPE is found
+ switch (scope.kind) {
+ case Scope.METHOD_SCOPE :
+ case Scope.BLOCK_SCOPE :
+ BlockScope blockScope = (BlockScope) scope;
+ next : for (int i = 0, length = blockScope.scopeIndex; i < length; i++) {
+ if (blockScope.subscopes[i] instanceof ClassScope) {
+ SourceTypeBinding localType = ((ClassScope) blockScope.subscopes[i]).referenceContext.binding;
+ if (!localType.isAnonymousType()) {
+ if (typeLength > localType.sourceName.length) continue next;
+ if (!CharOperation.prefixEquals(typeName, localType.sourceName, false /* ignore case */)) continue next;
+
+ requestor.acceptClass(
+ localType.qualifiedPackageName(),
+ localType.sourceName,
+ localType.sourceName,
+ localType.modifiers,
+ startPosition,
+ endPosition);
}
}
}
-
- // bit reinitialization
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++)
- interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
- }
- }
- currentType = scope.getJavaLangObject();
- }
-
- while (currentType != null) {
- findMethods(
- selector,
- argTypes,
- currentType.methods(),
- scope,
- methodsFound,
- onlyStaticMethods,
- exactMatch,
- receiverType,
- invocationSite);
- currentType = currentType.superclass();
+ break;
+ case Scope.CLASS_SCOPE :
+ findMemberTypes(typeName, scope.enclosingSourceType(), scope);
+ if (typeLength == 0) return; // do not search outside the class scope if no prefix was provided
+ break;
+ case Scope.COMPILATION_UNIT_SCOPE :
+ return;
}
+ scope = scope.parent;
}
- private void findNestedTypes(
- char[] typeName,
- SourceTypeBinding currentType,
- Scope scope) {
- if (typeName == null)
- return;
-
- int typeLength = typeName.length;
- while (scope != null) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (scope.kind) {
- case Scope.METHOD_SCOPE :
- case Scope.BLOCK_SCOPE :
- BlockScope blockScope = (BlockScope) scope;
- next : for (int i = 0, length = blockScope.scopeIndex; i < length; i++) {
- if (blockScope.subscopes[i] instanceof ClassScope) {
- SourceTypeBinding localType =
- ((ClassScope) blockScope.subscopes[i]).referenceContext.binding;
- if (!localType.isAnonymousType()) {
- if (typeLength > localType.sourceName.length)
- continue next;
- if (!CharOperation.prefixEquals(typeName, localType.sourceName, false
- /* ignore case */
- ))
- continue next;
-
- requestor.acceptClass(
- localType.qualifiedPackageName(),
- localType.sourceName,
- localType.sourceName,
- localType.modifiers,
- startPosition,
- endPosition);
- }
- }
- }
- break;
- case Scope.CLASS_SCOPE :
- findMemberTypes(typeName, scope.enclosingSourceType(), scope, currentType);
- if (typeLength == 0)
- return; // do not search outside the class scope if no prefix was provided
- break;
- case Scope.COMPILATION_UNIT_SCOPE :
- return;
- }
- scope = scope.parent;
+}
+private void findPackages(CompletionOnPackageReference packageStatement) {
+ char[] packageName = CharOperation.concatWith(packageStatement.tokens, '.');
+ if (packageName.length == 0) return;
+
+ setSourceRange(packageStatement.sourceStart, packageStatement.sourceEnd);
+ nameEnvironment.findPackages(CharOperation.toLowerCase(packageName), this);
+}
+private void findTypesAndPackages(char[] token, Scope scope) {
+ if (token == null) return;
+
+ if (scope.enclosingSourceType() != null)
+ findNestedTypes(token, scope.enclosingSourceType(), scope);
+
+ if (unitScope != null) {
+ int typeLength = token.length;
+ SourceTypeBinding[] types = unitScope.topLevelTypes;
+ for (int i = 0, length = types.length; i < length; i++) {
+ SourceTypeBinding sourceType = types[i];
+ if (typeLength > sourceType.sourceName.length) continue;
+ if (!CharOperation.prefixEquals(token, sourceType.sourceName, false /* ignore case */)) continue;
+
+ requestor.acceptType(
+ sourceType.qualifiedPackageName(),
+ sourceType.sourceName(),
+ sourceType.sourceName(),
+ startPosition,
+ endPosition);
}
}
- private void findPackages(CompletionOnPackageReference packageStatement) {
- char[] packageName = CharOperation.concatWith(packageStatement.tokens, '.');
- if (packageName.length == 0)
- return;
- setSourceRange(packageStatement.sourceStart, packageStatement.sourceEnd);
- nameEnvironment.findPackages(CharOperation.toLowerCase(packageName), this);
+ if (token.length == 0) return;
+ findKeywords(token, baseTypes, scope);
+ nameEnvironment.findTypes(token, this);
+ nameEnvironment.findPackages(token, this);
+}
+private void findTypesAndSubpackages(char[] token, PackageBinding packageBinding) {
+ char[] qualifiedName = CharOperation.concatWith(packageBinding.compoundName, token, '.');
+ if (token == null || token.length == 0) {
+ int length = qualifiedName.length;
+ System.arraycopy(qualifiedName, 0, qualifiedName = new char[length + 1], 0, length);
+ qualifiedName[length] = '.';
}
- private void findTypesAndPackages(char[] token, Scope scope) {
- if (token == null)
- return;
-
- if (scope.enclosingSourceType() != null)
- findNestedTypes(token, scope.enclosingSourceType(), scope);
-
- if (unitScope != null) {
- int typeLength = token.length;
- SourceTypeBinding[] types = unitScope.topLevelTypes;
- for (int i = 0, length = types.length; i < length; i++) {
- SourceTypeBinding sourceType = types[i];
- if (typeLength > sourceType.sourceName.length)
- continue;
- if (!CharOperation.prefixEquals(token, sourceType.sourceName, false
- /* ignore case */
- ))
- continue;
-
- requestor.acceptType(
- sourceType.qualifiedPackageName(),
- sourceType.sourceName(),
- sourceType.sourceName(),
- startPosition,
- endPosition);
- }
- }
-
- if (token.length == 0)
- return;
- findKeywords(token, baseTypes, scope);
- nameEnvironment.findTypes(token, this);
- nameEnvironment.findPackages(token, this);
- }
- private void findTypesAndSubpackages(
- char[] token,
- PackageBinding packageBinding) {
- char[] qualifiedName =
- CharOperation.concatWith(packageBinding.compoundName, token, '.');
- if (token == null || token.length == 0) {
- int length = qualifiedName.length;
- System.arraycopy(
- qualifiedName,
- 0,
- qualifiedName = new char[length + 1],
- 0,
- length);
- qualifiedName[length] = '.';
- }
- nameEnvironment.findTypes(qualifiedName, this);
- nameEnvironment.findPackages(qualifiedName, this);
- }
- private void findVariablesAndMethods(
- char[] token,
- Scope scope,
- InvocationSite invocationSite,
- Scope invocationScope) {
- if (token == null)
- return;
-
- // Should local variables hide fields from the receiver type or any of its enclosing types?
- // we know its an implicit field/method access... see BlockScope getBinding/getImplicitMethod
-
- boolean staticsOnly = false;
- // need to know if we're in a static context (or inside a constructor)
- int lastPosition = -1;
- int tokenLength = token.length;
-
- ObjectVector localsFound = new ObjectVector();
- ObjectVector fieldsFound = new ObjectVector();
- ObjectVector methodsFound = new ObjectVector();
-
- Scope currentScope = scope;
- done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (currentScope.kind) {
- case Scope.METHOD_SCOPE :
- // handle the error case inside an explicit constructor call (see MethodScope>>findField)
- MethodScope methodScope = (MethodScope) currentScope;
- staticsOnly |= methodScope.isStatic | methodScope.isConstructorCall;
- case Scope.BLOCK_SCOPE :
- BlockScope blockScope = (BlockScope) currentScope;
- next : for (int i = 0, length = blockScope.locals.length; i < length; i++) {
- LocalVariableBinding local = blockScope.locals[i];
- if (local == null)
- break next;
- if (tokenLength > local.name.length)
- continue next;
- if (!CharOperation.prefixEquals(token, local.name, false /* ignore case */
- ))
- continue next;
- if (local.isSecret())
- continue next;
-
- for (int f = 0; f < localsFound.size; f++) {
- LocalVariableBinding otherLocal =
- (LocalVariableBinding) localsFound.elementAt(f);
- if (CharOperation.equals(otherLocal.name, local.name, false /* ignore case */
- ))
- continue next;
+ nameEnvironment.findTypes(qualifiedName, this);
+ nameEnvironment.findPackages(qualifiedName, this);
+}
+private void findVariablesAndMethods(char[] token, Scope scope) {
+ if (token == null) return;
+
+ // Should local variables hide fields from the receiver type or any of its enclosing types?
+ // we know its an implicit field/method access... see BlockScope getBinding/getImplicitMethod
+
+ boolean staticsOnly = false; // need to know if we're in a static context (or inside a constructor)
+ char[][] found = null;
+ int lastPosition = -1;
+ int tokenLength = token.length;
+ ObjectVector fieldsFound = new ObjectVector();
+ ObjectVector methodsFound = new ObjectVector();
+ done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
+ switch (scope.kind) {
+ case Scope.METHOD_SCOPE :
+ // handle the error case inside an explicit constructor call (see MethodScope>>findField)
+ MethodScope methodScope = (MethodScope) scope;
+ staticsOnly |= methodScope.isStatic | methodScope.isConstructorCall;
+ case Scope.BLOCK_SCOPE :
+ BlockScope blockScope = (BlockScope) scope;
+ next : for (int i = 0, length = blockScope.locals.length; i < length; i++) {
+ LocalVariableBinding local = blockScope.locals[i];
+ if (local == null) break next;
+ if (tokenLength > local.name.length) continue next;
+ if (!CharOperation.prefixEquals(token, local.name, false /* ignore case */)) continue next;
+ if (local.isSecret()) continue next;
+
+ if (found == null) {
+ found = new char[5][];
+ } else {
+ for (int f = 0; f < found.length; f++) {
+ char[] name = found[f];
+ if (name == null) break;
+ if (CharOperation.equals(name, local.name, false /* ignore case */)) continue next;
}
- localsFound.add(local);
-
- requestor.acceptLocalVariable(
- local.name,
- NoChar,
- local.type == null
- ? local.declaration.type.toString().toCharArray()
- : local.type.qualifiedSourceName(),
- local.modifiers,
- startPosition,
- endPosition);
}
- break;
- case Scope.COMPILATION_UNIT_SCOPE :
+ if (++lastPosition == found.length)
+ System.arraycopy(found, 0, found = new char[lastPosition * 2][], 0, lastPosition);
+ found[lastPosition] = local.name;
+
+ requestor.acceptLocalVariable(
+ local.name,
+ NoChar,
+ local.type == null ? local.declaration.type.toString().toCharArray() : local.type.qualifiedSourceName(),
+ local.modifiers,
+ startPosition,
+ endPosition);
+ }
+ break;
+ case Scope.CLASS_SCOPE :
+ ClassScope classScope = (ClassScope) scope;
+ SourceTypeBinding enclosingType = classScope.referenceContext.binding;
+/* if (tokenLength == 0) { // only search inside the type itself if no prefix was provided
+ findFields(token, enclosingType.fields(), classScope, fieldsFound, staticsOnly);
+ findMethods(token, enclosingType.methods(), classScope, methodsFound, staticsOnly, false);
break done;
- }
- currentScope = currentScope.parent;
- }
-
- currentScope = scope;
- done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (currentScope.kind) {
- case Scope.CLASS_SCOPE :
- ClassScope classScope = (ClassScope) currentScope;
- SourceTypeBinding enclosingType = classScope.referenceContext.binding;
- /* if (tokenLength == 0) { // only search inside the type itself if no prefix was provided
- findFields(token, enclosingType.fields(), classScope, fieldsFound, staticsOnly);
- findMethods(token, enclosingType.methods(), classScope, methodsFound, staticsOnly, false);
- break done;
- } else { */
- findFields(
- token,
- enclosingType,
- classScope,
- fieldsFound,
- localsFound,
- staticsOnly,
- invocationSite,
- invocationScope);
- findMethods(
- token,
- null,
- enclosingType,
- classScope,
- methodsFound,
- staticsOnly,
- false,
- invocationSite);
+ } else { */
+ findFields(token, enclosingType, classScope, fieldsFound, staticsOnly);
+ findMethods(token, null, enclosingType, classScope, methodsFound, staticsOnly, false);
staticsOnly |= enclosingType.isStatic();
- // }
- break;
- case Scope.COMPILATION_UNIT_SCOPE :
- break done;
- }
- currentScope = currentScope.parent;
+// }
+ break;
+ case Scope.COMPILATION_UNIT_SCOPE :
+ break done;
}
+ scope = scope.parent;
}
- public AssistParser getParser() {
- return parser;
- }
- private boolean mustQualifyType(
- char[][] packageName,
- char[] readableTypeName) {
- // If there are no types defined into the current CU yet.
- if (unitScope == null)
- return true;
- if (CharOperation.equals(unitScope.fPackage.compoundName, packageName))
- return false;
-
- ImportBinding[] imports = unitScope.imports;
- for (int i = 0, length = imports.length; i < length; i++) {
- if (imports[i].onDemand) {
- if (CharOperation.equals(imports[i].compoundName, packageName))
- return false; // how do you match p1.p2.A.* ?
- } else
- if (CharOperation.equals(imports[i].readableName(), readableTypeName)) {
- return false;
- }
- }
+}
+public AssistParser getParser(){
+ return parser;
+}
+private boolean mustQualifyType(char[][] packageName, char[] readableTypeName) {
+ // If there are no types defined into the current CU yet.
+ if (unitScope == null)
return true;
- }
- protected void reset() {
- super.reset();
- this.knownPkgs = new HashtableOfObject(10);
- }
- private void setSourceRange(int start, int end) {
- this.startPosition = start;
- if (options.checkEntireWordReplacement()) {
- this.endPosition = end + 1; // Add 1 for now
- } else {
- this.endPosition = actualCompletionPosition + 1;
- }
- }
-
- /**
- * Returns all the options of the Completion Engine to be shown by the UI
- *
- * @param locale java.util.Locale
- * @return com.ibm.compiler.java.ConfigurableOption[]
- */
- public static ConfigurableOption[] getDefaultOptions(Locale locale) {
- String[] ids =
- ConfigurableOption.getIDs(CompletionEngine.class.getName(), locale);
-
- ConfigurableOption[] result = new ConfigurableOption[ids.length];
- for (int i = 0; i < ids.length; i++) {
- result[i] = new ConfigurableOption(ids[i], locale);
+ if (CharOperation.equals(unitScope.fPackage.compoundName, packageName))
+ return false;
+
+ ImportBinding[] imports = unitScope.imports;
+ for (int i = 0, length = imports.length; i < length; i++) {
+ if (imports[i].onDemand) {
+ if (CharOperation.equals(imports[i].compoundName, packageName))
+ return false; // how do you match p1.p2.A.* ?
+ } else if (CharOperation.equals(imports[i].readableName(), readableTypeName)) {
+ return false;
}
-
- return result;
}
-} \ No newline at end of file
+ return true;
+}
+protected void reset() {
+ super.reset();
+ this.knownPkgs = new HashtableOfObject(10);
+}
+private void setSourceRange(int start, int end) {
+ this.startPosition = start;
+ this.endPosition = end + 1; // Add 1 for now
+}
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
index 364322ee75..46432c43f6 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
@@ -13,43 +13,39 @@ import org.eclipse.jdt.internal.codeassist.*;
* to the raw name environment results before answering them to the UI.
*/
public interface ISearchRequestor {
-
- /**
- * One result of the search consists of a new class.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.M".
- * The default package is represented by an empty array.
- */
- public void acceptClass(char[] packageName, char[] typeName, int modifiers);
-
- /**
- * One result of the search consists of a new interface.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.I".
- * The default package is represented by an empty array.
- */
- public void acceptInterface(char[] packageName, char[] typeName, int modifiers);
-
- /**
- * One result of the search consists of a new package.
- *
- * NOTE - All package names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * The default package is represented by an empty array.
- */
- public void acceptPackage(char[] packageName);
-
- /**
- * One result of the search consists of a new type.
- *
- * NOTE - All package and type names are presented in their readable form:
- * Package names are in the form "a.b.c".
- * Nested type names are in the qualified form "A.M".
- * The default package is represented by an empty array.
- */
- public void acceptType(char[] packageName, char[] typeName);
-} \ No newline at end of file
+/**
+ * One result of the search consists of a new class.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.M".
+ * The default package is represented by an empty array.
+ */
+public void acceptClass(char[] packageName, char[] typeName, int modifiers);
+/**
+ * One result of the search consists of a new interface.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.I".
+ * The default package is represented by an empty array.
+ */
+public void acceptInterface(char[] packageName, char[] typeName, int modifiers);
+/**
+ * One result of the search consists of a new package.
+ *
+ * NOTE - All package names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * The default package is represented by an empty array.
+ */
+public void acceptPackage(char[] packageName);
+/**
+ * One result of the search consists of a new type.
+ *
+ * NOTE - All package and type names are presented in their readable form:
+ * Package names are in the form "a.b.c".
+ * Nested type names are in the qualified form "A.M".
+ * The default package is represented by an empty array.
+ */
+public void acceptType(char[] packageName, char[] typeName);
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index 15fadba2fb..808c774ef1 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -74,7 +74,7 @@ public SelectionEngine(ISearchableNameEnvironment nameEnvironment, ISelectionReq
}
};
- this.parser = new SelectionParser(problemReporter, options.getAssertMode());
+ this.parser = new SelectionParser(problemReporter);
this.lookupEnvironment = new LookupEnvironment(this, options, problemReporter, nameEnvironment);
}
/**
@@ -366,12 +366,11 @@ public void selectType(ISourceType sourceType, char[] typeName) {
// compute parse tree for this most outer type
CompilationResult result = new CompilationResult(outerType.getFileName(), 1, 1);
CompilationUnitDeclaration parsedUnit =
- SourceTypeConverter.buildCompilationUnit(
- new ISourceType[]{outerType},
+ SourceTypeConverter.buildCompilationUnit(
+ outerType,
false, // don't need field and methods
- true, // by default get member types
this.parser.problemReporter(),
- result);
+ result);
if (parsedUnit != null && parsedUnit.types != null) {
// find the type declaration that corresponds to the original source type
@@ -401,7 +400,7 @@ public void selectType(ISourceType sourceType, char[] typeName) {
selectionIdentifier,
new long[previousIdentifiers.length + 1]);
}
- field.name = "<fakeField>".toCharArray(); //$NON-NLS-1$
+ field.name = "<fakeField>"/*nonNLS*/.toCharArray();
typeDecl.fields = new FieldDeclaration[] {field};
// build bindings
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
index 7421006d64..79e6f0887a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
@@ -41,11 +41,11 @@ public TypeBinding resolveType(BlockScope scope) {
throw new CompletionNodeFound(this, targetType, scope);
}
public String toStringExpression() {
- StringBuffer result = new StringBuffer("<CompleteOnClassLiteralAccess:"); //$NON-NLS-1$
+ StringBuffer result = new StringBuffer("<CompleteOnClassLiteralAccess:"/*nonNLS*/);
result.append(type.toString());
- result.append("."); //$NON-NLS-1$
+ result.append("."/*nonNLS*/);
result.append(completionIdentifier);
- result.append(">"); //$NON-NLS-1$
+ result.append(">"/*nonNLS*/);
return result.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
index fddf441d12..6b14d5a183 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
@@ -36,6 +36,6 @@ public CompletionOnExceptionReference(char[] source, long pos) {
super(source, pos);
}
public String toStringExpression(int tab) {
- return "<CompleteOnException:" + new String(token) + ">"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<CompleteOnException:"/*nonNLS*/ + new String(token) + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
index 47d62d50cb..33a2a6aa88 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
@@ -48,23 +48,23 @@ public void resolve(BlockScope scope) {
}
public String toString(int tab) {
String s = tabString(tab);
- s += "<CompleteOnExplicitConstructorCall:"; //$NON-NLS-1$
+ s += "<CompleteOnExplicitConstructorCall:"/*nonNLS*/;
if (qualification != null)
- s = s + qualification.toStringExpression() + "."; //$NON-NLS-1$
+ s = s + qualification.toStringExpression() + "."/*nonNLS*/;
if (accessMode == This) {
- s = s + "this("; //$NON-NLS-1$
+ s = s + "this("/*nonNLS*/;
} else {
- s = s + "super("; //$NON-NLS-1$
+ s = s + "super("/*nonNLS*/;
}
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
s += arguments[i].toStringExpression();
if (i != arguments.length - 1) {
- s += ", "; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
}
};
}
- s += ")>"; //$NON-NLS-1$
+ s += ")>"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
index d71d7b728f..33a99a1d68 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
@@ -36,14 +36,14 @@ public CompletionOnImportReference(char[][] tokens , long[] positions) {
public String toString(int tab, boolean withOnDemand) {
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer. append("<CompleteOnImport:"); //$NON-NLS-1$
+ buffer. append("<CompleteOnImport:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
index 0d3d0633ba..55098d0456 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
@@ -43,8 +43,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/* slow code */
- return "<CompleteOnMemberAccess:" //$NON-NLS-1$
+ return "<CompleteOnMemberAccess:"/*nonNLS*/
+ super.toStringExpression()
- + ">"; //$NON-NLS-1$
+ + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
index 3c91fd11a8..bb9419e342 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
@@ -45,19 +45,19 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression() {
/*slow code*/
- String s = "<CompleteOnMessageSend:"; //$NON-NLS-1$
+ String s = "<CompleteOnMessageSend:"/*nonNLS*/;
if (receiver != ThisReference.ThisImplicit)
- s = s + receiver.toStringExpression() + "."; //$NON-NLS-1$
- s = s + new String(selector) + "("; //$NON-NLS-1$
+ s = s + receiver.toStringExpression() + "."/*nonNLS*/;
+ s = s + new String(selector) + "("/*nonNLS*/;
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
s += arguments[i].toStringExpression();
if (i != arguments.length - 1) {
- s += ", "; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
}
};
}
- s = s + ")>"; //$NON-NLS-1$
+ s = s + ")>"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
index 7c3af043cc..1f7e313392 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
@@ -34,14 +34,14 @@ public CompletionOnPackageReference(char[][] tokens , long[] positions) {
}
public String toString(int tab, boolean withOnDemand) {
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer. append("<CompleteOnPackage:"); //$NON-NLS-1$
+ buffer. append("<CompleteOnPackage:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
index aba7d73b1c..63b20d5f86 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
@@ -56,8 +56,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(int tab) {
return
((this.enclosingInstance == null) ?
- "<CompleteOnAllocationExpression:" : //$NON-NLS-1$
- "<CompleteOnQualifiedAllocationExpression:") + //$NON-NLS-1$
- super.toStringExpression(tab) + ">"; //$NON-NLS-1$
+ "<CompleteOnAllocationExpression:"/*nonNLS*/ :
+ "<CompleteOnQualifiedAllocationExpression:"/*nonNLS*/) +
+ super.toStringExpression(tab) + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
index e55f05257c..4d02d4529d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
@@ -39,12 +39,12 @@ public CompletionOnQualifiedExceptionReference(char[][] previousIdentifiers, cha
public String toStringExpression(int tab) {
StringBuffer buffer = new StringBuffer();
- buffer. append("<CompleteOnException:"); //$NON-NLS-1$
+ buffer. append("<CompleteOnException:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
- buffer.append(completionIdentifier).append(">"); //$NON-NLS-1$
+ buffer.append(completionIdentifier).append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
index 036d3f3df7..df2ef4691f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
@@ -61,12 +61,12 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression() {
- StringBuffer buffer = new StringBuffer("<CompleteOnName:"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("<CompleteOnName:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
- buffer.append(completionIdentifier).append(">"); //$NON-NLS-1$
+ buffer.append(completionIdentifier).append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
index 65eb427267..d1a29bd56d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
@@ -49,12 +49,12 @@ public TypeBinding getTypeBinding(Scope scope) {
public String toStringExpression(int tab) {
StringBuffer buffer = new StringBuffer();
- buffer.append("<CompleteOnType:"); //$NON-NLS-1$
+ buffer.append("<CompleteOnType:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
- buffer.append(completionIdentifier).append(">"); //$NON-NLS-1$
+ buffer.append(completionIdentifier).append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
index db8f08f099..71cc39432f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
@@ -36,6 +36,6 @@ public TypeBinding resolveType(BlockScope scope) {
throw new CompletionNodeFound(this, scope);
}
public String toStringExpression() {
- return "<CompleteOnName:" + super.toStringExpression() + ">"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<CompleteOnName:"/*nonNLS*/ + super.toStringExpression() + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
index b75bbe54a8..f9c4c6d6ca 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
@@ -42,6 +42,6 @@ public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclo
}
public String toStringExpression(int tab){
- return "<CompleteOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<CompleteOnType:"/*nonNLS*/ + new String(token) + ">"/*nonNLS*/ ;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 5febd1c61c..62a3b91568 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -70,13 +70,8 @@ public class CompletionParser extends AssistParser {
// it is poped when a block is exited
int blockInvocationPtr;
int[] blockInvocationStack = new int[StackIncrement];
-
-/** @deprecated - should use constructor with assertMode */
public CompletionParser(ProblemReporter problemReporter) {
- this(problemReporter, false/*no assertion by default*/);
-}
-public CompletionParser(ProblemReporter problemReporter, boolean assertMode) {
- super(problemReporter, assertMode);
+ super(problemReporter);
}
public char[] assistIdentifier(){
return ((CompletionScanner)scanner).completionIdentifier;
@@ -865,7 +860,7 @@ private void initializeForBlockStatements() {
this.blockInvocationPtr = -1;
}
public void initializeScanner(){
- this.scanner = new CompletionScanner(this.assertMode);
+ this.scanner = new CompletionScanner();
}
/**
* Returns whether we are directly or indirectly inside a field initializer.
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
index cdca93064e..2ac0910b9c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
@@ -29,8 +29,8 @@ public class CompletionScanner extends Scanner {
public int completedIdentifierEnd = -1;
public static final char[] EmptyCompletionIdentifier = {};
-public CompletionScanner(boolean assertMode) {
- super(false, false, false, assertMode);
+public CompletionScanner() {
+ super();
}
/*
* Truncate the current identifier if it is containing the cursor location. Since completion is performed
@@ -646,7 +646,7 @@ public int getNextToken() throws InvalidInputException {
if (atEnd())
return TokenNameEOF;
//the atEnd may not be <currentPosition == source.length> if source is only some part of a real (external) stream
- throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
+ throw new InvalidInputException("Ctrl-Z"/*nonNLS*/);
default :
if (Character.isJavaIdentifierStart(currentCharacter))
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
index adb6de9233..543d318d2c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
@@ -14,10 +14,10 @@ public class InvalidCursorLocation extends RuntimeException {
public String irritant;
/* Possible irritants */
- public static final String NO_COMPLETION_INSIDE_UNICODE = "No Completion Inside Unicode"; //$NON-NLS-1$
- public static final String NO_COMPLETION_INSIDE_COMMENT = "No Completion Inside Comment"; //$NON-NLS-1$
- public static final String NO_COMPLETION_INSIDE_STRING = "No Completion Inside String"; //$NON-NLS-1$
- public static final String NO_COMPLETION_INSIDE_NUMBER = "No Completion Inside Number"; //$NON-NLS-1$
+ public static final String NO_COMPLETION_INSIDE_UNICODE = "No Completion Inside Unicode"/*nonNLS*/;
+ public static final String NO_COMPLETION_INSIDE_COMMENT = "No Completion Inside Comment"/*nonNLS*/;
+ public static final String NO_COMPLETION_INSIDE_STRING = "No Completion Inside String"/*nonNLS*/;
+ public static final String NO_COMPLETION_INSIDE_NUMBER = "No Completion Inside Number"/*nonNLS*/;
public InvalidCursorLocation(String irritant){
this.irritant = irritant;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index 92eca57ff9..1e93c1b211 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
@@ -52,8 +52,8 @@ public abstract class AssistParser extends Parser {
// and it is poped when the type is exited)
protected int inMethodPtr;
protected boolean[] inMethodStack = new boolean[StackIncrement];
-public AssistParser(ProblemReporter problemReporter, boolean assertMode) {
- super(problemReporter, false, assertMode);
+public AssistParser(ProblemReporter problemReporter) {
+ super(problemReporter, false);
}
public abstract char[] assistIdentifier();
public int bodyEnd(AbstractMethodDeclaration method){
@@ -90,8 +90,7 @@ public RecoveredElement buildInitialRecoveryState(){
TypeDeclaration type = (TypeDeclaration) referenceContext;
for (int i = 0; i < type.fields.length; i++){
FieldDeclaration field = type.fields[i];
- if (!field.isField()
- && field.declarationSourceStart <= scanner.initialPosition
+ if (field.declarationSourceStart <= scanner.initialPosition
&& scanner.initialPosition <= field.declarationSourceEnd
&& scanner.eofPosition <= field.declarationSourceEnd+1){
element = new RecoveredInitializer((Initializer) field, null, 1, this);
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/CompletionOptions.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/CompletionOptions.java
deleted file mode 100644
index 46c42cb64d..0000000000
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/CompletionOptions.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.jdt.internal.codeassist.impl;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import org.eclipse.jdt.internal.codeassist.*;
-import org.eclipse.jdt.internal.compiler.ConfigurableOption;
-
-public class CompletionOptions {
- /**
- * Option IDs
- */
- public static final String OPTION_PerformVisibilityCheck = CompletionEngine.class.getName() + ".performVisibilityCheck"; //$NON-NLS-1$
- public static final String OPTION_EntireWordReplacement = CompletionEngine.class.getName() + ".entireWordReplacement"; //$NON-NLS-1$
-
- private boolean visibilitySensitive = true;
- private boolean entireWordReplacement = true;
-
- /**
- * Initializing the completion engine options with default settings
- */
- public CompletionOptions() {
- }
- /**
- * Initializing the completion engine options with external settings
- */
- public CompletionOptions(ConfigurableOption[] settings) {
- if (settings == null)
- return;
-
- // filter options which are related to the formatter component
- String componentName = CompletionEngine.class.getName();
- for (int i = 0, max = settings.length; i < max; i++) {
- if (settings[i].getComponentName().equals(componentName)) {
- this.setOption(settings[i]);
- }
- }
- }
-
- public void setVisibilitySensitive(boolean visibilitySensitive){
- this.visibilitySensitive = visibilitySensitive;
- }
-
- public boolean checkVisibilitySensitive(){
- return visibilitySensitive;
- }
-
- public void setEntireWordReplacement(boolean entireWordReplacement){
- this.entireWordReplacement = entireWordReplacement;
- }
-
- public boolean checkEntireWordReplacement(){
- return entireWordReplacement;
- }
-
- /**
- * Change the value of the option corresponding to the option number
- *
- * @param optionNumber <CODE>int</CODE>
- * @param newValue <CODE>int</CODE>
- */
- public void setOption(ConfigurableOption setting) {
- String componentName = CompletionEngine.class.getName();
-
- String optionID = setting.getID();
-
- if (optionID.equals(OPTION_PerformVisibilityCheck)) {
- setVisibilitySensitive(setting.getValueIndex() == 0);
- } else if (optionID.equals(OPTION_EntireWordReplacement)) {
- setEntireWordReplacement(setting.getValueIndex() == 0);
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
index d6c80ee870..2e949d90e4 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
@@ -16,121 +16,102 @@ import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.impl.*;
public abstract class Engine implements ITypeRequestor {
-
public LookupEnvironment lookupEnvironment;
+/**
+ * Add an additional binary type
+ */
- /**
- * Add an additional binary type
- */
- public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
- lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
- }
+public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
+ lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
+}
+/**
+ * Add an additional compilation unit.
+ */
- /**
- * Add an additional compilation unit.
- */
- public void accept(ICompilationUnit sourceUnit) {
- CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
- CompilationUnitDeclaration parsedUnit =
- this.getParser().dietParse(sourceUnit, result);
+public void accept(ICompilationUnit sourceUnit) {
+ CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
+ CompilationUnitDeclaration parsedUnit = this.getParser().dietParse(sourceUnit, result);
- lookupEnvironment.buildTypeBindings(parsedUnit);
- lookupEnvironment.completeTypeBindings(parsedUnit, true);
- }
+ lookupEnvironment.buildTypeBindings(parsedUnit);
+ lookupEnvironment.completeTypeBindings(parsedUnit, true);
+}
+/**
+ * Add an additional source type
+ */
- /**
- * Add additional source types (the first one is the requested type, the rest is formed by the
- * secondary types defined in the same compilation unit).
- */
- public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
- CompilationResult result =
- new CompilationResult(sourceTypes[0].getFileName(), 1, 1);
- CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
- lookupEnvironment.problemReporter,
- result);
+public void accept(ISourceType sourceType, PackageBinding packageBinding) {
+ CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1); // need to hold onto this
+ CompilationUnitDeclaration unit =
+ SourceTypeConverter.buildCompilationUnit(sourceType, true, true, lookupEnvironment.problemReporter, result);
- if (unit != null) {
- lookupEnvironment.buildTypeBindings(unit);
- lookupEnvironment.completeTypeBindings(unit, true);
- }
+ if (unit != null) {
+ lookupEnvironment.buildTypeBindings(unit);
+ lookupEnvironment.completeTypeBindings(unit, true);
}
-
- /**
- * Answer an array of descriptions for the configurable options.
- * The descriptions may be changed and passed back to a different
- * compiler.
- *
- * @return ConfigurableOption[] - array of configurable options
- */
- public static ConfigurableOption[] getDefaultOptions(Locale locale) {
- return Compiler.getDefaultOptions(locale);
+}
+/**
+ * Answer an array of descriptions for the configurable options.
+ * The descriptions may be changed and passed back to a different
+ * compiler.
+ *
+ * @return ConfigurableOption[] - array of configurable options
+ */
+public static ConfigurableOption[] getDefaultOptions(Locale locale) {
+ return Compiler.getDefaultOptions(locale);
+}
+public abstract AssistParser getParser();
+protected void parseMethod(CompilationUnitDeclaration unit, int position) {
+ for (int i = unit.types.length; --i >= 0;) {
+ TypeDeclaration type = unit.types[i];
+ if (type.declarationSourceStart < position && type.declarationSourceEnd >= position) {
+ getParser().scanner.setSourceBuffer(unit.compilationResult.compilationUnit.getContents());
+ parseMethod(type, unit, position);
+ return;
+ }
}
- public abstract AssistParser getParser();
- protected void parseMethod(CompilationUnitDeclaration unit, int position) {
- for (int i = unit.types.length; --i >= 0;) {
- TypeDeclaration type = unit.types[i];
- if (type.declarationSourceStart < position
- && type.declarationSourceEnd >= position) {
- getParser().scanner.setSourceBuffer(
- unit.compilationResult.compilationUnit.getContents());
- parseMethod(type, unit, position);
+}
+private void parseMethod(TypeDeclaration type, CompilationUnitDeclaration unit, int position) {
+ //members
+ TypeDeclaration[] memberTypes = type.memberTypes;
+ if (memberTypes != null) {
+ for (int i = memberTypes.length; --i >= 0;) {
+ TypeDeclaration memberType = memberTypes[i];
+ if (memberType.bodyStart > position) continue;
+ if (memberType.declarationSourceEnd >= position) {
+ parseMethod(memberType, unit, position);
return;
}
}
}
- private void parseMethod(
- TypeDeclaration type,
- CompilationUnitDeclaration unit,
- int position) {
- //members
- TypeDeclaration[] memberTypes = type.memberTypes;
- if (memberTypes != null) {
- for (int i = memberTypes.length; --i >= 0;) {
- TypeDeclaration memberType = memberTypes[i];
- if (memberType.bodyStart > position)
- continue;
- if (memberType.declarationSourceEnd >= position) {
- parseMethod(memberType, unit, position);
- return;
- }
- }
- }
- //methods
- AbstractMethodDeclaration[] methods = type.methods;
- if (methods != null) {
- for (int i = methods.length; --i >= 0;) {
- AbstractMethodDeclaration method = methods[i];
- if (method.bodyStart > position)
- continue;
- if (method.declarationSourceEnd >= position) {
- getParser().parseBlockStatements(method, unit);
- return;
- }
- }
- }
- //initializers
- FieldDeclaration[] fields = type.fields;
- if (fields != null) {
- for (int i = fields.length; --i >= 0;) {
- if (!(fields[i] instanceof Initializer))
- continue;
- Initializer initializer = (Initializer) fields[i];
- if (initializer.bodyStart > position)
- continue;
- if (initializer.declarationSourceEnd >= position) {
- getParser().parseBlockStatements(initializer, type, unit);
- return;
- }
+ //methods
+ AbstractMethodDeclaration[] methods = type.methods;
+ if (methods != null) {
+ for (int i = methods.length; --i >= 0;) {
+ AbstractMethodDeclaration method = methods[i];
+ if (method.bodyStart > position) continue;
+ if (method.declarationSourceEnd >= position) {
+ getParser().parseBlockStatements(method, unit);
+ return;
}
}
}
- protected void reset() {
- lookupEnvironment.reset();
+ //initializers
+ FieldDeclaration[] fields = type.fields;
+ if (fields != null) {
+ for (int i = fields.length; --i >= 0;) {
+ if (!(fields[i] instanceof Initializer)) continue;
+ Initializer initializer = (Initializer) fields[i];
+ if (initializer.bodyStart > position) continue;
+ if (initializer.declarationSourceEnd>= position) {
+ getParser().parseBlockStatements(initializer, type, unit);
+ return;
+ }
+ }
}
-} \ No newline at end of file
+}
+protected void reset() {
+ lookupEnvironment.reset();
+}
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/options.properties b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/options.properties
new file mode 100644
index 0000000000..f2f2745617
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/options.properties
@@ -0,0 +1,11 @@
+show.superHierarchyOverriddenDeclarations.number=1
+show.superHierarchyOverriddenDeclarations.category=Show
+show.superHierarchyOverriddenDeclarations.name=Show super hierarchy overridden methods or fields
+show.superHierarchyOverriddenDeclarations.possibleValues=2|Yes|No
+show.superHierarchyOverriddenDeclarations.description=Show any method or field declared into the super hierarchy even if overridden by a more specialized version.
+
+show.enclosingHierarchyOverriddenDeclarations.number=2
+show.enclosingHierarchyOverriddenDeclarations.category=Show
+show.enclosingHierarchyOverriddenDeclarations.name=Show enslosing hierarchy overridden methods or fields
+show.enclosingHierarchyOverriddenDeclarations.possibleValues=2|Yes|No
+show.enclosingHierarchyOverriddenDeclarations.description=Show any method or field declared into the enclosing hierarchy even if overridden by a more enclosed version.
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
index f092f25963..c129f322d7 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
@@ -40,23 +40,23 @@ public void resolve(BlockScope scope) {
}
public String toString(int tab) {
String s = tabString(tab);
- s += "<SelectOnExplicitConstructorCall:"; //$NON-NLS-1$
+ s += "<SelectOnExplicitConstructorCall:"/*nonNLS*/;
if (qualification != null)
- s = s + qualification.toStringExpression() + "."; //$NON-NLS-1$
+ s = s + qualification.toStringExpression() + "."/*nonNLS*/;
if (accessMode == This) {
- s = s + "this("; //$NON-NLS-1$
+ s = s + "this("/*nonNLS*/;
} else {
- s = s + "super("; //$NON-NLS-1$
+ s = s + "super("/*nonNLS*/;
}
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
s += arguments[i].toStringExpression();
if (i != arguments.length - 1) {
- s += ", "; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
}
};
}
- s += ")>"; //$NON-NLS-1$
+ s += ")>"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
index 267ffc50e4..47688f76cd 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
@@ -41,8 +41,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/* slow code */
- return "<SelectionOnFieldReference:" //$NON-NLS-1$
+ return "<SelectionOnFieldReference:"/*nonNLS*/
+ super.toStringExpression()
- + ">"; //$NON-NLS-1$
+ + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
index fcb222bed9..fa29b317c8 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
@@ -33,14 +33,14 @@ public SelectionOnImportReference(char[][] tokens , long[] positions) {
public String toString(int tab, boolean withOnDemand) {
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer. append("<SelectOnImport:"); //$NON-NLS-1$
+ buffer. append("<SelectOnImport:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
index ed685bddc7..262dfdb5ce 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
@@ -38,19 +38,19 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression() {
/*slow code*/
- String s = "<SelectOnMessageSend:"; //$NON-NLS-1$
+ String s = "<SelectOnMessageSend:"/*nonNLS*/;
if (receiver != ThisReference.ThisImplicit)
- s = s + receiver.toStringExpression() + "."; //$NON-NLS-1$
- s = s + new String(selector) + "("; //$NON-NLS-1$
+ s = s + receiver.toStringExpression() + "."/*nonNLS*/;
+ s = s + new String(selector) + "("/*nonNLS*/;
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
s += arguments[i].toStringExpression();
if (i != arguments.length - 1) {
- s += ", "; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
}
};
}
- s = s + ")>"; //$NON-NLS-1$
+ s = s + ")>"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
index fbe58864ea..58460d3e5f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
@@ -31,14 +31,14 @@ public SelectionOnPackageReference(char[][] tokens , long[] positions) {
}
public String toString(int tab, boolean withOnDemand) {
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer. append("<SelectOnPackage:"); //$NON-NLS-1$
+ buffer. append("<SelectOnPackage:"/*nonNLS*/);
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
index 4c36ccefc6..f590a7deb5 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
@@ -57,8 +57,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(int tab) {
return
((this.enclosingInstance == null) ?
- "<SelectOnAllocationExpression:" : //$NON-NLS-1$
- "<SelectOnQualifiedAllocationExpression:") + //$NON-NLS-1$
- super.toStringExpression(tab) + ">"; //$NON-NLS-1$
+ "<SelectOnAllocationExpression:"/*nonNLS*/ :
+ "<SelectOnQualifiedAllocationExpression:"/*nonNLS*/) +
+ super.toStringExpression(tab) + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
index a233b1818e..d6cd44f1c4 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
@@ -56,13 +56,13 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression() {
- StringBuffer buffer = new StringBuffer("<SelectOnName:"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("<SelectOnName:"/*nonNLS*/);
for (int i = 0, length = tokens.length; i < length; i++) {
buffer.append(tokens[i]);
if (i != length - 1)
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
index 60737b0092..d4c9138e16 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
@@ -45,9 +45,9 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression(){
- StringBuffer buffer = new StringBuffer("<SelectOnQualifiedSuper:"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("<SelectOnQualifiedSuper:"/*nonNLS*/);
buffer.append(super.toStringExpression());
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
index 0ca55c720d..fb94e29376 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
@@ -42,13 +42,13 @@ public TypeBinding getTypeBinding(Scope scope) {
public String toStringExpression(int tab) {
StringBuffer buffer = new StringBuffer();
- buffer.append("<SelectOnType:"); //$NON-NLS-1$
+ buffer.append("<SelectOnType:"/*nonNLS*/);
for (int i = 0, length = tokens.length; i < length; i++) {
buffer.append(tokens[i]);
if (i != length - 1)
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
- buffer.append(">"); //$NON-NLS-1$
+ buffer.append(">"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
index 6274c12574..f79a4f6970 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
@@ -47,6 +47,6 @@ public TypeBinding resolveType(BlockScope scope) {
throw new SelectionNodeFound(binding);
}
public String toStringExpression() {
- return "<SelectOnName:" + super.toStringExpression() + ">"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<SelectOnName:"/*nonNLS*/ + super.toStringExpression() + ">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
index 5a1c51b87b..25632914df 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
@@ -46,6 +46,6 @@ public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclo
}
public String toStringExpression(int tab){
- return "<SelectOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<SelectOnType:"/*nonNLS*/ + new String(token) + ">"/*nonNLS*/ ;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
index 28f9f55a4c..ea6450a647 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
@@ -46,7 +46,7 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression(){
- return "<SelectOnSuper:"+super.toStringExpression()+">"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "<SelectOnSuper:"/*nonNLS*/+super.toStringExpression()+">"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 2e5545eb5c..2752e8d5e5 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -30,14 +30,9 @@ public class SelectionParser extends AssistParser {
public int selectionStart, selectionEnd;
public AstNode selectionNode;
- public static final char[] SUPER = "super".toCharArray(); //$NON-NLS-1$
-
-/** @deprecated - should use constructor with assertMode */
+ public static final char[] SUPER = "super"/*nonNLS*/.toCharArray();
public SelectionParser(ProblemReporter problemReporter) {
- this(problemReporter, false/*no assertion by default*/);
-}
-public SelectionParser(ProblemReporter problemReporter, boolean assertMode) {
- super(problemReporter, assertMode);
+ super(problemReporter);
}
public char[] assistIdentifier(){
return ((SelectionScanner)scanner).selectionIdentifier;
@@ -422,7 +417,7 @@ protected NameReference getUnspecifiedReferenceOptimized() {
return reference;
}
public void initializeScanner(){
- this.scanner = new SelectionScanner(this.assertMode);
+ this.scanner = new SelectionScanner();
}
protected MessageSend newMessageSend() {
// '(' ArgumentListopt ')'
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
index 80541e4a09..e98bb1daa0 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
@@ -21,11 +21,6 @@ public class SelectionScanner extends Scanner {
* on an identifier prefix.
*
*/
-
-public SelectionScanner(boolean assertMode) {
- super(false, false, false, assertMode);
-}
-
public char[] getCurrentIdentifierSource() {
if (selectionIdentifier == null){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
index 553e90ea87..caef291509 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
@@ -48,8 +48,6 @@ public class AbstractSyntaxTreeVisitorAdapter implements IAbstractSyntaxTreeVisi
}
public void endVisit(Assignment assignment, BlockScope scope) {
}
- public void endVisit(AssertStatement assertStatement, BlockScope scope) {
- }
public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
}
public void endVisit(Block block, BlockScope scope) {
@@ -260,9 +258,6 @@ public class AbstractSyntaxTreeVisitorAdapter implements IAbstractSyntaxTreeVisi
public boolean visit(Assignment assignment, BlockScope scope) {
return true;
}
- public boolean visit(AssertStatement assertStatement, BlockScope scope) {
- return true;
- }
public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
return true;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index c09067920c..8b5b98adf8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -4,17 +4,6 @@ package org.eclipse.jdt.internal.compiler;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-import java.io.*;
-import java.util.*;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
-
/**
* Represents a class file wrapper on bytes, it is aware of its actual
* type name.
@@ -32,20 +21,29 @@ import org.eclipse.jdt.internal.compiler.util.*;
* Answer a smaller byte format, which is only contains some structural
* information. Those bytes are decodable with a regular class file reader,
* such as DietClassFileReader
- */
-public class ClassFile
- implements AttributeNamesConstants, CompilerModifiers, TypeConstants, TypeIds {
+ */
+
+import java.io.*;
+import java.util.*;
+import org.eclipse.jdt.internal.compiler.Compiler;
+import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.internal.compiler.util.*;
+
+
+public class ClassFile implements AttributeNamesConstants, CompilerModifiers, TypeConstants, TypeIds {
public SourceTypeBinding referenceBinding;
public ConstantPool constantPool;
- public ClassFile enclosingClassFile;
- // used to generate private access methods
+ public ClassFile enclosingClassFile; // used to generate private access methods
public int produceDebugAttributes;
public ReferenceBinding[] innerClassesBindings;
public int numberOfInnerClasses;
- public byte[] header;
- // the header contains all the bytes till the end of the constant pool
- public byte[] contents;
- // that collection contains all the remaining bytes of the .class file
+ public byte[] header; // the header contains all the bytes till the end of the constant pool
+ public byte[] contents; // that collection contains all the remaining bytes of the .class file
public int headerOffset;
public int contentsOffset;
public int constantPoolOffset;
@@ -56,1358 +54,1363 @@ public class ClassFile
public static final int INITIAL_HEADER_SIZE = 1000;
public static final int INCREMENT_SIZE = 1000;
public static final int INNER_CLASSES_SIZE = 5;
- protected HashtableOfType nameUsage;
+ protected CharArrayCache nameUsage;
public CodeStream codeStream;
- protected int problemLine; // used to create line number attributes for problem methods
-
- /**
- * INTERNAL USE-ONLY
- * This methods creates a new instance of the receiver.
- */
- public ClassFile() {
+ protected int problemLine; // used to create line number attributes for problem methods
+/**
+ * INTERNAL USE-ONLY
+ * This methods creates a new instance of the receiver.
+ */
+public ClassFile() {}
+/**
+ * INTERNAL USE-ONLY
+ * This methods creates a new instance of the receiver.
+ *
+ * @param aType org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
+ * @param enclosingClassFile org.eclipse.jdt.internal.compiler.ClassFile
+ * @param creatingProblemType <CODE>boolean</CODE>
+ */
+public ClassFile(SourceTypeBinding aType, ClassFile enclosingClassFile, boolean creatingProblemType) {
+ referenceBinding = aType;
+ header = new byte[INITIAL_HEADER_SIZE];
+ // generate the magic numbers inside the header
+ header[headerOffset++] = (byte) (0xCAFEBABEL >> 24);
+ header[headerOffset++] = (byte) (0xCAFEBABEL >> 16);
+ header[headerOffset++] = (byte) (0xCAFEBABEL >> 8);
+ header[headerOffset++] = (byte) (0xCAFEBABEL >> 0);
+ if (((SourceTypeBinding) referenceBinding).scope.environment().options.targetJDK == CompilerOptions.JDK1_2) {
+ // Compatible with JDK 1.2
+ header[headerOffset++] = 0; // minorVersion = 0 means we just need to offset the current offset by 2
+ header[headerOffset++] = 0;
+ header[headerOffset++] = 0;
+ header[headerOffset++] = 46;
+ } else {
+ // Compatible with JDK 1.1
+ header[headerOffset++] = 0;
+ header[headerOffset++] = 3;
+ header[headerOffset++] = 0;
+ header[headerOffset++] = 45;
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods creates a new instance of the receiver.
- *
- * @param aType org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
- * @param enclosingClassFile org.eclipse.jdt.internal.compiler.ClassFile
- * @param creatingProblemType <CODE>boolean</CODE>
- */
- public ClassFile(
- SourceTypeBinding aType,
- ClassFile enclosingClassFile,
- boolean creatingProblemType) {
- referenceBinding = aType;
- header = new byte[INITIAL_HEADER_SIZE];
- // generate the magic numbers inside the header
- header[headerOffset++] = (byte) (0xCAFEBABEL >> 24);
- header[headerOffset++] = (byte) (0xCAFEBABEL >> 16);
- header[headerOffset++] = (byte) (0xCAFEBABEL >> 8);
- header[headerOffset++] = (byte) (0xCAFEBABEL >> 0);
- if (((SourceTypeBinding) referenceBinding)
- .scope
- .environment()
- .options
- .targetJDK
- == CompilerOptions.JDK1_2) {
- // Compatible with JDK 1.2
- header[headerOffset++] = 0;
- // minorVersion = 0 means we just need to offset the current offset by 2
- header[headerOffset++] = 0;
- header[headerOffset++] = 0;
- header[headerOffset++] = 46;
- } else {
- // Compatible with JDK 1.1
- header[headerOffset++] = 0;
- header[headerOffset++] = 3;
- header[headerOffset++] = 0;
- header[headerOffset++] = 45;
- }
- constantPoolOffset = headerOffset;
- headerOffset += 2;
- constantPool = new ConstantPool(this);
- int accessFlags = aType.getAccessFlags() | AccSuper;
- if (aType.isNestedType()) {
- if (aType.isStatic()) {
- // clear Acc_Static
- accessFlags &= ~AccStatic;
- }
- if (aType.isPrivate()) {
- // clear Acc_Private and Acc_Public
- accessFlags &= ~(AccPrivate | AccPublic);
- }
- if (aType.isProtected()) {
- // clear Acc_Protected and set Acc_Public
- accessFlags &= ~AccProtected;
- accessFlags |= AccPublic;
- }
- }
- // clear all bits that are illegal for a class or an interface
- accessFlags
- &= ~(
- AccStrictfp
- | AccProtected
- | AccPrivate
- | AccStatic
- | AccSynchronized
- | AccNative);
-
- this.enclosingClassFile = enclosingClassFile;
- // innerclasses get their names computed at code gen time
- if (aType.isLocalType()) {
- ((LocalTypeBinding) aType).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) aType));
- ReferenceBinding[] memberTypes = aType.memberTypes();
- for (int i = 0, max = memberTypes.length; i < max; i++) {
- ((LocalTypeBinding) memberTypes[i]).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) memberTypes[i]));
- }
- }
- contents = new byte[INITIAL_CONTENTS_SIZE];
- // now we continue to generate the bytes inside the contents array
- contents[contentsOffset++] = (byte) (accessFlags >> 8);
- contents[contentsOffset++] = (byte) accessFlags;
- int classNameIndex = constantPool.literalIndex(aType);
- contents[contentsOffset++] = (byte) (classNameIndex >> 8);
- contents[contentsOffset++] = (byte) classNameIndex;
- int superclassNameIndex;
- if (aType.isInterface()) {
- superclassNameIndex = constantPool.literalIndexForJavaLangObject();
- } else {
- superclassNameIndex =
- (aType.superclass == null ? 0 : constantPool.literalIndex(aType.superclass));
- }
- contents[contentsOffset++] = (byte) (superclassNameIndex >> 8);
- contents[contentsOffset++] = (byte) superclassNameIndex;
- ReferenceBinding[] superInterfacesBinding = aType.superInterfaces();
- int interfacesCount = superInterfacesBinding.length;
- contents[contentsOffset++] = (byte) (interfacesCount >> 8);
- contents[contentsOffset++] = (byte) interfacesCount;
- if (superInterfacesBinding != null) {
- for (int i = 0; i < interfacesCount; i++) {
- int interfaceIndex = constantPool.literalIndex(superInterfacesBinding[i]);
- contents[contentsOffset++] = (byte) (interfaceIndex >> 8);
- contents[contentsOffset++] = (byte) interfaceIndex;
- }
+ constantPoolOffset = headerOffset;
+ headerOffset += 2;
+ constantPool = new ConstantPool(this);
+ int accessFlags = aType.getAccessFlags() | AccSuper;
+ if (aType.isNestedType()) {
+ if (aType.isStatic()) {
+ // clear Acc_Static
+ accessFlags &= ~AccStatic;
+ }
+ if (aType.isPrivate()) {
+ // clear Acc_Private and Acc_Public
+ accessFlags &= ~ (AccPrivate | AccPublic);
+ }
+ if (aType.isProtected()) {
+ // clear Acc_Protected and set Acc_Public
+ accessFlags &= ~AccProtected;
+ accessFlags |= AccPublic;
}
- produceDebugAttributes =
- ((SourceTypeBinding) referenceBinding)
- .scope
- .environment()
- .options
- .produceDebugAttributes;
- innerClassesBindings = new ReferenceBinding[INNER_CLASSES_SIZE];
- this.creatingProblemType = creatingProblemType;
- codeStream = new CodeStream(this);
+ }
+ // clear all bits that are illegal for a class or an interface
+ accessFlags &= ~(AccStrictfp | AccProtected | AccPrivate | AccStatic | AccSynchronized | AccNative);
- // retrieve the enclosing one guaranteed to be the one matching the propagated flow info
- // 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
- ClassFile outermostClassFile = this.outerMostEnclosingClassFile();
- if (this == outermostClassFile) {
- codeStream.maxFieldCount = aType.scope.referenceType().maxFieldCount;
- } else {
- codeStream.maxFieldCount = outermostClassFile.codeStream.maxFieldCount;
+ this.enclosingClassFile = enclosingClassFile;
+ // innerclasses get their names computed at code gen time
+ if (aType.isLocalType()) {
+ ((LocalTypeBinding) aType).constantPoolName(computeConstantPoolName((LocalTypeBinding) aType));
+ ReferenceBinding[] memberTypes = aType.memberTypes();
+ for (int i = 0, max = memberTypes.length; i < max; i++) {
+ ((LocalTypeBinding) memberTypes[i]).constantPoolName(computeConstantPoolName((LocalTypeBinding) memberTypes[i]));
}
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a boggus method.
- *
- * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
- */
- public void addAbstractMethod(
- AbstractMethodDeclaration method,
- MethodBinding methodBinding) {
-
- // force the modifiers to be public and abstract
- methodBinding.modifiers = AccPublic | AccAbstract;
-
- this.generateMethodInfoHeader(methodBinding);
- int methodAttributeOffset = this.contentsOffset;
- int attributeNumber = this.generateMethodInfoAttribute(methodBinding);
- this.completeMethodInfo(methodAttributeOffset, attributeNumber);
+ contents = new byte[INITIAL_CONTENTS_SIZE];
+ // now we continue to generate the bytes inside the contents array
+ contents[contentsOffset++] = (byte) (accessFlags >> 8);
+ contents[contentsOffset++] = (byte) accessFlags;
+ int classNameIndex = constantPool.literalIndex(aType);
+ contents[contentsOffset++] = (byte) (classNameIndex >> 8);
+ contents[contentsOffset++] = (byte) classNameIndex;
+ int superclassNameIndex;
+ if (aType.isInterface()) {
+ superclassNameIndex = constantPool.literalIndexForJavaLangObject();
+ } else {
+ superclassNameIndex = (aType.superclass == null ? 0 : constantPool.literalIndex(aType.superclass));
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods generate all the attributes for the receiver.
- * For a class they could be:
- * - source file attribute
- * - inner classes attribute
- * - deprecated attribute
- */
- public void addAttributes() {
- // update the method count
- contents[methodCountOffset++] = (byte) (methodCount >> 8);
- contents[methodCountOffset] = (byte) methodCount;
-
- int attributeNumber = 0;
- // leave two bytes for the number of attributes and store the current offset
- int attributeOffset = contentsOffset;
- contentsOffset += 2;
-
- // source attribute
- if ((produceDebugAttributes & CompilerOptions.Source) != 0) {
- String fullFileName =
- new String(referenceBinding.scope.referenceCompilationUnit().getFileName());
- fullFileName = fullFileName.replace('\\', '/');
- int lastIndex = fullFileName.lastIndexOf('/');
- if (lastIndex != -1) {
- fullFileName = fullFileName.substring(lastIndex + 1, fullFileName.length());
- }
- // check that there is enough space to write all the bytes for the field info corresponding
- // to the @fieldBinding
- int contentsLength;
- if (contentsOffset + 8 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int sourceAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SourceName);
- contents[contentsOffset++] = (byte) (sourceAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) sourceAttributeNameIndex;
- // The length of a source file attribute is 2. This is a fixed-length
- // attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- // write the source file name
- int fileNameIndex = constantPool.literalIndex(fullFileName.toCharArray());
- contents[contentsOffset++] = (byte) (fileNameIndex >> 8);
- contents[contentsOffset++] = (byte) fileNameIndex;
- attributeNumber++;
- }
- // Deprecated attribute
- if (referenceBinding.isDeprecated()) {
- // check that there is enough space to write all the bytes for the field info corresponding
- // to the @fieldBinding
- int contentsLength;
- if (contentsOffset + 6 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int deprecatedAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
- contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
- // the length of a deprecated attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- attributeNumber++;
- }
- // Inner class attribute
- if (numberOfInnerClasses != 0) {
- // Generate the inner class attribute
- int contentsLength;
- int exSize;
- if (contentsOffset + (exSize = (8 * numberOfInnerClasses + 8))
- >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents =
- new byte[contentsLength
- + (exSize >= INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]),
- 0,
- contentsLength);
- }
- // Now we now the size of the attribute and the number of entries
- // attribute name
- int attributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.InnerClassName);
- contents[contentsOffset++] = (byte) (attributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) attributeNameIndex;
- int value = (numberOfInnerClasses << 3) + 2;
- contents[contentsOffset++] = (byte) (value >> 24);
- contents[contentsOffset++] = (byte) (value >> 16);
- contents[contentsOffset++] = (byte) (value >> 8);
- contents[contentsOffset++] = (byte) value;
- contents[contentsOffset++] = (byte) (numberOfInnerClasses >> 8);
- contents[contentsOffset++] = (byte) numberOfInnerClasses;
- for (int i = 0; i < numberOfInnerClasses; i++) {
- ReferenceBinding innerClass = innerClassesBindings[i];
- int accessFlags = innerClass.getAccessFlags();
- int innerClassIndex = constantPool.literalIndex(innerClass);
- // inner class index
- contents[contentsOffset++] = (byte) (innerClassIndex >> 8);
- contents[contentsOffset++] = (byte) innerClassIndex;
- // outer class index: anonymous and local have no outer class index
- if (innerClass.isMemberType()) {
- // member or member of local
- int outerClassIndex = constantPool.literalIndex(innerClass.enclosingType());
- contents[contentsOffset++] = (byte) (outerClassIndex >> 8);
- contents[contentsOffset++] = (byte) outerClassIndex;
- } else {
- // equals to 0 if the innerClass is not a member type
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- }
- // name index
- if (!innerClass.isAnonymousType()) {
- int nameIndex = constantPool.literalIndex(innerClass.sourceName());
- contents[contentsOffset++] = (byte) (nameIndex >> 8);
- contents[contentsOffset++] = (byte) nameIndex;
- } else {
- // equals to 0 if the innerClass is an anonymous type
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- }
- // access flag
- if (innerClass.isAnonymousType()) {
- accessFlags |= AccPrivate;
- } else
- if (innerClass.isLocalType() && !innerClass.isMemberType()) {
- accessFlags |= AccPrivate;
- }
- contents[contentsOffset++] = (byte) (accessFlags >> 8);
- contents[contentsOffset++] = (byte) accessFlags;
- }
- attributeNumber++;
+ contents[contentsOffset++] = (byte) (superclassNameIndex >> 8);
+ contents[contentsOffset++] = (byte) superclassNameIndex;
+ ReferenceBinding[] superInterfacesBinding = aType.superInterfaces();
+ int interfacesCount = superInterfacesBinding.length;
+ contents[contentsOffset++] = (byte) (interfacesCount >> 8);
+ contents[contentsOffset++] = (byte) interfacesCount;
+ if (superInterfacesBinding != null) {
+ for (int i = 0; i < interfacesCount; i++) {
+ int interfaceIndex = constantPool.literalIndex(superInterfacesBinding[i]);
+ contents[contentsOffset++] = (byte) (interfaceIndex >> 8);
+ contents[contentsOffset++] = (byte) interfaceIndex;
}
- // update the number of attributes
- contents[attributeOffset++] = (byte) (attributeNumber >> 8);
- contents[attributeOffset] = (byte) attributeNumber;
-
- // resynchronize all offsets of the classfile
- header = constantPool.poolContent;
- headerOffset = constantPool.currentOffset;
- int constantPoolCount = constantPool.currentIndex;
- header[constantPoolOffset++] = (byte) (constantPoolCount >> 8);
- header[constantPoolOffset] = (byte) constantPoolCount;
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods generate all the default abstract method infos that correpond to
- * the abstract methods inherited from superinterfaces.
- */
- public void addDefaultAbstractMethods() { // default abstract methods
- MethodBinding[] defaultAbstractMethods =
- referenceBinding.getDefaultAbstractMethods();
- for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
- generateMethodInfoHeader(defaultAbstractMethods[i]);
- int methodAttributeOffset = contentsOffset;
- int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
- completeMethodInfo(methodAttributeOffset, attributeNumber);
+ produceDebugAttributes = ((SourceTypeBinding) referenceBinding).scope.environment().options.produceDebugAttributes;
+ innerClassesBindings = new ReferenceBinding[INNER_CLASSES_SIZE];
+ this.creatingProblemType = creatingProblemType;
+ codeStream = new CodeStream(this);
+
+ // retrieve the enclosing one guaranteed to be the one matching the propagated flow info
+ // 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
+ ClassFile outermostClassFile = this.outerMostEnclosingClassFile();
+ if (this == outermostClassFile) {
+ codeStream.maxFieldCount = aType.scope.referenceType().maxFieldCount;
+ } else {
+ codeStream.maxFieldCount = outermostClassFile.codeStream.maxFieldCount;
+ }
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a boggus method.
+ *
+ * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
+ */
+public void addAbstractMethod(
+ AbstractMethodDeclaration method,
+ MethodBinding methodBinding) {
+
+ // force the modifiers to be public and abstract
+ methodBinding.modifiers = AccPublic | AccAbstract;
+
+ this.generateMethodInfoHeader(methodBinding);
+ int methodAttributeOffset = this.contentsOffset;
+ int attributeNumber = this.generateMethodInfoAttribute(methodBinding);
+ this.completeMethodInfo(methodAttributeOffset, attributeNumber);
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods generate all the attributes for the receiver.
+ * For a class they could be:
+ * - source file attribute
+ * - inner classes attribute
+ * - deprecated attribute
+ */
+public void addAttributes() {
+ // update the method count
+ contents[methodCountOffset++] = (byte) (methodCount >> 8);
+ contents[methodCountOffset] = (byte) methodCount;
+
+ int attributeNumber = 0;
+ // leave two bytes for the number of attributes and store the current offset
+ int attributeOffset = contentsOffset;
+ contentsOffset += 2;
+
+ // source attribute
+ if ((produceDebugAttributes & CompilerOptions.Source) != 0) {
+ String fullFileName = new String(referenceBinding.scope.referenceCompilationUnit().getFileName());
+ fullFileName = fullFileName.replace('\\', '/');
+ int lastIndex = fullFileName.lastIndexOf('/');
+ if (lastIndex != -1) {
+ fullFileName = fullFileName.substring(lastIndex + 1, fullFileName.length());
}
+ // check that there is enough space to write all the bytes for the field info corresponding
+ // to the @fieldBinding
+ int contentsLength;
+ if (contentsOffset + 8 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ int sourceAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SourceName);
+ contents[contentsOffset++] = (byte) (sourceAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) sourceAttributeNameIndex;
+ // The length of a source file attribute is 2. This is a fixed-length
+ // attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ // write the source file name
+ int fileNameIndex = constantPool.literalIndex(fullFileName.toCharArray());
+ contents[contentsOffset++] = (byte) (fileNameIndex >> 8);
+ contents[contentsOffset++] = (byte) fileNameIndex;
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * This methods generates the bytes for the field binding passed like a parameter
- * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
- */
- public void addFieldInfo(FieldBinding fieldBinding) {
- int attributeNumber = 0;
+ // Deprecated attribute
+ if (referenceBinding.isDeprecated()) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
int contentsLength;
- if (contentsOffset + 30 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
+ if (contentsOffset + 6 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
- // Generate two attribute: constantValueAttribute and SyntheticAttribute
- // Now we can generate all entries into the byte array
- // First the accessFlags
- int accessFlags = fieldBinding.getAccessFlags();
- contents[contentsOffset++] = (byte) (accessFlags >> 8);
- contents[contentsOffset++] = (byte) accessFlags;
- // Then the nameIndex
- int nameIndex = constantPool.literalIndex(fieldBinding.name);
- contents[contentsOffset++] = (byte) (nameIndex >> 8);
- contents[contentsOffset++] = (byte) nameIndex;
- // Then the descriptorIndex
- int descriptorIndex = constantPool.literalIndex(fieldBinding.type.signature());
- contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
- contents[contentsOffset++] = (byte) descriptorIndex;
- // leave some space for the number of attributes
- int fieldAttributeOffset = contentsOffset;
- contentsOffset += 2;
- // 4.7.2 only static constant fields get a ConstantAttribute
- if (fieldBinding.isStatic()
- && fieldBinding.constant != Constant.NotAConstant
- && fieldBinding.constant.typeID() != T_null) {
- // Now we generate the constant attribute corresponding to the fieldBinding
- int constantValueNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.ConstantValueName);
- contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
- contents[contentsOffset++] = (byte) constantValueNameIndex;
- // The attribute length = 2 in case of a constantValue attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- attributeNumber++;
- // Need to add the constant_value_index
- switch (fieldBinding.constant.typeID()) {
- case T_boolean :
- int booleanValueIndex =
- constantPool.literalIndex(fieldBinding.constant.booleanValue() ? 1 : 0);
- contents[contentsOffset++] = (byte) (booleanValueIndex >> 8);
- contents[contentsOffset++] = (byte) booleanValueIndex;
- break;
- case T_byte :
- case T_char :
- case T_int :
- case T_short :
- int integerValueIndex =
- constantPool.literalIndex(fieldBinding.constant.intValue());
- contents[contentsOffset++] = (byte) (integerValueIndex >> 8);
- contents[contentsOffset++] = (byte) integerValueIndex;
- break;
- case T_float :
- int floatValueIndex =
- constantPool.literalIndex(fieldBinding.constant.floatValue());
- contents[contentsOffset++] = (byte) (floatValueIndex >> 8);
- contents[contentsOffset++] = (byte) floatValueIndex;
- break;
- case T_double :
- int doubleValueIndex =
- constantPool.literalIndex(fieldBinding.constant.doubleValue());
- contents[contentsOffset++] = (byte) (doubleValueIndex >> 8);
- contents[contentsOffset++] = (byte) doubleValueIndex;
- break;
- case T_long :
- int longValueIndex =
- constantPool.literalIndex(fieldBinding.constant.longValue());
- contents[contentsOffset++] = (byte) (longValueIndex >> 8);
- contents[contentsOffset++] = (byte) longValueIndex;
- break;
- case T_String :
- int stringValueIndex =
- constantPool.literalIndex(
- ((StringConstant) fieldBinding.constant).stringValue());
- if (stringValueIndex == -1) {
- if (!creatingProblemType) {
- // report an error and abort: will lead to a problem type classfile creation
- TypeDeclaration typeDeclaration = referenceBinding.scope.referenceContext;
- FieldDeclaration[] fieldDecls = typeDeclaration.fields;
- for (int i = 0, max = fieldDecls.length; i < max; i++) {
- if (fieldDecls[i].binding == fieldBinding) {
- // problem should abort
- typeDeclaration.scope.problemReporter().stringConstantIsExceedingUtf8Limit(
- fieldDecls[i]);
- }
+ int deprecatedAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
+ contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
+ // the length of a deprecated attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ attributeNumber++;
+ }
+
+ // Inner class attribute
+ if (numberOfInnerClasses != 0) {
+ // Generate the inner class attribute
+ int contentsLength;
+ int exSize;
+ if (contentsOffset + (exSize = (8 * numberOfInnerClasses + 8)) >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + (exSize >= INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]), 0, contentsLength);
+ }
+ // Now we now the size of the attribute and the number of entries
+ // attribute name
+ int attributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.InnerClassName);
+ contents[contentsOffset++] = (byte) (attributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) attributeNameIndex;
+ int value = (numberOfInnerClasses << 3) + 2;
+ contents[contentsOffset++] = (byte) (value >> 24);
+ contents[contentsOffset++] = (byte) (value >> 16);
+ contents[contentsOffset++] = (byte) (value >> 8);
+ contents[contentsOffset++] = (byte) value;
+ contents[contentsOffset++] = (byte) (numberOfInnerClasses >> 8);
+ contents[contentsOffset++] = (byte) numberOfInnerClasses;
+ for (int i = 0; i < numberOfInnerClasses; i++) {
+ ReferenceBinding innerClass = innerClassesBindings[i];
+ int accessFlags = innerClass.getAccessFlags();
+ int innerClassIndex = constantPool.literalIndex(innerClass);
+ // inner class index
+ contents[contentsOffset++] = (byte) (innerClassIndex >> 8);
+ contents[contentsOffset++] = (byte) innerClassIndex;
+ // outer class index: anonymous and local have no outer class index
+ if (innerClass.isMemberType()) {
+ // member or member of local
+ int outerClassIndex = constantPool.literalIndex(innerClass.enclosingType());
+ contents[contentsOffset++] = (byte) (outerClassIndex >> 8);
+ contents[contentsOffset++] = (byte) outerClassIndex;
+ } else {
+ // equals to 0 if the innerClass is not a member type
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ }
+ // name index
+ if (!innerClass.isAnonymousType()) {
+ int nameIndex = constantPool.literalIndex(innerClass.sourceName());
+ contents[contentsOffset++] = (byte) (nameIndex >> 8);
+ contents[contentsOffset++] = (byte) nameIndex;
+ } else {
+ // equals to 0 if the innerClass is an anonymous type
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ }
+ // access flag
+ if (innerClass.isAnonymousType()) {
+ accessFlags |= AccPrivate;
+ } else
+ if (innerClass.isLocalType() && !innerClass.isMemberType()) {
+ accessFlags |= AccPrivate;
+ }
+ contents[contentsOffset++] = (byte) (accessFlags >> 8);
+ contents[contentsOffset++] = (byte) accessFlags;
+ }
+ attributeNumber++;
+ }
+ // update the number of attributes
+ contents[attributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[attributeOffset] = (byte) attributeNumber;
+
+ // resynchronize all offsets of the classfile
+ header = constantPool.poolContent;
+ headerOffset = constantPool.currentOffset;
+ int constantPoolCount = constantPool.currentIndex;
+ header[constantPoolOffset++] = (byte) (constantPoolCount >> 8);
+ header[constantPoolOffset] = (byte) constantPoolCount;
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods generate all the default abstract method infos that correpond to
+ * the abstract methods inherited from superinterfaces.
+ */
+public void addDefaultAbstractMethods() { // default abstract methods
+ MethodBinding[] defaultAbstractMethods = referenceBinding.getDefaultAbstractMethods();
+ for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
+ generateMethodInfoHeader(defaultAbstractMethods[i]);
+ int methodAttributeOffset = contentsOffset;
+ int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
+ completeMethodInfo(methodAttributeOffset, attributeNumber);
+ }
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods generates the bytes for the field binding passed like a parameter
+ * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
+ */
+public void addFieldInfo(FieldBinding fieldBinding) {
+ int attributeNumber = 0;
+ // check that there is enough space to write all the bytes for the field info corresponding
+ // to the @fieldBinding
+ int contentsLength;
+ if (contentsOffset + 30 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ // Generate two attribute: constantValueAttribute and SyntheticAttribute
+ // Now we can generate all entries into the byte array
+ // First the accessFlags
+ int accessFlags = fieldBinding.getAccessFlags();
+ contents[contentsOffset++] = (byte) (accessFlags >> 8);
+ contents[contentsOffset++] = (byte) accessFlags;
+ // Then the nameIndex
+ int nameIndex = constantPool.literalIndex(fieldBinding.name);
+ contents[contentsOffset++] = (byte) (nameIndex >> 8);
+ contents[contentsOffset++] = (byte) nameIndex;
+ // Then the descriptorIndex
+ int descriptorIndex = constantPool.literalIndex(fieldBinding.type.signature());
+ contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
+ contents[contentsOffset++] = (byte) descriptorIndex;
+ // leave some space for the number of attributes
+ int fieldAttributeOffset = contentsOffset;
+ contentsOffset += 2;
+ // 4.7.2 only static constant fields get a ConstantAttribute
+ if (fieldBinding.isStatic()
+ && fieldBinding.constant != Constant.NotAConstant
+ && fieldBinding.constant.typeID() != T_null) {
+ // Now we generate the constant attribute corresponding to the fieldBinding
+ int constantValueNameIndex = constantPool.literalIndex(AttributeNamesConstants.ConstantValueName);
+ contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
+ contents[contentsOffset++] = (byte) constantValueNameIndex;
+ // The attribute length = 2 in case of a constantValue attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ attributeNumber++;
+ // Need to add the constant_value_index
+ switch (fieldBinding.constant.typeID()) {
+ case T_boolean :
+ int booleanValueIndex = constantPool.literalIndex(fieldBinding.constant.booleanValue() ? 1 : 0);
+ contents[contentsOffset++] = (byte) (booleanValueIndex >> 8);
+ contents[contentsOffset++] = (byte) booleanValueIndex;
+ break;
+ case T_byte :
+ case T_char :
+ case T_int :
+ case T_short :
+ int integerValueIndex = constantPool.literalIndex(fieldBinding.constant.intValue());
+ contents[contentsOffset++] = (byte) (integerValueIndex >> 8);
+ contents[contentsOffset++] = (byte) integerValueIndex;
+ break;
+ case T_float :
+ int floatValueIndex = constantPool.literalIndex(fieldBinding.constant.floatValue());
+ contents[contentsOffset++] = (byte) (floatValueIndex >> 8);
+ contents[contentsOffset++] = (byte) floatValueIndex;
+ break;
+ case T_double :
+ int doubleValueIndex = constantPool.literalIndex(fieldBinding.constant.doubleValue());
+ contents[contentsOffset++] = (byte) (doubleValueIndex >> 8);
+ contents[contentsOffset++] = (byte) doubleValueIndex;
+ break;
+ case T_long :
+ int longValueIndex = constantPool.literalIndex(fieldBinding.constant.longValue());
+ contents[contentsOffset++] = (byte) (longValueIndex >> 8);
+ contents[contentsOffset++] = (byte) longValueIndex;
+ break;
+ case T_String :
+ int stringValueIndex = constantPool.literalIndex(((StringConstant) fieldBinding.constant).stringValue());
+ if (stringValueIndex == -1) {
+ if (!creatingProblemType) {
+ // report an error and abort: will lead to a problem type classfile creation
+ TypeDeclaration typeDeclaration = referenceBinding.scope.referenceContext;
+ FieldDeclaration[] fieldDecls = typeDeclaration.fields;
+ for (int i = 0, max = fieldDecls.length; i < max; i++) {
+ if (fieldDecls[i].binding == fieldBinding) {
+ // problem should abort
+ typeDeclaration.scope.problemReporter().stringConstantIsExceedingUtf8Limit(fieldDecls[i]);
}
- } else {
- // already inside a problem type creation : no constant for this field
- contentsOffset = fieldAttributeOffset + 2;
- // +2 is necessary to keep the two byte space for the attribute number
- attributeNumber--;
}
} else {
- contents[contentsOffset++] = (byte) (stringValueIndex >> 8);
- contents[contentsOffset++] = (byte) stringValueIndex;
+ // already inside a problem type creation : no constant for this field
+ contentsOffset = fieldAttributeOffset + 2; // +2 is necessary to keep the two byte space for the attribute number
+ attributeNumber--;
}
- }
- }
- if (fieldBinding.isSynthetic()) {
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- attributeNumber++;
- }
- if (fieldBinding.isDeprecated()) {
- int deprecatedAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
- contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
- // the length of a deprecated attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- attributeNumber++;
+ } else {
+ contents[contentsOffset++] = (byte) (stringValueIndex >> 8);
+ contents[contentsOffset++] = (byte) stringValueIndex;
+ }
}
- contents[fieldAttributeOffset++] = (byte) (attributeNumber >> 8);
- contents[fieldAttributeOffset] = (byte) attributeNumber;
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods generate all the fields infos for the receiver.
- * This includes:
- * - a field info for each defined field of that class
- * - a field info for each synthetic field (e.g. this$0)
- */
- public void addFieldInfos() {
- SourceTypeBinding currentBinding = referenceBinding;
- FieldBinding[] syntheticFields = currentBinding.syntheticFields();
- int fieldCount =
- currentBinding.fieldCount()
- + (syntheticFields == null ? 0 : syntheticFields.length);
-
- // write the number of fields
- contents[contentsOffset++] = (byte) (fieldCount >> 8);
- contents[contentsOffset++] = (byte) fieldCount;
-
- FieldBinding[] fieldBindings = currentBinding.fields();
- for (int i = 0, max = fieldBindings.length; i < max; i++) {
- addFieldInfo(fieldBindings[i]);
+ if (fieldBinding.isSynthetic()) {
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ attributeNumber++;
+ }
+ if (fieldBinding.isDeprecated()) {
+ int deprecatedAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
+ contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
+ // the length of a deprecated attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ attributeNumber++;
+ }
+ contents[fieldAttributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[fieldAttributeOffset] = (byte) attributeNumber;
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods generate all the fields infos for the receiver.
+ * This includes:
+ * - a field info for each defined field of that class
+ * - a field info for each synthetic field (e.g. this$0)
+ */
+public void addFieldInfos() {
+ SourceTypeBinding currentBinding = referenceBinding;
+ FieldBinding[] syntheticFields = currentBinding.syntheticFields();
+ int fieldCount = currentBinding.fieldCount() + (syntheticFields == null ? 0 : syntheticFields.length);
+
+ // write the number of fields
+ contents[contentsOffset++] = (byte) (fieldCount >> 8);
+ contents[contentsOffset++] = (byte) fieldCount;
+
+ FieldBinding[] fieldBindings = currentBinding.fields();
+ for (int i = 0, max = fieldBindings.length; i < max; i++) {
+ addFieldInfo(fieldBindings[i]);
+ }
+ if (syntheticFields != null) {
+ for (int i = 0, max = syntheticFields.length; i < max; i++) {
+ addFieldInfo(syntheticFields[i]);
}
- if (syntheticFields != null) {
- for (int i = 0, max = syntheticFields.length; i < max; i++) {
- addFieldInfo(syntheticFields[i]);
+ }
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods stores the bindings for each inner class. They will be used to know which entries
+ * have to be generated for the inner classes attributes.
+ * @param referenceBinding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
+ */
+public void addInnerClasses(ReferenceBinding referenceBinding) {
+ // check first if that reference binding is there
+ for (int i = 0; i < numberOfInnerClasses; i++) {
+ if (innerClassesBindings[i] == referenceBinding)
+ return;
+ }
+ int length = innerClassesBindings.length;
+ if (numberOfInnerClasses == length) {
+ System.arraycopy(innerClassesBindings, 0, (innerClassesBindings = new ReferenceBinding[length * 2]), 0, length);
+ }
+ innerClassesBindings[numberOfInnerClasses++] = referenceBinding;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem clinit method info that correspond to a boggus method.
+ *
+ * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
+ */
+public void addProblemClinit(IProblem[] problems) {
+ generateMethodInfoHeaderForClinit();
+ // leave two spaces for the number of attributes
+ contentsOffset -= 2;
+ int attributeOffset = contentsOffset;
+ contentsOffset += 2;
+ ReferenceBinding[] thrownsExceptions;
+ int attributeNumber = 0;
+ int contentsLength;
+
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ codeStream.resetForProblemClinit(this);
+ String problemString = ""/*nonNLS*/;
+ if (problems != null) {
+ int max = problems.length;
+ StringBuffer buffer = new StringBuffer(25);
+ int count = 0;
+ for (int i = 0; i < max; i++) {
+ IProblem problem = problems[i];
+ if ((problem != null) && (problem.isError())) {
+ buffer.append("\t"/*nonNLS*/ + problem.getMessage() + "\n"/*nonNLS*/);
+ count++;
+ if (problemLine == 0) {
+ problemLine = problem.getSourceLineNumber();
+ }
+ problems[i] = null;
}
+ } // insert the top line afterwards, once knowing how many problems we have to consider
+ if (count > 1) {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblems"/*nonNLS*/));
+ } else {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblem"/*nonNLS*/));
}
+ problemString = buffer.toString();
}
- /**
- * INTERNAL USE-ONLY
- * This methods stores the bindings for each inner class. They will be used to know which entries
- * have to be generated for the inner classes attributes.
- * @param referenceBinding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
- */
- public void addInnerClasses(ReferenceBinding referenceBinding) {
- // check first if that reference binding is there
- for (int i = 0; i < numberOfInnerClasses; i++) {
- if (innerClassesBindings[i] == referenceBinding)
- return;
- }
- int length = innerClassesBindings.length;
- if (numberOfInnerClasses == length) {
- System.arraycopy(
- innerClassesBindings,
- 0,
- (innerClassesBindings = new ReferenceBinding[length * 2]),
- 0,
- length);
+ // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
+ int[] exceptionHandler = codeStream.generateCodeAttributeForProblemMethod(referenceBinding.scope.problemReporter().options.runtimeExceptionNameForCompileError, problemString);
+ attributeNumber++; // code attribute
+ completeCodeAttributeForClinit(
+ codeAttributeOffset,
+ exceptionHandler,
+ referenceBinding
+ .scope
+ .referenceCompilationUnit()
+ .compilationResult
+ .lineSeparatorPositions);
+ contents[attributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[attributeOffset] = (byte) attributeNumber;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a boggus constructor.
+ *
+ * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
+ * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
+ */
+public void addProblemConstructor(
+ AbstractMethodDeclaration method,
+ MethodBinding methodBinding,
+ IProblem[] problems) {
+
+ // always clear the strictfp/native/abstract bit for a problem method
+ methodBinding.modifiers &= ~(AccStrictfp | AccNative | AccAbstract);
+
+ generateMethodInfoHeader(methodBinding);
+ // We know that we won't get more than 1 attribute: the code attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 1; // Code attribute
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ final ProblemReporter problemReporter = method.scope.problemReporter();
+ codeStream.reset(method, this);
+ String problemString = ""/*nonNLS*/;
+ if (problems != null) {
+ int max = problems.length;
+ StringBuffer buffer = new StringBuffer(25);
+ int count = 0;
+ for (int i = 0; i < max; i++) {
+ IProblem problem = problems[i];
+ if ((problem != null) && (problem.isError())) {
+ buffer.append("\t"/*nonNLS*/ + problem.getMessage() + "\n"/*nonNLS*/);
+ count++;
+ if (problemLine == 0) {
+ problemLine = problem.getSourceLineNumber();
+ }
+ }
+ } // insert the top line afterwards, once knowing how many problems we have to consider
+ if (count > 1) {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblems"/*nonNLS*/));
+ } else {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblem"/*nonNLS*/));
}
- innerClassesBindings[numberOfInnerClasses++] = referenceBinding;
+ problemString = buffer.toString();
+ }
+
+ // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
+ int[] exceptionHandler =
+ codeStream.generateCodeAttributeForProblemMethod(
+ problemReporter.options.runtimeExceptionNameForCompileError,
+ problemString);
+ completeCodeAttributeForProblemMethod(
+ method,
+ methodBinding,
+ codeAttributeOffset,
+ exceptionHandler,
+ ((SourceTypeBinding) methodBinding.declaringClass)
+ .scope
+ .referenceCompilationUnit()
+ .compilationResult
+ .lineSeparatorPositions);
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a boggus constructor.
+ * Reset the position inside the contents byte array to the savedOffset.
+ *
+ * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
+ * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
+ * @param savedOffset <CODE>int</CODE>
+ */
+public void addProblemConstructor(AbstractMethodDeclaration method, MethodBinding methodBinding,IProblem[] problems, int savedOffset) {
+ // we need to move back the contentsOffset to the value at the beginning of the method
+ contentsOffset = savedOffset;
+ methodCount--; // we need to remove the method that causes the problem
+ addProblemConstructor(method, methodBinding, problems);
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a boggus method.
+ *
+ * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
+ * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
+ */
+public void addProblemMethod(
+ AbstractMethodDeclaration method,
+ MethodBinding methodBinding,
+ IProblem[] problems) {
+ if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
+ method.abort(AbstractMethodDeclaration.AbortType);
+ }
+ // always clear the strictfp/native/abstract bit for a problem method
+ methodBinding.modifiers &= ~(AccStrictfp | AccNative | AccAbstract);
+
+ generateMethodInfoHeader(methodBinding);
+ // leave two spaces for the number of attributes
+ int attributeOffset = contentsOffset;
+ contentsOffset += 2;
+ ReferenceBinding[] thrownsExceptions;
+ int attributeNumber = 0;
+ int contentsLength;
+
+ if ((thrownsExceptions = methodBinding.thrownExceptions) != NoExceptions) {
+ // The method has a throw clause. So we need to add an exception attribute
+ // check that there is enough space to write all the bytes for the exception attribute
+ int length = thrownsExceptions.length;
+ if (contentsOffset + (8 + length * 2) >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + Math.max(INCREMENT_SIZE, (8 + length * 2))]), 0, contentsLength);
+ }
+ int exceptionNameIndex = constantPool.literalIndex(AttributeNamesConstants.ExceptionsName);
+ contents[contentsOffset++] = (byte) (exceptionNameIndex >> 8);
+ contents[contentsOffset++] = (byte) exceptionNameIndex;
+ // The attribute length = length * 2 + 2 in case of a exception attribute
+ int attributeLength = length * 2 + 2;
+ contents[contentsOffset++] = (byte) (attributeLength >> 24);
+ contents[contentsOffset++] = (byte) (attributeLength >> 16);
+ contents[contentsOffset++] = (byte) (attributeLength >> 8);
+ contents[contentsOffset++] = (byte) attributeLength;
+ contents[contentsOffset++] = (byte) (length >> 8);
+ contents[contentsOffset++] = (byte) length;
+ for (int i = 0; i < length; i++) {
+ int exceptionIndex = constantPool.literalIndex(thrownsExceptions[i]);
+ contents[contentsOffset++] = (byte) (exceptionIndex >> 8);
+ contents[contentsOffset++] = (byte) exceptionIndex;
+ }
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem clinit method info that correspond to a boggus method.
- *
- * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
- */
- public void addProblemClinit(IProblem[] problems) {
- generateMethodInfoHeaderForClinit();
- // leave two spaces for the number of attributes
- contentsOffset -= 2;
- int attributeOffset = contentsOffset;
- contentsOffset += 2;
- ReferenceBinding[] thrownsExceptions;
- int attributeNumber = 0;
- int contentsLength;
+ // Deprecated attribute
+ // Check that there is enough space to write the deprecated attribute
+ if (contentsOffset + 6 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ if (methodBinding.isDeprecated()) {
+ int deprecatedAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
+ contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
+ // the length of a deprecated attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- codeStream.resetForProblemClinit(this);
- String problemString = "" ; //$NON-NLS-1$
- if (problems != null) {
- int max = problems.length;
- StringBuffer buffer = new StringBuffer(25);
- int count = 0;
- for (int i = 0; i < max; i++) {
- IProblem problem = problems[i];
- if ((problem != null) && (problem.isError())) {
- buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- count++;
- if (problemLine == 0) {
- problemLine = problem.getSourceLineNumber();
- }
- problems[i] = null;
+ attributeNumber++;
+ }
+
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ final ProblemReporter problemReporter = method.scope.problemReporter();
+ codeStream.reset(method, this);
+ String problemString = ""/*nonNLS*/;
+ if (problems != null) {
+ int max = problems.length;
+ StringBuffer buffer = new StringBuffer(25);
+ int count = 0;
+ for (int i = 0; i < max; i++) {
+ IProblem problem = problems[i];
+ if ((problem != null)
+ && (problem.isError())
+ && (problem.getSourceStart() >= method.declarationSourceStart)
+ && (problem.getSourceEnd() <= method.declarationSourceEnd)) {
+ buffer.append("\t"/*nonNLS*/ + problem.getMessage() + "\n"/*nonNLS*/);
+ count++;
+ if (problemLine == 0) {
+ problemLine = problem.getSourceLineNumber();
}
- } // insert the top line afterwards, once knowing how many problems we have to consider
- if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
- } else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
+ problems[i] = null;
}
- problemString = buffer.toString();
+ } // insert the top line afterwards, once knowing how many problems we have to consider
+ if (count > 1) {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblems"/*nonNLS*/));
+ } else {
+ buffer.insert(0, Util.bind("compilation.unresolvedProblem"/*nonNLS*/));
}
-
- // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
- int[] exceptionHandler =
- codeStream.generateCodeAttributeForProblemMethod(
- referenceBinding
- .scope
- .problemReporter()
- .options
- .runtimeExceptionNameForCompileError,
- problemString);
- attributeNumber++; // code attribute
- completeCodeAttributeForClinit(
- codeAttributeOffset,
- exceptionHandler,
- referenceBinding
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- contents[attributeOffset++] = (byte) (attributeNumber >> 8);
- contents[attributeOffset] = (byte) attributeNumber;
+ problemString = buffer.toString();
}
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a boggus constructor.
- *
- * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
- * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
- */
- public void addProblemConstructor(
- AbstractMethodDeclaration method,
- MethodBinding methodBinding,
- IProblem[] problems) {
-
- // always clear the strictfp/native/abstract bit for a problem method
- methodBinding.modifiers &= ~(AccStrictfp | AccNative | AccAbstract);
+ // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
+ int[] exceptionHandler =
+ codeStream.generateCodeAttributeForProblemMethod(
+ problemReporter.options.runtimeExceptionNameForCompileError,
+ problemString);
+ attributeNumber++; // code attribute
+ completeCodeAttributeForProblemMethod(
+ method,
+ methodBinding,
+ codeAttributeOffset,
+ exceptionHandler,
+ ((SourceTypeBinding) methodBinding.declaringClass)
+ .scope
+ .referenceCompilationUnit()
+ .compilationResult
+ .lineSeparatorPositions);
+ contents[attributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[attributeOffset] = (byte) attributeNumber;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a boggus method.
+ * Reset the position inside the contents byte array to the savedOffset.
+ *
+ * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
+ * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
+ * @param savedOffset <CODE>int</CODE>
+ */
+public void addProblemMethod(AbstractMethodDeclaration method, MethodBinding methodBinding,IProblem[] problems, int savedOffset) {
+ // we need to move back the contentsOffset to the value at the beginning of the method
+ contentsOffset = savedOffset;
+ methodCount--; // we need to remove the method that causes the problem
+ addProblemMethod(method, methodBinding, problems);
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for all the special method infos.
+ * They are:
+ * - synthetic access methods
+ * - default abstract methods
+ */
+public void addSpecialMethods() {
+ // add all methods (default abstract methods and synthetic)
+
+ // default abstract methods
+ SourceTypeBinding currentBinding = referenceBinding;
+ MethodBinding[] defaultAbstractMethods = currentBinding.getDefaultAbstractMethods();
+ for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
+ generateMethodInfoHeader(defaultAbstractMethods[i]);
+ int methodAttributeOffset = contentsOffset;
+ int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
+ completeMethodInfo(methodAttributeOffset, attributeNumber);
+ }
- generateMethodInfoHeader(methodBinding);
- // We know that we won't get more than 1 attribute: the code attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 1; // Code attribute
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- final ProblemReporter problemReporter = method.scope.problemReporter();
- codeStream.reset(method, this);
- String problemString = "" ; //$NON-NLS-1$
- if (problems != null) {
- int max = problems.length;
- StringBuffer buffer = new StringBuffer(25);
- int count = 0;
- for (int i = 0; i < max; i++) {
- IProblem problem = problems[i];
- if ((problem != null) && (problem.isError())) {
- buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- count++;
- if (problemLine == 0) {
- problemLine = problem.getSourceLineNumber();
- }
- }
- } // insert the top line afterwards, once knowing how many problems we have to consider
- if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
- } else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
+ // add synthetic methods infos
+ SyntheticAccessMethodBinding[] syntheticAccessMethods = currentBinding.syntheticAccessMethods();
+ if (syntheticAccessMethods != null) {
+ for (int i = 0, max = syntheticAccessMethods.length; i < max; i++) {
+ SyntheticAccessMethodBinding accessMethodBinding = syntheticAccessMethods[i];
+ switch (accessMethodBinding.accessType) {
+ case SyntheticAccessMethodBinding.FieldReadAccess :
+ // generate a method info to emulate an reading access to
+ // a private field
+ addSyntheticFieldReadAccessMethod(syntheticAccessMethods[i]);
+ break;
+ case SyntheticAccessMethodBinding.FieldWriteAccess :
+ // generate a method info to emulate an writing access to
+ // a private field
+ addSyntheticFieldWriteAccessMethod(syntheticAccessMethods[i]);
+ break;
+ case SyntheticAccessMethodBinding.MethodAccess :
+ // generate a method info to emulate an access to a private method
+ addSyntheticMethodAccessMethod(syntheticAccessMethods[i]);
+ break;
+ case SyntheticAccessMethodBinding.ConstructorAccess :
+ // generate a method info to emulate an access to a private method
+ addSyntheticConstructorAccessMethod(syntheticAccessMethods[i]);
}
- problemString = buffer.toString();
}
-
- // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
- int[] exceptionHandler =
- codeStream.generateCodeAttributeForProblemMethod(
- problemReporter.options.runtimeExceptionNameForCompileError,
- problemString);
- completeCodeAttributeForProblemMethod(
- method,
- methodBinding,
- codeAttributeOffset,
- exceptionHandler,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a boggus constructor.
- * Reset the position inside the contents byte array to the savedOffset.
- *
- * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
- * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
- * @param savedOffset <CODE>int</CODE>
- */
- public void addProblemConstructor(
- AbstractMethodDeclaration method,
- MethodBinding methodBinding,
- IProblem[] problems,
- int savedOffset) {
- // we need to move back the contentsOffset to the value at the beginning of the method
- contentsOffset = savedOffset;
- methodCount--; // we need to remove the method that causes the problem
- addProblemConstructor(method, methodBinding, problems);
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a synthetic method that
+ * generate an access to a private constructor.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
+ */
+public void addSyntheticConstructorAccessMethod(SyntheticAccessMethodBinding methodBinding) {
+ generateMethodInfoHeader(methodBinding);
+ // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ // Code attribute
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ codeStream.init(this);
+ codeStream.generateSyntheticBodyForConstructorAccess(methodBinding);
+ completeCodeAttributeForSyntheticAccessMethod(methodBinding, codeAttributeOffset, ((SourceTypeBinding) methodBinding.declaringClass).scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions);
+ // add the synthetic attribute
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a synthetic method that
+ * generate an read access to a private field.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
+ */
+public void addSyntheticFieldReadAccessMethod(SyntheticAccessMethodBinding methodBinding) {
+ generateMethodInfoHeader(methodBinding);
+ // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ // Code attribute
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ codeStream.init(this);
+ codeStream.generateSyntheticBodyForFieldReadAccess(methodBinding);
+ completeCodeAttributeForSyntheticAccessMethod(methodBinding, codeAttributeOffset, ((SourceTypeBinding) methodBinding.declaringClass).scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions);
+ // add the synthetic attribute
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a synthetic method that
+ * generate an write access to a private field.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
+ */
+public void addSyntheticFieldWriteAccessMethod(SyntheticAccessMethodBinding methodBinding) {
+ generateMethodInfoHeader(methodBinding);
+ // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ // Code attribute
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ codeStream.init(this);
+ codeStream.generateSyntheticBodyForFieldWriteAccess(methodBinding);
+ completeCodeAttributeForSyntheticAccessMethod(methodBinding, codeAttributeOffset, ((SourceTypeBinding) methodBinding.declaringClass).scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions);
+ // add the synthetic attribute
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Generate the byte for a problem method info that correspond to a synthetic method that
+ * generate an access to a private method.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
+ */
+public void addSyntheticMethodAccessMethod(SyntheticAccessMethodBinding methodBinding) {
+ generateMethodInfoHeader(methodBinding);
+ // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 2;
+ // Code attribute
+ int codeAttributeOffset = contentsOffset;
+ generateCodeAttributeHeader();
+ codeStream.init(this);
+ codeStream.generateSyntheticBodyForMethodAccess(methodBinding);
+ completeCodeAttributeForSyntheticAccessMethod(methodBinding, codeAttributeOffset, ((SourceTypeBinding) methodBinding.declaringClass).scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions);
+ // add the synthetic attribute
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Build all the directories and subdirectories corresponding to the packages names
+ * into the directory specified in parameters.
+ *
+ * outputPath is formed like:
+ * c:\temp\ the last character is a file separator
+ * relativeFileName is formed like:
+ * java\lang\String.class *
+ *
+ * @param outputPath java.lang.String
+ * @param relativeFileName java.lang.String
+ * @return java.lang.String
+ */
+public static String buildAllDirectoriesInto(String outputPath, String relativeFileName) throws IOException {
+ char fileSeparatorChar = File.separatorChar;
+ String fileSeparator = File.separator;
+ File f;
+ // First we ensure that the outputPath exists
+ outputPath = outputPath.replace('/', fileSeparatorChar);
+ // To be able to pass the mkdirs() method we need to remove the extra file separator at the end of the outDir name
+ if (outputPath.endsWith(fileSeparator)) {
+ outputPath = outputPath.substring(0, outputPath.length() - 1);
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a boggus method.
- *
- * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
- * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
- */
- public void addProblemMethod(
- AbstractMethodDeclaration method,
- MethodBinding methodBinding,
- IProblem[] problems) {
- if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
- method.abort(AbstractMethodDeclaration.AbortType);
+ f = new File(outputPath);
+ if (f.exists()) {
+ if (!f.isDirectory()) {
+ System.out.println(Util.bind("output.isFile"/*nonNLS*/,f.getAbsolutePath()));
+ throw new IOException(Util.bind("output.isFileNotDirectory"/*nonNLS*/));
+ }
+ } else {
+ // we have to create that directory
+ if (!f.mkdirs()) {
+ System.out.println(Util.bind("output.dirName"/*nonNLS*/,f.getAbsolutePath()));
+ throw new IOException(Util.bind("output.notValidAll"/*nonNLS*/));
}
- // always clear the strictfp/native/abstract bit for a problem method
- methodBinding.modifiers &= ~(AccStrictfp | AccNative | AccAbstract);
-
- generateMethodInfoHeader(methodBinding);
- // leave two spaces for the number of attributes
- int attributeOffset = contentsOffset;
- contentsOffset += 2;
- ReferenceBinding[] thrownsExceptions;
- int attributeNumber = 0;
- int contentsLength;
-
- if ((thrownsExceptions = methodBinding.thrownExceptions) != NoExceptions) {
- // The method has a throw clause. So we need to add an exception attribute
- // check that there is enough space to write all the bytes for the exception attribute
- int length = thrownsExceptions.length;
- if (contentsOffset + (8 + length * 2) >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents =
- new byte[contentsLength + Math.max(INCREMENT_SIZE, (8 + length * 2))]),
- 0,
- contentsLength);
+ }
+ StringBuffer outDir = new StringBuffer(outputPath);
+ outDir.append(fileSeparator);
+ StringTokenizer tokenizer = new StringTokenizer(relativeFileName, fileSeparator);
+ String token = tokenizer.nextToken();
+ while (tokenizer.hasMoreTokens()) {
+ f = new File(outDir.append(token).append(fileSeparator).toString());
+ if (f.exists()) {
+ // The outDir already exists, so we proceed the next entry
+ // System.out.println("outDir: " + outDir + " already exists.");
+ } else {
+ // Need to add the outDir
+ if (!f.mkdir()) {
+ System.out.println(Util.bind("output.fileName"/*nonNLS*/,f.getName()));
+ throw new IOException(Util.bind("output.notValid"/*nonNLS*/));
}
- int exceptionNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.ExceptionsName);
- contents[contentsOffset++] = (byte) (exceptionNameIndex >> 8);
- contents[contentsOffset++] = (byte) exceptionNameIndex;
- // The attribute length = length * 2 + 2 in case of a exception attribute
- int attributeLength = length * 2 + 2;
- contents[contentsOffset++] = (byte) (attributeLength >> 24);
- contents[contentsOffset++] = (byte) (attributeLength >> 16);
- contents[contentsOffset++] = (byte) (attributeLength >> 8);
- contents[contentsOffset++] = (byte) attributeLength;
- contents[contentsOffset++] = (byte) (length >> 8);
- contents[contentsOffset++] = (byte) length;
- for (int i = 0; i < length; i++) {
- int exceptionIndex = constantPool.literalIndex(thrownsExceptions[i]);
- contents[contentsOffset++] = (byte) (exceptionIndex >> 8);
- contents[contentsOffset++] = (byte) exceptionIndex;
+ }
+ token = tokenizer.nextToken();
+ }
+ // token contains the last one
+ return outDir.append(token).toString();
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method completes the creation of the code attribute by setting
+ * - the attribute_length
+ * - max_stack
+ * - max_locals
+ * - code_length
+ * - exception table
+ * - and debug attributes if necessary.
+ *
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param codeAttributeOffset <CODE>int</CODE>
+ */
+public void completeCodeAttribute(int codeAttributeOffset) {
+ // reinitialize the localContents with the byte modified by the code stream
+ byte[] localContents = contents = codeStream.bCodeStream;
+ int localContentsOffset = codeStream.classFileOffset;
+ // codeAttributeOffset is the position inside localContents byte array before we started to write
+ // any information about the codeAttribute
+ // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
+ // to get the right position, 6 for the max_stack etc...
+ int contentsLength;
+ int code_length = codeStream.position;
+ if (code_length > 65535) {
+ codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(codeStream.methodDeclaration);
+ }
+ if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ int max_stack = codeStream.stackMax;
+ localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
+ localContents[codeAttributeOffset + 7] = (byte) max_stack;
+ int max_locals = codeStream.maxLocals;
+ localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
+ localContents[codeAttributeOffset + 9] = (byte) max_locals;
+ localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
+ localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
+ localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
+ localContents[codeAttributeOffset + 13] = (byte) code_length;
+
+ // write the exception table
+ int exceptionHandlersNumber = codeStream.exceptionHandlersNumber;
+ ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
+ int exSize;
+ if (localContentsOffset + (exSize = (exceptionHandlersNumber * 8 + 2)) >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + (exSize > INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]), 0, contentsLength);
+ }
+ // there is no exception table, so we need to offset by 2 the current offset and move
+ // on the attribute generation
+ localContents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
+ localContents[localContentsOffset++] = (byte) exceptionHandlersNumber;
+ for (int i = 0; i < exceptionHandlersNumber; i++) {
+ ExceptionLabel exceptionHandler = exceptionHandlers[i];
+ int start = exceptionHandler.start;
+ localContents[localContentsOffset++] = (byte) (start >> 8);
+ localContents[localContentsOffset++] = (byte) start;
+ int end = exceptionHandler.end;
+ localContents[localContentsOffset++] = (byte) (end >> 8);
+ localContents[localContentsOffset++] = (byte) end;
+ int handlerPC = exceptionHandler.position;
+ localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
+ localContents[localContentsOffset++] = (byte) handlerPC;
+ if (exceptionHandler.exceptionType == null) {
+ // any exception handler
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ } else {
+ int nameIndex;
+ if (exceptionHandler.exceptionType == TypeBinding.NullBinding) {
+ /* represents ClassNotFoundException, see class literal access*/
+ nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
+ } else {
+ nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
}
- attributeNumber++;
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
}
+ }
- // Deprecated attribute
- // Check that there is enough space to write the deprecated attribute
- if (contentsOffset + 6 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- if (methodBinding.isDeprecated()) {
- int deprecatedAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
- contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
- // the length of a deprecated attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
+ // debug attributes
+ int codeAttributeAttributeOffset = localContentsOffset;
+ int attributeNumber = 0;
+ // leave two bytes for the attribute_length
+ localContentsOffset += 2;
+
+ // first we handle the linenumber attribute
+ if (codeStream.generateLineNumberAttributes) {
+ /* Create and add the line number attribute (used for debugging)
+ * Build the pairs of:
+ * (bytecodePC lineNumber)
+ * according to the table of start line indexes and the pcToSourceMap table
+ * contained into the codestream
+ */
+ /** OLD CODE
+ int[][] pcToSourceMapTable;
+ int previousLineNumber;
+ int[] flatTable;
+ int index;
+ int startLineIndexes[] = codeStream.methodDeclaration.scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions;
+ int max = startLineIndexes.length;
+ */
+ int[] pcToSourceMapTable;
+ if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null) && (codeStream.pcToSourceMapSize != 0)) {
+ int lineNumberNameIndex = constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
+ if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
+ int lineNumberTableOffset = localContentsOffset;
+ localContentsOffset += 6; // leave space for attribute_length and line_number_table_length
+ /** OLD CODE
+ previousLineNumber = 0;
- attributeNumber++;
- }
+ // Seems like do would be better, but this preserves the existing behavior.
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- final ProblemReporter problemReporter = method.scope.problemReporter();
- codeStream.reset(method, this);
- String problemString = "" ; //$NON-NLS-1$
- if (problems != null) {
- int max = problems.length;
- StringBuffer buffer = new StringBuffer(25);
- int count = 0;
- for (int i = 0; i < max; i++) {
- IProblem problem = problems[i];
- if ((problem != null)
- && (problem.isError())
- && (problem.getSourceStart() >= method.declarationSourceStart)
- && (problem.getSourceEnd() <= method.declarationSourceEnd)) {
- buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- count++;
- if (problemLine == 0) {
- problemLine = problem.getSourceLineNumber();
+ flatTable = new int[code_length];
+ for (int i = codeStream.pcToSourceMapSize - 1; i >= 0; i--) {
+ // entry contains the following structure:
+ // position 1: startPC
+ // position 2: endPC
+ // position 3: sourceStart
+ // position 4: sourceEnd
+ // Compute the line number for a given source position
+ index = searchLineNumber(startLineIndexes, pcToSourceMapTable[i][2]);
+ for (int j = pcToSourceMapTable[i][0]; j < pcToSourceMapTable[i][1]; j++)
+ flatTable[j] = index;
+ }
+ previousLineNumber = -1;
+
+ */
+ int numberOfEntries = 0;
+ int length = codeStream.pcToSourceMapSize;
+ /** OLD CODE
+ int length = flatTable.length;
+ for (int i = 0; i < length; i++) {
+ if (flatTable[i] != previousLineNumber) {
+ previousLineNumber = flatTable[i];
+ // write the entry
+ if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
- problems[i] = null;
+ localContents[localContentsOffset++] = (byte) (i >> 8);
+ localContents[localContentsOffset++] = (byte) i;
+ localContents[localContentsOffset++] = (byte) (previousLineNumber >> 8);
+ localContents[localContentsOffset++] = (byte) previousLineNumber;
+ numberOfEntries++;
}
- } // insert the top line afterwards, once knowing how many problems we have to consider
- if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
- } else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
}
- problemString = buffer.toString();
+ */
+ for (int i = 0; i < length;) {
+ // write the entry
+ if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ int pc = pcToSourceMapTable[i++];
+ localContents[localContentsOffset++] = (byte) (pc >> 8);
+ localContents[localContentsOffset++] = (byte) pc;
+ int lineNumber = pcToSourceMapTable[i++];
+ localContents[localContentsOffset++] = (byte) (lineNumber >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumber;
+ numberOfEntries++;
+ }
+ // now we change the size of the line number attribute
+ int lineNumberAttr_length = numberOfEntries * 4 + 2;
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
+ localContents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
+ localContents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
+ localContents[lineNumberTableOffset++] = (byte) numberOfEntries;
+ attributeNumber++;
}
-
- // return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
- int[] exceptionHandler =
- codeStream.generateCodeAttributeForProblemMethod(
- problemReporter.options.runtimeExceptionNameForCompileError,
- problemString);
- attributeNumber++; // code attribute
- completeCodeAttributeForProblemMethod(
- method,
- methodBinding,
- codeAttributeOffset,
- exceptionHandler,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- contents[attributeOffset++] = (byte) (attributeNumber >> 8);
- contents[attributeOffset] = (byte) attributeNumber;
}
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a boggus method.
- * Reset the position inside the contents byte array to the savedOffset.
- *
- * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
- * @param problem org.eclipse.jdt.internal.compiler.problem.Problem[]
- * @param savedOffset <CODE>int</CODE>
- */
- public void addProblemMethod(
- AbstractMethodDeclaration method,
- MethodBinding methodBinding,
- IProblem[] problems,
- int savedOffset) {
- // we need to move back the contentsOffset to the value at the beginning of the method
- contentsOffset = savedOffset;
- methodCount--; // we need to remove the method that causes the problem
- addProblemMethod(method, methodBinding, problems);
- }
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for all the special method infos.
- * They are:
- * - synthetic access methods
- * - default abstract methods
- */
- public void addSpecialMethods() {
- // add all methods (default abstract methods and synthetic)
- // default abstract methods
- SourceTypeBinding currentBinding = referenceBinding;
- MethodBinding[] defaultAbstractMethods =
- currentBinding.getDefaultAbstractMethods();
- for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
- generateMethodInfoHeader(defaultAbstractMethods[i]);
- int methodAttributeOffset = contentsOffset;
- int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
- completeMethodInfo(methodAttributeOffset, attributeNumber);
- }
- // add synthetic methods infos
- SyntheticAccessMethodBinding[] syntheticAccessMethods =
- currentBinding.syntheticAccessMethods();
- if (syntheticAccessMethods != null) {
- for (int i = 0, max = syntheticAccessMethods.length; i < max; i++) {
- SyntheticAccessMethodBinding accessMethodBinding = syntheticAccessMethods[i];
- switch (accessMethodBinding.accessType) {
- case SyntheticAccessMethodBinding.FieldReadAccess :
- // generate a method info to emulate an reading access to
- // a private field
- addSyntheticFieldReadAccessMethod(syntheticAccessMethods[i]);
- break;
- case SyntheticAccessMethodBinding.FieldWriteAccess :
- // generate a method info to emulate an writing access to
- // a private field
- addSyntheticFieldWriteAccessMethod(syntheticAccessMethods[i]);
- break;
- case SyntheticAccessMethodBinding.MethodAccess :
- // generate a method info to emulate an access to a private method
- addSyntheticMethodAccessMethod(syntheticAccessMethods[i]);
- break;
- case SyntheticAccessMethodBinding.ConstructorAccess :
- // generate a method info to emulate an access to a private method
- addSyntheticConstructorAccessMethod(syntheticAccessMethods[i]);
+ // then we do the local variable attribute
+ if (codeStream.generateLocalVariableTableAttributes) {
+ int localVariableTableOffset = localContentsOffset;
+ int numberOfEntries = 0;
+ int localVariableNameIndex = constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
+ if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) localVariableNameIndex;
+ localContentsOffset += 6; // leave space for attribute_length and local_variable_table_length
+ int nameIndex;
+ int descriptorIndex;
+ if (!codeStream.methodDeclaration.isStatic()) {
+ numberOfEntries++;
+ if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContentsOffset += 2; // the startPC for this is always 0
+ localContents[localContentsOffset++] = (byte) (code_length >> 8);
+ localContents[localContentsOffset++] = (byte) code_length;
+ nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
+ descriptorIndex = constantPool.literalIndex(codeStream.methodDeclaration.binding.declaringClass.signature());
+ localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
+ localContents[localContentsOffset++] = (byte) descriptorIndex;
+ localContentsOffset += 2; // the resolved position for this is always 0
+ }
+ for (int i = 0; i < codeStream.allLocalsCounter; i++) {
+ LocalVariableBinding localVariable = codeStream.locals[i];
+ for (int j = 0; j < localVariable.initializationCount; j++) {
+ int startPC = localVariable.initializationPCs[j << 1];
+ int endPC = localVariable.initializationPCs[(j << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ int currentLength;
+ if (endPC == -1) {
+ localVariable.declaringScope.problemReporter().abortDueToInternalError(Util.bind("abort.invalidAttribute"/*nonNLS*/,new String(localVariable.name)), (AstNode) localVariable.declaringScope.methodScope().referenceContext);
+ }
+ if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ // now we can safely add the local entry
+ numberOfEntries++;
+ localContents[localContentsOffset++] = (byte) (startPC >> 8);
+ localContents[localContentsOffset++] = (byte) startPC;
+ int length = endPC - startPC;
+ localContents[localContentsOffset++] = (byte) (length >> 8);
+ localContents[localContentsOffset++] = (byte) length;
+ nameIndex = constantPool.literalIndex(localVariable.name);
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
+ descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
+ localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
+ localContents[localContentsOffset++] = (byte) descriptorIndex;
+ int resolvedPosition = localVariable.resolvedPosition;
+ localContents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
+ localContents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
+ int value = numberOfEntries * 10 + 2;
+ localVariableTableOffset += 2;
+ localContents[localVariableTableOffset++] = (byte) (value >> 24);
+ localContents[localVariableTableOffset++] = (byte) (value >> 16);
+ localContents[localVariableTableOffset++] = (byte) (value >> 8);
+ localContents[localVariableTableOffset++] = (byte) value;
+ localContents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
+ localContents[localVariableTableOffset] = (byte) numberOfEntries;
+ attributeNumber++;
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a synthetic method that
- * generate an access to a private constructor.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
- */
- public void addSyntheticConstructorAccessMethod(SyntheticAccessMethodBinding methodBinding) {
- generateMethodInfoHeader(methodBinding);
- // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- // Code attribute
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- codeStream.init(this);
- codeStream.generateSyntheticBodyForConstructorAccess(methodBinding);
- completeCodeAttributeForSyntheticAccessMethod(
- methodBinding,
- codeAttributeOffset,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- // add the synthetic attribute
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
+ // update the number of attributes
+ // ensure first that there is enough space available inside the localContents array
+ if (codeAttributeAttributeOffset + 2 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a synthetic method that
- * generate an read access to a private field.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
- */
- public void addSyntheticFieldReadAccessMethod(SyntheticAccessMethodBinding methodBinding) {
- generateMethodInfoHeader(methodBinding);
- // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- // Code attribute
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- codeStream.init(this);
- codeStream.generateSyntheticBodyForFieldReadAccess(methodBinding);
- completeCodeAttributeForSyntheticAccessMethod(
- methodBinding,
- codeAttributeOffset,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- // add the synthetic attribute
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
+ localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
+ localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
+
+ // update the attribute length
+ int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
+ localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
+ localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
+ localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
+ localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
+ contentsOffset = localContentsOffset;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method completes the creation of the code attribute by setting
+ * - the attribute_length
+ * - max_stack
+ * - max_locals
+ * - code_length
+ * - exception table
+ * - and debug attributes if necessary.
+ *
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param codeAttributeOffset <CODE>int</CODE>
+ */
+public void completeCodeAttributeForClinit(int codeAttributeOffset) {
+ // reinitialize the contents with the byte modified by the code stream
+ byte[] localContents = contents = codeStream.bCodeStream;
+ int localContentsOffset = codeStream.classFileOffset;
+ // codeAttributeOffset is the position inside contents byte array before we started to write
+ // any information about the codeAttribute
+ // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
+ // to get the right position, 6 for the max_stack etc...
+ int contentsLength;
+ int code_length = codeStream.position;
+ if (code_length > 65535) {
+ codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(codeStream.methodDeclaration.scope.referenceType());
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a synthetic method that
- * generate an write access to a private field.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
- */
- public void addSyntheticFieldWriteAccessMethod(SyntheticAccessMethodBinding methodBinding) {
- generateMethodInfoHeader(methodBinding);
- // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- // Code attribute
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- codeStream.init(this);
- codeStream.generateSyntheticBodyForFieldWriteAccess(methodBinding);
- completeCodeAttributeForSyntheticAccessMethod(
- methodBinding,
- codeAttributeOffset,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- // add the synthetic attribute
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
+ if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * Generate the byte for a problem method info that correspond to a synthetic method that
- * generate an access to a private method.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
- */
- public void addSyntheticMethodAccessMethod(SyntheticAccessMethodBinding methodBinding) {
- generateMethodInfoHeader(methodBinding);
- // We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 2;
- // Code attribute
- int codeAttributeOffset = contentsOffset;
- generateCodeAttributeHeader();
- codeStream.init(this);
- codeStream.generateSyntheticBodyForMethodAccess(methodBinding);
- completeCodeAttributeForSyntheticAccessMethod(
- methodBinding,
- codeAttributeOffset,
- ((SourceTypeBinding) methodBinding.declaringClass)
- .scope
- .referenceCompilationUnit()
- .compilationResult
- .lineSeparatorPositions);
- // add the synthetic attribute
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
+ int max_stack = codeStream.stackMax;
+ localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
+ localContents[codeAttributeOffset + 7] = (byte) max_stack;
+ int max_locals = codeStream.maxLocals;
+ localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
+ localContents[codeAttributeOffset + 9] = (byte) max_locals;
+ localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
+ localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
+ localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
+ localContents[codeAttributeOffset + 13] = (byte) code_length;
+
+ // write the exception table
+ int exceptionHandlersNumber = codeStream.exceptionHandlersNumber;
+ ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
+ int exSize;
+ if (localContentsOffset + (exSize = (exceptionHandlersNumber * 8 + 2)) >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + (exSize > INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * Build all the directories and subdirectories corresponding to the packages names
- * into the directory specified in parameters.
- *
- * outputPath is formed like:
- * c:\temp\ the last character is a file separator
- * relativeFileName is formed like:
- * java\lang\String.class *
- *
- * @param outputPath java.lang.String
- * @param relativeFileName java.lang.String
- * @return java.lang.String
- */
- public static String buildAllDirectoriesInto(
- String outputPath,
- String relativeFileName)
- throws IOException {
- char fileSeparatorChar = File.separatorChar;
- String fileSeparator = File.separator;
- File f;
- // First we ensure that the outputPath exists
- outputPath = outputPath.replace('/', fileSeparatorChar);
- // To be able to pass the mkdirs() method we need to remove the extra file separator at the end of the outDir name
- if (outputPath.endsWith(fileSeparator)) {
- outputPath = outputPath.substring(0, outputPath.length() - 1);
- }
- f = new File(outputPath);
- if (f.exists()) {
- if (!f.isDirectory()) {
- System.out.println(Util.bind("output.isFile" , f.getAbsolutePath())); //$NON-NLS-1$
- throw new IOException(Util.bind("output.isFileNotDirectory" )); //$NON-NLS-1$
- }
+ // there is no exception table, so we need to offset by 2 the current offset and move
+ // on the attribute generation
+ localContents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
+ localContents[localContentsOffset++] = (byte) exceptionHandlersNumber;
+ for (int i = 0; i < exceptionHandlersNumber; i++) {
+ ExceptionLabel exceptionHandler = exceptionHandlers[i];
+ int start = exceptionHandler.start;
+ localContents[localContentsOffset++] = (byte) (start >> 8);
+ localContents[localContentsOffset++] = (byte) start;
+ int end = exceptionHandler.end;
+ localContents[localContentsOffset++] = (byte) (end >> 8);
+ localContents[localContentsOffset++] = (byte) end;
+ int handlerPC = exceptionHandler.position;
+ localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
+ localContents[localContentsOffset++] = (byte) handlerPC;
+ if (exceptionHandler.exceptionType == null) {
+ // any exception handler
+ localContentsOffset += 2;
} else {
- // we have to create that directory
- if (!f.mkdirs()) {
- System.out.println(Util.bind("output.dirName" , f.getAbsolutePath())); //$NON-NLS-1$
- throw new IOException(Util.bind("output.notValidAll" )); //$NON-NLS-1$
- }
- }
- StringBuffer outDir = new StringBuffer(outputPath);
- outDir.append(fileSeparator);
- StringTokenizer tokenizer =
- new StringTokenizer(relativeFileName, fileSeparator);
- String token = tokenizer.nextToken();
- while (tokenizer.hasMoreTokens()) {
- f = new File(outDir.append(token).append(fileSeparator).toString());
- if (f.exists()) {
- // The outDir already exists, so we proceed the next entry
- // System.out.println("outDir: " + outDir + " already exists.");
+ int nameIndex;
+ if (exceptionHandler.exceptionType == TypeBinding.NullBinding) {
+ /* represents denote ClassNotFoundException, see class literal access*/
+ nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
} else {
- // Need to add the outDir
- if (!f.mkdir()) {
- System.out.println(Util.bind("output.fileName" , f.getName())); //$NON-NLS-1$
- throw new IOException(Util.bind("output.notValid" )); //$NON-NLS-1$
- }
+ nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
}
- token = tokenizer.nextToken();
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
}
- // token contains the last one
- return outDir.append(token).toString();
}
- /**
- * INTERNAL USE-ONLY
- * That method completes the creation of the code attribute by setting
- * - the attribute_length
- * - max_stack
- * - max_locals
- * - code_length
- * - exception table
- * - and debug attributes if necessary.
- *
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param codeAttributeOffset <CODE>int</CODE>
- */
- public void completeCodeAttribute(int codeAttributeOffset) {
- // reinitialize the localContents with the byte modified by the code stream
- byte[] localContents = contents = codeStream.bCodeStream;
- int localContentsOffset = codeStream.classFileOffset;
- // codeAttributeOffset is the position inside localContents byte array before we started to write
- // any information about the codeAttribute
- // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
- // to get the right position, 6 for the max_stack etc...
- int contentsLength;
- int code_length = codeStream.position;
- if (code_length > 65535) {
- codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
- codeStream.methodDeclaration);
- }
- if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int max_stack = codeStream.stackMax;
- localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
- localContents[codeAttributeOffset + 7] = (byte) max_stack;
- int max_locals = codeStream.maxLocals;
- localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
- localContents[codeAttributeOffset + 9] = (byte) max_locals;
- localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
- localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
- localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
- localContents[codeAttributeOffset + 13] = (byte) code_length;
-
- // write the exception table
- int exceptionHandlersNumber = codeStream.exceptionHandlersNumber;
- ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
- int exSize;
- if (localContentsOffset + (exSize = (exceptionHandlersNumber * 8 + 2))
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents =
- contents =
- new byte[contentsLength + (exSize > INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]),
- 0,
- contentsLength);
- }
- // there is no exception table, so we need to offset by 2 the current offset and move
- // on the attribute generation
- localContents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
- localContents[localContentsOffset++] = (byte) exceptionHandlersNumber;
- for (int i = 0; i < exceptionHandlersNumber; i++) {
- ExceptionLabel exceptionHandler = exceptionHandlers[i];
- int start = exceptionHandler.start;
- localContents[localContentsOffset++] = (byte) (start >> 8);
- localContents[localContentsOffset++] = (byte) start;
- int end = exceptionHandler.end;
- localContents[localContentsOffset++] = (byte) (end >> 8);
- localContents[localContentsOffset++] = (byte) end;
- int handlerPC = exceptionHandler.position;
- localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
- localContents[localContentsOffset++] = (byte) handlerPC;
- if (exceptionHandler.exceptionType == null) {
- // any exception handler
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- } else {
- int nameIndex;
- if (exceptionHandler.exceptionType == TypeBinding.NullBinding) {
- /* represents ClassNotFoundException, see class literal access*/
- nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
- } else {
- nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
- }
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
+ // debug attributes
+ int codeAttributeAttributeOffset = localContentsOffset;
+ int attributeNumber = 0;
+ // leave two bytes for the attribute_length
+ localContentsOffset += 2;
+
+ // first we handle the linenumber attribute
+ if (codeStream.generateLineNumberAttributes) {
+ /* Create and add the line number attribute (used for debugging)
+ * Build the pairs of:
+ * (bytecodePC lineNumber)
+ * according to the table of start line indexes and the pcToSourceMap table
+ * contained into the codestream
+ */
+ int[] pcToSourceMapTable;
+ if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null) && (codeStream.pcToSourceMapSize != 0)) {
+ int lineNumberNameIndex = constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
+ if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
- }
- // debug attributes
- int codeAttributeAttributeOffset = localContentsOffset;
- int attributeNumber = 0;
- // leave two bytes for the attribute_length
- localContentsOffset += 2;
-
- // first we handle the linenumber attribute
- if (codeStream.generateLineNumberAttributes) {
- /* Create and add the line number attribute (used for debugging)
- * Build the pairs of:
- * (bytecodePC lineNumber)
- * according to the table of start line indexes and the pcToSourceMap table
- * contained into the codestream
- */
- /** OLD CODE
- int[][] pcToSourceMapTable;
- int previousLineNumber;
- int[] flatTable;
- int index;
- int startLineIndexes[] = codeStream.methodDeclaration.scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions;
- int max = startLineIndexes.length;
- */
- int[] pcToSourceMapTable;
- if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null)
- && (codeStream.pcToSourceMapSize != 0)) {
- int lineNumberNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
- if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
- int lineNumberTableOffset = localContentsOffset;
- localContentsOffset += 6;
- // leave space for attribute_length and line_number_table_length
- /** OLD CODE
- previousLineNumber = 0;
-
- // Seems like do would be better, but this preserves the existing behavior.
-
- flatTable = new int[code_length];
- for (int i = codeStream.pcToSourceMapSize - 1; i >= 0; i--) {
- // entry contains the following structure:
- // position 1: startPC
- // position 2: endPC
- // position 3: sourceStart
- // position 4: sourceEnd
- // Compute the line number for a given source position
- index = searchLineNumber(startLineIndexes, pcToSourceMapTable[i][2]);
- for (int j = pcToSourceMapTable[i][0]; j < pcToSourceMapTable[i][1]; j++)
- flatTable[j] = index;
- }
- previousLineNumber = -1;
-
- */
- int numberOfEntries = 0;
- int length = codeStream.pcToSourceMapSize;
- /** OLD CODE
- int length = flatTable.length;
- for (int i = 0; i < length; i++) {
- if (flatTable[i] != previousLineNumber) {
- previousLineNumber = flatTable[i];
- // write the entry
- if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
- System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (i >> 8);
- localContents[localContentsOffset++] = (byte) i;
- localContents[localContentsOffset++] = (byte) (previousLineNumber >> 8);
- localContents[localContentsOffset++] = (byte) previousLineNumber;
- numberOfEntries++;
- }
- }
- */
- for (int i = 0; i < length;) {
- // write the entry
- if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int pc = pcToSourceMapTable[i++];
- localContents[localContentsOffset++] = (byte) (pc >> 8);
- localContents[localContentsOffset++] = (byte) pc;
- int lineNumber = pcToSourceMapTable[i++];
- localContents[localContentsOffset++] = (byte) (lineNumber >> 8);
- localContents[localContentsOffset++] = (byte) lineNumber;
- numberOfEntries++;
+ localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
+ int lineNumberTableOffset = localContentsOffset;
+ localContentsOffset += 6; // leave space for attribute_length and line_number_table_length
+ int numberOfEntries = 0;
+ int length = codeStream.pcToSourceMapSize;
+ for (int i = 0; i < length;) {
+ // write the entry
+ if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
- // now we change the size of the line number attribute
- int lineNumberAttr_length = numberOfEntries * 4 + 2;
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
- localContents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
- localContents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
- localContents[lineNumberTableOffset++] = (byte) numberOfEntries;
- attributeNumber++;
+ int pc = pcToSourceMapTable[i++];
+ localContents[localContentsOffset++] = (byte) (pc >> 8);
+ localContents[localContentsOffset++] = (byte) pc;
+ int lineNumber = pcToSourceMapTable[i++];
+ localContents[localContentsOffset++] = (byte) (lineNumber >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumber;
+ numberOfEntries++;
}
+ // now we change the size of the line number attribute
+ int lineNumberAttr_length = numberOfEntries * 4 + 2;
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
+ localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
+ localContents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
+ localContents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
+ localContents[lineNumberTableOffset++] = (byte) numberOfEntries;
+ attributeNumber++;
}
- // then we do the local variable attribute
- if (codeStream.generateLocalVariableTableAttributes) {
- int localVariableTableOffset = localContentsOffset;
- int numberOfEntries = 0;
- int localVariableNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
+ }
+
+
+
+ // then we do the local variable attribute
+ if (codeStream.generateLocalVariableTableAttributes) {
+ int localVariableTableOffset = localContentsOffset;
+ int numberOfEntries = 0;
+ // codeAttribute.addLocalVariableTableAttribute(this);
+ if ((codeStream.pcToSourceMap != null) && (codeStream.pcToSourceMapSize != 0)) {
+ int localVariableNameIndex = constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
localContents[localContentsOffset++] = (byte) localVariableNameIndex;
- localContentsOffset += 6;
- // leave space for attribute_length and local_variable_table_length
+ localContentsOffset += 6; // leave space for attribute_length and local_variable_table_length
int nameIndex;
int descriptorIndex;
- if (!codeStream.methodDeclaration.isStatic()) {
- numberOfEntries++;
- if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContentsOffset += 2; // the startPC for this is always 0
- localContents[localContentsOffset++] = (byte) (code_length >> 8);
- localContents[localContentsOffset++] = (byte) code_length;
- nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex =
- constantPool.literalIndex(
- codeStream.methodDeclaration.binding.declaringClass.signature());
- localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
- localContents[localContentsOffset++] = (byte) descriptorIndex;
- localContentsOffset += 2; // the resolved position for this is always 0
- }
for (int i = 0; i < codeStream.allLocalsCounter; i++) {
LocalVariableBinding localVariable = codeStream.locals[i];
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
- int endPC = localVariable.initializationPCs[(j << 1) + 1];
+ int endPC = localVariable.initializationPCs[ (j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
int currentLength;
if (endPC == -1) {
- localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
- (AstNode) localVariable.declaringScope.methodScope().referenceContext);
+ localVariable.declaringScope.problemReporter().abortDueToInternalError(Util.bind("abort.invalidAttribute"/*nonNLS*/,new String(localVariable.name)), (AstNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
// now we can safely add the local entry
numberOfEntries++;
@@ -1438,616 +1441,271 @@ public class ClassFile
localContents[localVariableTableOffset] = (byte) numberOfEntries;
attributeNumber++;
}
- // update the number of attributes
- // ensure first that there is enough space available inside the localContents array
- if (codeAttributeAttributeOffset + 2
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
- localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
-
- // update the attribute length
- int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
- localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
- localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
- localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
- localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
- contentsOffset = localContentsOffset;
}
-
- /**
- * INTERNAL USE-ONLY
- * That method completes the creation of the code attribute by setting
- * - the attribute_length
- * - max_stack
- * - max_locals
- * - code_length
- * - exception table
- * - and debug attributes if necessary.
- *
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param codeAttributeOffset <CODE>int</CODE>
- */
- public void completeCodeAttributeForClinit(int codeAttributeOffset) {
- // reinitialize the contents with the byte modified by the code stream
- byte[] localContents = contents = codeStream.bCodeStream;
- int localContentsOffset = codeStream.classFileOffset;
- // codeAttributeOffset is the position inside contents byte array before we started to write
- // any information about the codeAttribute
- // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
- // to get the right position, 6 for the max_stack etc...
- int contentsLength;
- int code_length = codeStream.position;
- if (code_length > 65535) {
- codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
- codeStream.methodDeclaration.scope.referenceType());
- }
- if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int max_stack = codeStream.stackMax;
- localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
- localContents[codeAttributeOffset + 7] = (byte) max_stack;
- int max_locals = codeStream.maxLocals;
- localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
- localContents[codeAttributeOffset + 9] = (byte) max_locals;
- localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
- localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
- localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
- localContents[codeAttributeOffset + 13] = (byte) code_length;
-
- // write the exception table
- int exceptionHandlersNumber = codeStream.exceptionHandlersNumber;
- ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
- int exSize;
- if (localContentsOffset + (exSize = (exceptionHandlersNumber * 8 + 2))
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents =
- contents =
- new byte[contentsLength + (exSize > INCREMENT_SIZE ? exSize : INCREMENT_SIZE)]),
- 0,
- contentsLength);
- }
- // there is no exception table, so we need to offset by 2 the current offset and move
- // on the attribute generation
- localContents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
- localContents[localContentsOffset++] = (byte) exceptionHandlersNumber;
- for (int i = 0; i < exceptionHandlersNumber; i++) {
- ExceptionLabel exceptionHandler = exceptionHandlers[i];
- int start = exceptionHandler.start;
- localContents[localContentsOffset++] = (byte) (start >> 8);
- localContents[localContentsOffset++] = (byte) start;
- int end = exceptionHandler.end;
- localContents[localContentsOffset++] = (byte) (end >> 8);
- localContents[localContentsOffset++] = (byte) end;
- int handlerPC = exceptionHandler.position;
- localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
- localContents[localContentsOffset++] = (byte) handlerPC;
- if (exceptionHandler.exceptionType == null) {
- // any exception handler
- localContentsOffset += 2;
- } else {
- int nameIndex;
- if (exceptionHandler.exceptionType == TypeBinding.NullBinding) {
- /* represents denote ClassNotFoundException, see class literal access*/
- nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
- } else {
- nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
- }
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
- }
- }
- // debug attributes
- int codeAttributeAttributeOffset = localContentsOffset;
- int attributeNumber = 0;
- // leave two bytes for the attribute_length
- localContentsOffset += 2;
-
- // first we handle the linenumber attribute
- if (codeStream.generateLineNumberAttributes) {
- /* Create and add the line number attribute (used for debugging)
- * Build the pairs of:
- * (bytecodePC lineNumber)
- * according to the table of start line indexes and the pcToSourceMap table
- * contained into the codestream
- */
- int[] pcToSourceMapTable;
- if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null)
- && (codeStream.pcToSourceMapSize != 0)) {
- int lineNumberNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
- if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
- int lineNumberTableOffset = localContentsOffset;
- localContentsOffset += 6;
- // leave space for attribute_length and line_number_table_length
- int numberOfEntries = 0;
- int length = codeStream.pcToSourceMapSize;
- for (int i = 0; i < length;) {
- // write the entry
- if (localContentsOffset + 4 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int pc = pcToSourceMapTable[i++];
- localContents[localContentsOffset++] = (byte) (pc >> 8);
- localContents[localContentsOffset++] = (byte) pc;
- int lineNumber = pcToSourceMapTable[i++];
- localContents[localContentsOffset++] = (byte) (lineNumber >> 8);
- localContents[localContentsOffset++] = (byte) lineNumber;
- numberOfEntries++;
- }
- // now we change the size of the line number attribute
- int lineNumberAttr_length = numberOfEntries * 4 + 2;
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
- localContents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
- localContents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
- localContents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
- localContents[lineNumberTableOffset++] = (byte) numberOfEntries;
- attributeNumber++;
- }
- }
- // then we do the local variable attribute
- if (codeStream.generateLocalVariableTableAttributes) {
- int localVariableTableOffset = localContentsOffset;
- int numberOfEntries = 0;
- // codeAttribute.addLocalVariableTableAttribute(this);
- if ((codeStream.pcToSourceMap != null)
- && (codeStream.pcToSourceMapSize != 0)) {
- int localVariableNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
- if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) localVariableNameIndex;
- localContentsOffset += 6;
- // leave space for attribute_length and local_variable_table_length
- int nameIndex;
- int descriptorIndex;
- for (int i = 0; i < codeStream.allLocalsCounter; i++) {
- LocalVariableBinding localVariable = codeStream.locals[i];
- for (int j = 0; j < localVariable.initializationCount; j++) {
- int startPC = localVariable.initializationPCs[j << 1];
- int endPC = localVariable.initializationPCs[(j << 1) + 1];
- if (startPC != endPC) { // only entries for non zero length
- int currentLength;
- if (endPC == -1) {
- localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
- (AstNode) localVariable.declaringScope.methodScope().referenceContext);
- }
- if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- // now we can safely add the local entry
- numberOfEntries++;
- localContents[localContentsOffset++] = (byte) (startPC >> 8);
- localContents[localContentsOffset++] = (byte) startPC;
- int length = endPC - startPC;
- localContents[localContentsOffset++] = (byte) (length >> 8);
- localContents[localContentsOffset++] = (byte) length;
- nameIndex = constantPool.literalIndex(localVariable.name);
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
- localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
- localContents[localContentsOffset++] = (byte) descriptorIndex;
- int resolvedPosition = localVariable.resolvedPosition;
- localContents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
- localContents[localContentsOffset++] = (byte) resolvedPosition;
- }
- }
- }
- int value = numberOfEntries * 10 + 2;
- localVariableTableOffset += 2;
- localContents[localVariableTableOffset++] = (byte) (value >> 24);
- localContents[localVariableTableOffset++] = (byte) (value >> 16);
- localContents[localVariableTableOffset++] = (byte) (value >> 8);
- localContents[localVariableTableOffset++] = (byte) value;
- localContents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
- localContents[localVariableTableOffset] = (byte) numberOfEntries;
- attributeNumber++;
- }
- }
- // update the number of attributes
- // ensure first that there is enough space available inside the contents array
- if (codeAttributeAttributeOffset + 2
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
- localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
- // update the attribute length
- int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
- localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
- localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
- localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
- localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
- contentsOffset = localContentsOffset;
+ // update the number of attributes
+ // ensure first that there is enough space available inside the contents array
+ if (codeAttributeAttributeOffset + 2 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * That method completes the creation of the code attribute by setting
- * - the attribute_length
- * - max_stack
- * - max_locals
- * - code_length
- * - exception table
- * - and debug attributes if necessary.
- *
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param codeAttributeOffset <CODE>int</CODE>
- * @param exceptionHandler int[]
- * @param startIndexes int[]
- */
- public void completeCodeAttributeForClinit(
- int codeAttributeOffset,
- int[] exceptionHandler,
- int[] startLineIndexes) {
- // reinitialize the contents with the byte modified by the code stream
- byte[] localContents = contents = codeStream.bCodeStream;
- int localContentsOffset = codeStream.classFileOffset;
- // codeAttributeOffset is the position inside contents byte array before we started to write
- // any information about the codeAttribute
- // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
- // to get the right position, 6 for the max_stack etc...
- int contentsLength;
- int code_length = codeStream.position;
- if (code_length > 65535) {
- codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
- codeStream.methodDeclaration.scope.referenceType());
- }
- if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int max_stack = codeStream.stackMax;
- localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
- localContents[codeAttributeOffset + 7] = (byte) max_stack;
- int max_locals = codeStream.maxLocals;
- localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
- localContents[codeAttributeOffset + 9] = (byte) max_locals;
- localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
- localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
- localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
- localContents[codeAttributeOffset + 13] = (byte) code_length;
-
- // write the exception table
+ localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
+ localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
+ // update the attribute length
+ int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
+ localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
+ localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
+ localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
+ localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
+ contentsOffset = localContentsOffset;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method completes the creation of the code attribute by setting
+ * - the attribute_length
+ * - max_stack
+ * - max_locals
+ * - code_length
+ * - exception table
+ * - and debug attributes if necessary.
+ *
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param codeAttributeOffset <CODE>int</CODE>
+ * @param exceptionHandler int[]
+ * @param startIndexes int[]
+ */
+public void completeCodeAttributeForClinit(int codeAttributeOffset, int[] exceptionHandler, int[] startLineIndexes) {
+ // reinitialize the contents with the byte modified by the code stream
+ byte[] localContents = contents = codeStream.bCodeStream;
+ int localContentsOffset = codeStream.classFileOffset;
+ // codeAttributeOffset is the position inside contents byte array before we started to write
+ // any information about the codeAttribute
+ // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
+ // to get the right position, 6 for the max_stack etc...
+ int contentsLength;
+ int code_length = codeStream.position;
+ if (code_length > 65535) {
+ codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(codeStream.methodDeclaration.scope.referenceType());
+ }
+ if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ int max_stack = codeStream.stackMax;
+ localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
+ localContents[codeAttributeOffset + 7] = (byte) max_stack;
+ int max_locals = codeStream.maxLocals;
+ localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
+ localContents[codeAttributeOffset + 9] = (byte) max_locals;
+ localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
+ localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
+ localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
+ localContents[codeAttributeOffset + 13] = (byte) code_length;
+
+ // write the exception table
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 1;
+ int start = exceptionHandler[0];
+ localContents[localContentsOffset++] = (byte) (start >> 8);
+ localContents[localContentsOffset++] = (byte) start;
+ int end = exceptionHandler[1];
+ localContents[localContentsOffset++] = (byte) (end >> 8);
+ localContents[localContentsOffset++] = (byte) end;
+ int handlerPC = exceptionHandler[2];
+ localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
+ localContents[localContentsOffset++] = (byte) handlerPC;
+ int nameIndex = constantPool.literalIndexForJavaLangException();
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
+
+ // debug attributes
+ int codeAttributeAttributeOffset = localContentsOffset;
+ int attributeNumber = 0; // leave two bytes for the attribute_length
+ localContentsOffset += 2; // first we handle the linenumber attribute
+
+ // first we handle the linenumber attribute
+ if (codeStream.generateLineNumberAttributes) {
+ /* Create and add the line number attribute (used for debugging)
+ * Build the pairs of:
+ * (bytecodePC lineNumber)
+ * according to the table of start line indexes and the pcToSourceMap table
+ * contained into the codestream
+ */
+ int index = 0, max = startLineIndexes.length;
+ int lineNumberNameIndex = constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
+ localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 6;
localContents[localContentsOffset++] = 0;
localContents[localContentsOffset++] = 1;
- int start = exceptionHandler[0];
- localContents[localContentsOffset++] = (byte) (start >> 8);
- localContents[localContentsOffset++] = (byte) start;
- int end = exceptionHandler[1];
- localContents[localContentsOffset++] = (byte) (end >> 8);
- localContents[localContentsOffset++] = (byte) end;
- int handlerPC = exceptionHandler[2];
- localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
- localContents[localContentsOffset++] = (byte) handlerPC;
- int nameIndex = constantPool.literalIndexForJavaLangException();
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
-
- // debug attributes
- int codeAttributeAttributeOffset = localContentsOffset;
- int attributeNumber = 0; // leave two bytes for the attribute_length
- localContentsOffset += 2; // first we handle the linenumber attribute
-
- // first we handle the linenumber attribute
- if (codeStream.generateLineNumberAttributes) {
- /* Create and add the line number attribute (used for debugging)
- * Build the pairs of:
- * (bytecodePC lineNumber)
- * according to the table of start line indexes and the pcToSourceMap table
- * contained into the codestream
- */
- int index = 0, max = startLineIndexes.length;
- int lineNumberNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
- localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 6;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 1;
- // first entry at pc = 0
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = (byte) (problemLine >> 8);
- localContents[localContentsOffset++] = (byte) problemLine;
- // now we change the size of the line number attribute
- attributeNumber++;
- }
- // then we do the local variable attribute
- if (codeStream.generateLocalVariableTableAttributes) {
- int localVariableNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
- if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) localVariableNameIndex;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 2;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- attributeNumber++;
- }
- // update the number of attributes
- // ensure first that there is enough space available inside the contents array
- if (codeAttributeAttributeOffset + 2
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
- localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
- // update the attribute length
- int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
- localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
- localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
- localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
- localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
- contentsOffset = localContentsOffset;
+ // first entry at pc = 0
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = (byte) (problemLine >> 8);
+ localContents[localContentsOffset++] = (byte) problemLine;
+ // now we change the size of the line number attribute
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * That method completes the creation of the code attribute by setting
- * - the attribute_length
- * - max_stack
- * - max_locals
- * - code_length
- * - exception table
- * - and debug attributes if necessary.
- *
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param codeAttributeOffset <CODE>int</CODE>
- * @param exceptionHandler int[]
- */
- public void completeCodeAttributeForProblemMethod(
- AbstractMethodDeclaration method,
- MethodBinding binding,
- int codeAttributeOffset,
- int[] exceptionHandler,
- int[] startLineIndexes) {
- // reinitialize the localContents with the byte modified by the code stream
- byte[] localContents = contents = codeStream.bCodeStream;
- int localContentsOffset = codeStream.classFileOffset;
- // codeAttributeOffset is the position inside localContents byte array before we started to write// any information about the codeAttribute// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset// to get the right position, 6 for the max_stack etc...
- int max_stack = codeStream.stackMax;
- localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
- localContents[codeAttributeOffset + 7] = (byte) max_stack;
- int max_locals = codeStream.maxLocals;
- localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
- localContents[codeAttributeOffset + 9] = (byte) max_locals;
- int code_length = codeStream.position;
- localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
- localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
- localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
- localContents[codeAttributeOffset + 13] = (byte) code_length;
- // write the exception table
- int contentsLength;
- if (localContentsOffset + 50 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
+ // then we do the local variable attribute
+ if (codeStream.generateLocalVariableTableAttributes) {
+ int localVariableNameIndex = constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
+ if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
+ localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) localVariableNameIndex;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 2;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ attributeNumber++;
+ }
+
+ // update the number of attributes
+ // ensure first that there is enough space available inside the contents array
+ if (codeAttributeAttributeOffset + 2 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
+ localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
+ // update the attribute length
+ int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
+ localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
+ localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
+ localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
+ localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
+ contentsOffset = localContentsOffset;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method completes the creation of the code attribute by setting
+ * - the attribute_length
+ * - max_stack
+ * - max_locals
+ * - code_length
+ * - exception table
+ * - and debug attributes if necessary.
+ *
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param codeAttributeOffset <CODE>int</CODE>
+ * @param exceptionHandler int[]
+ */
+public void completeCodeAttributeForProblemMethod(AbstractMethodDeclaration method, MethodBinding binding, int codeAttributeOffset, int[] exceptionHandler, int[] startLineIndexes) {
+ // reinitialize the localContents with the byte modified by the code stream
+ byte[] localContents = contents = codeStream.bCodeStream;
+ int localContentsOffset = codeStream.classFileOffset;
+ // codeAttributeOffset is the position inside localContents byte array before we started to write// any information about the codeAttribute// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset// to get the right position, 6 for the max_stack etc...
+ int max_stack = codeStream.stackMax;
+ localContents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
+ localContents[codeAttributeOffset + 7] = (byte) max_stack;
+ int max_locals = codeStream.maxLocals;
+ localContents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
+ localContents[codeAttributeOffset + 9] = (byte) max_locals;
+ int code_length = codeStream.position;
+ localContents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
+ localContents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
+ localContents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
+ localContents[codeAttributeOffset + 13] = (byte) code_length;
+ // write the exception table
+ int contentsLength;
+ if (localContentsOffset + 50 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 1;
+ int start = exceptionHandler[0];
+ localContents[localContentsOffset++] = (byte) (start >> 8);
+ localContents[localContentsOffset++] = (byte) start;
+ int end = exceptionHandler[1];
+ localContents[localContentsOffset++] = (byte) (end >> 8);
+ localContents[localContentsOffset++] = (byte) end;
+ int handlerPC = exceptionHandler[2];
+ localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
+ localContents[localContentsOffset++] = (byte) handlerPC;
+ int nameIndex = constantPool.literalIndexForJavaLangException();
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex; // debug attributes
+ int codeAttributeAttributeOffset = localContentsOffset;
+ int attributeNumber = 0; // leave two bytes for the attribute_length
+ localContentsOffset += 2; // first we handle the linenumber attribute
+
+ if (codeStream.generateLineNumberAttributes) {
+ /* Create and add the line number attribute (used for debugging)
+ * Build the pairs of:
+ * (bytecodePC lineNumber)
+ * according to the table of start line indexes and the pcToSourceMap table
+ * contained into the codestream
+ */
+ int lineNumberNameIndex = constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
+ localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 6;
localContents[localContentsOffset++] = 0;
localContents[localContentsOffset++] = 1;
- int start = exceptionHandler[0];
- localContents[localContentsOffset++] = (byte) (start >> 8);
- localContents[localContentsOffset++] = (byte) start;
- int end = exceptionHandler[1];
- localContents[localContentsOffset++] = (byte) (end >> 8);
- localContents[localContentsOffset++] = (byte) end;
- int handlerPC = exceptionHandler[2];
- localContents[localContentsOffset++] = (byte) (handlerPC >> 8);
- localContents[localContentsOffset++] = (byte) handlerPC;
- int nameIndex = constantPool.literalIndexForJavaLangException();
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex; // debug attributes
- int codeAttributeAttributeOffset = localContentsOffset;
- int attributeNumber = 0; // leave two bytes for the attribute_length
- localContentsOffset += 2; // first we handle the linenumber attribute
+ if (problemLine == 0) {
+ problemLine = searchLineNumber(startLineIndexes, binding.sourceStart());
+ }
+ // first entry at pc = 0
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = (byte) (problemLine >> 8);
+ localContents[localContentsOffset++] = (byte) problemLine;
+ // now we change the size of the line number attribute
+ attributeNumber++;
+ }
- if (codeStream.generateLineNumberAttributes) {
- /* Create and add the line number attribute (used for debugging)
- * Build the pairs of:
- * (bytecodePC lineNumber)
- * according to the table of start line indexes and the pcToSourceMap table
- * contained into the codestream
- */
- int lineNumberNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
- localContents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) lineNumberNameIndex;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
+ // then we do the local variable attribute
+ if (codeStream.generateLocalVariableTableAttributes) {
+ // compute the resolved position for the arguments of the method
+ int argSize;
+ int localVariableTableOffset = localContentsOffset;
+ int numberOfEntries = 0;
+ // codeAttribute.addLocalVariableTableAttribute(this);
+ int localVariableNameIndex = constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
+ if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) localVariableNameIndex;
+ localContentsOffset += 6; // leave space for attribute_length and local_variable_table_length
+ int descriptorIndex;
+ if (!codeStream.methodDeclaration.isStatic()) {
+ numberOfEntries++;
+ if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 6;
localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 1;
- if (problemLine == 0) {
- problemLine = searchLineNumber(startLineIndexes, binding.sourceStart());
- }
- // first entry at pc = 0
+ localContents[localContentsOffset++] = (byte) (code_length >> 8);
+ localContents[localContentsOffset++] = (byte) code_length;
+ nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
+ descriptorIndex = constantPool.literalIndex(codeStream.methodDeclaration.binding.declaringClass.signature());
+ localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
+ localContents[localContentsOffset++] = (byte) descriptorIndex;
+ // the resolved position for this is always 0
localContents[localContentsOffset++] = 0;
localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = (byte) (problemLine >> 8);
- localContents[localContentsOffset++] = (byte) problemLine;
- // now we change the size of the line number attribute
- attributeNumber++;
}
- // then we do the local variable attribute
- if (codeStream.generateLocalVariableTableAttributes) {
- // compute the resolved position for the arguments of the method
- int argSize;
- int localVariableTableOffset = localContentsOffset;
- int numberOfEntries = 0;
- // codeAttribute.addLocalVariableTableAttribute(this);
- int localVariableNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
- if (localContentsOffset + 8 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
- localContents[localContentsOffset++] = (byte) localVariableNameIndex;
- localContentsOffset += 6;
- // leave space for attribute_length and local_variable_table_length
- int descriptorIndex;
- if (!codeStream.methodDeclaration.isStatic()) {
- numberOfEntries++;
- if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = (byte) (code_length >> 8);
- localContents[localContentsOffset++] = (byte) code_length;
- nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex =
- constantPool.literalIndex(
- codeStream.methodDeclaration.binding.declaringClass.signature());
- localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
- localContents[localContentsOffset++] = (byte) descriptorIndex;
- // the resolved position for this is always 0
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- }
- if (binding.isConstructor()) {
- ReferenceBinding declaringClass = binding.declaringClass;
- if (declaringClass.isNestedType()) {
- NestedTypeBinding methodDeclaringClass = (NestedTypeBinding) declaringClass;
- argSize = methodDeclaringClass.syntheticArgumentsOffset;
- SyntheticArgumentBinding[] syntheticArguments;
- if ((syntheticArguments = methodDeclaringClass.syntheticEnclosingInstances())
- != null) {
- for (int i = 0, max = syntheticArguments.length; i < max; i++) {
- LocalVariableBinding localVariable = syntheticArguments[i];
- int currentLength;
- if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- // now we can safely add the local entry
- numberOfEntries++;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = 0;
- localContents[localContentsOffset++] = (byte) (code_length >> 8);
- localContents[localContentsOffset++] = (byte) code_length;
- nameIndex = constantPool.literalIndex(localVariable.name);
- localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
- localContents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
- localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
- localContents[localContentsOffset++] = (byte) descriptorIndex;
- int resolvedPosition = localVariable.resolvedPosition;
- localContents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
- localContents[localContentsOffset++] = (byte) resolvedPosition;
- }
- }
- } else {
- argSize = 1;
- }
- } else {
- argSize = binding.isStatic() ? 0 : 1;
- }
- if (method.binding != null) {
- TypeBinding[] parameters = method.binding.parameters;
- Argument[] arguments = method.arguments;
- if ((parameters != null) && (arguments != null)) {
- for (int i = 0, max = parameters.length; i < max; i++) {
- TypeBinding argumentBinding = parameters[i];
+ if (binding.isConstructor()) {
+ ReferenceBinding declaringClass = binding.declaringClass;
+ if (declaringClass.isNestedType()) {
+ NestedTypeBinding methodDeclaringClass = (NestedTypeBinding) declaringClass;
+ argSize = methodDeclaringClass.syntheticArgumentsOffset;
+ SyntheticArgumentBinding[] syntheticArguments;
+ if ((syntheticArguments = methodDeclaringClass.syntheticEnclosingInstances()) != null) {
+ for (int i = 0, max = syntheticArguments.length; i < max; i++) {
+ LocalVariableBinding localVariable = syntheticArguments[i];
int currentLength;
if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
// now we can safely add the local entry
numberOfEntries++;
@@ -2055,808 +1713,722 @@ public class ClassFile
localContents[localContentsOffset++] = 0;
localContents[localContentsOffset++] = (byte) (code_length >> 8);
localContents[localContentsOffset++] = (byte) code_length;
- nameIndex = constantPool.literalIndex(arguments[i].name);
+ nameIndex = constantPool.literalIndex(localVariable.name);
localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
localContents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex = constantPool.literalIndex(argumentBinding.signature());
+ descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
localContents[localContentsOffset++] = (byte) descriptorIndex;
- int resolvedPosition = argSize;
- if ((argumentBinding == TypeBinding.LongBinding)
- || (argumentBinding == TypeBinding.DoubleBinding))
- argSize += 2;
- else
- argSize++;
+ int resolvedPosition = localVariable.resolvedPosition;
localContents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
localContents[localContentsOffset++] = (byte) resolvedPosition;
}
}
+ } else {
+ argSize = 1;
}
- int value = numberOfEntries * 10 + 2;
- localVariableTableOffset += 2;
- localContents[localVariableTableOffset++] = (byte) (value >> 24);
- localContents[localVariableTableOffset++] = (byte) (value >> 16);
- localContents[localVariableTableOffset++] = (byte) (value >> 8);
- localContents[localVariableTableOffset++] = (byte) value;
- localContents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
- localContents[localVariableTableOffset] = (byte) numberOfEntries;
- attributeNumber++;
- }
- // update the number of attributes// ensure first that there is enough space available inside the localContents array
- if (codeAttributeAttributeOffset + 2
- >= (contentsLength = localContents.length)) {
- System.arraycopy(
- contents,
- 0,
- (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
- localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
- // update the attribute length
- int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
- localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
- localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
- localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
- localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
- contentsOffset = localContentsOffset;
- }
-
- /**
- * INTERNAL USE-ONLY
- * That method completes the creation of the code attribute by setting
- * - the attribute_length
- * - max_stack
- * - max_locals
- * - code_length
- * - exception table
- * - and debug attributes if necessary.
- *
- * @param binding org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param codeAttributeOffset <CODE>int</CODE>
- */
- public void completeCodeAttributeForSyntheticAccessMethod(
- SyntheticAccessMethodBinding binding,
- int codeAttributeOffset,
- int[] startLineIndexes) {
- // reinitialize the contents with the byte modified by the code stream
- contents = codeStream.bCodeStream;
- int localContentsOffset = codeStream.classFileOffset;
- // codeAttributeOffset is the position inside contents byte array before we started to write
- // any information about the codeAttribute
- // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
- // to get the right position, 6 for the max_stack etc...
- int max_stack = codeStream.stackMax;
- contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
- contents[codeAttributeOffset + 7] = (byte) max_stack;
- int max_locals = codeStream.maxLocals;
- contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
- contents[codeAttributeOffset + 9] = (byte) max_locals;
- int code_length = codeStream.position;
- contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
- contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
- contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
- contents[codeAttributeOffset + 13] = (byte) code_length;
- int contentsLength;
- if ((localContentsOffset + 40) >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- // there is no exception table, so we need to offset by 2 the current offset and move
- // on the attribute generation
- localContentsOffset += 2;
- // debug attributes
- int codeAttributeAttributeOffset = localContentsOffset;
- int attributeNumber = 0;
- // leave two bytes for the attribute_length
- localContentsOffset += 2;
-
- // first we handle the linenumber attribute
- if (codeStream.generateLineNumberAttributes) {
- int index = 0, max = startLineIndexes.length;
- int lineNumberNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
- contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
- contents[localContentsOffset++] = (byte) lineNumberNameIndex;
- int lineNumberTableOffset = localContentsOffset;
- localContentsOffset += 6;
- // leave space for attribute_length and line_number_table_length
- // Seems like do would be better, but this preserves the existing behavior.
- index = searchLineNumber(startLineIndexes, binding.sourceStart);
- contents[localContentsOffset++] = 0;
- contents[localContentsOffset++] = 0;
- contents[localContentsOffset++] = (byte) (index >> 8);
- contents[localContentsOffset++] = (byte) index;
- // now we change the size of the line number attribute
- contents[lineNumberTableOffset++] = 0;
- contents[lineNumberTableOffset++] = 0;
- contents[lineNumberTableOffset++] = 0;
- contents[lineNumberTableOffset++] = 6;
- contents[lineNumberTableOffset++] = 0;
- contents[lineNumberTableOffset++] = 1;
- attributeNumber++;
- }
- // then we do the local variable attribute
- if (codeStream.generateLocalVariableTableAttributes) {
- int localVariableTableOffset = localContentsOffset;
- int numberOfEntries = 0;
- int localVariableNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
- if (localContentsOffset + 8 > (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
- contents[localContentsOffset++] = (byte) localVariableNameIndex;
- localContentsOffset += 6;
- // leave space for attribute_length and local_variable_table_length
- int nameIndex;
- int descriptorIndex;
- for (int i = 0; i < codeStream.allLocalsCounter; i++) {
- LocalVariableBinding localVariable = codeStream.locals[i];
- for (int j = 0; j < localVariable.initializationCount; j++) {
- int startPC = localVariable.initializationPCs[j << 1];
- int endPC = localVariable.initializationPCs[(j << 1) + 1];
- if (startPC != endPC) { // only entries for non zero length
- int currentLength;
- if (endPC == -1) {
- localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
- (AstNode) localVariable.declaringScope.methodScope().referenceContext);
- }
- if (localContentsOffset + 10 > (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- // now we can safely add the local entry
- numberOfEntries++;
- contents[localContentsOffset++] = (byte) (startPC >> 8);
- contents[localContentsOffset++] = (byte) startPC;
- int length = endPC - startPC;
- contents[localContentsOffset++] = (byte) (length >> 8);
- contents[localContentsOffset++] = (byte) length;
- nameIndex = constantPool.literalIndex(localVariable.name);
- contents[localContentsOffset++] = (byte) (nameIndex >> 8);
- contents[localContentsOffset++] = (byte) nameIndex;
- descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
- contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
- contents[localContentsOffset++] = (byte) descriptorIndex;
- int resolvedPosition = localVariable.resolvedPosition;
- contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
- contents[localContentsOffset++] = (byte) resolvedPosition;
+ } else {
+ argSize = binding.isStatic() ? 0 : 1;
+ }
+ if (method.binding != null) {
+ TypeBinding[] parameters = method.binding.parameters;
+ Argument[] arguments = method.arguments;
+ if ((parameters != null) && (arguments != null)) {
+ for (int i = 0, max = parameters.length; i < max; i++) {
+ TypeBinding argumentBinding = parameters[i];
+ int currentLength;
+ if (localContentsOffset + 10 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
+ // now we can safely add the local entry
+ numberOfEntries++;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = (byte) (code_length >> 8);
+ localContents[localContentsOffset++] = (byte) code_length;
+ nameIndex = constantPool.literalIndex(arguments[i].name);
+ localContents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ localContents[localContentsOffset++] = (byte) nameIndex;
+ descriptorIndex = constantPool.literalIndex(argumentBinding.signature());
+ localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
+ localContents[localContentsOffset++] = (byte) descriptorIndex;
+ int resolvedPosition = argSize;
+ if ((argumentBinding == TypeBinding.LongBinding) || (argumentBinding == TypeBinding.DoubleBinding))
+ argSize += 2;
+ else
+ argSize++;
+ localContents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
+ localContents[localContentsOffset++] = (byte) resolvedPosition;
}
}
- int value = numberOfEntries * 10 + 2;
- localVariableTableOffset += 2;
- contents[localVariableTableOffset++] = (byte) (value >> 24);
- contents[localVariableTableOffset++] = (byte) (value >> 16);
- contents[localVariableTableOffset++] = (byte) (value >> 8);
- contents[localVariableTableOffset++] = (byte) value;
- contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
- contents[localVariableTableOffset] = (byte) numberOfEntries;
- attributeNumber++;
}
- // update the number of attributes
- // ensure first that there is enough space available inside the contents array
- if (codeAttributeAttributeOffset + 2 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
- contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
-
- // update the attribute length
- int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
- contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
- contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
- contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
- contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
- contentsOffset = localContentsOffset;
+ int value = numberOfEntries * 10 + 2;
+ localVariableTableOffset += 2;
+ localContents[localVariableTableOffset++] = (byte) (value >> 24);
+ localContents[localVariableTableOffset++] = (byte) (value >> 16);
+ localContents[localVariableTableOffset++] = (byte) (value >> 8);
+ localContents[localVariableTableOffset++] = (byte) value;
+ localContents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
+ localContents[localVariableTableOffset] = (byte) numberOfEntries;
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * Complete the creation of a method info by setting up the number of attributes at the right offset.
- *
- * @param methodAttributeOffset <CODE>int</CODE>
- * @param attributeNumber <CODE>int</CODE>
- */
- public void completeMethodInfo(
- int methodAttributeOffset,
- int attributeNumber) {
- // update the number of attributes
- contents[methodAttributeOffset++] = (byte) (attributeNumber >> 8);
- contents[methodAttributeOffset] = (byte) attributeNumber;
+ // update the number of attributes// ensure first that there is enough space available inside the localContents array
+ if (codeAttributeAttributeOffset + 2 >= (contentsLength = localContents.length)) {
+ System.arraycopy(contents, 0, (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ localContents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
+ localContents[codeAttributeAttributeOffset] = (byte) attributeNumber;
+ // update the attribute length
+ int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
+ localContents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
+ localContents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
+ localContents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
+ localContents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
+ contentsOffset = localContentsOffset;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method completes the creation of the code attribute by setting
+ * - the attribute_length
+ * - max_stack
+ * - max_locals
+ * - code_length
+ * - exception table
+ * - and debug attributes if necessary.
+ *
+ * @param binding org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param codeAttributeOffset <CODE>int</CODE>
+ */
+public void completeCodeAttributeForSyntheticAccessMethod(SyntheticAccessMethodBinding binding, int codeAttributeOffset, int[] startLineIndexes) {
+ // reinitialize the contents with the byte modified by the code stream
+ contents = codeStream.bCodeStream;
+ int localContentsOffset = codeStream.classFileOffset;
+ // codeAttributeOffset is the position inside contents byte array before we started to write
+ // any information about the codeAttribute
+ // That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
+ // to get the right position, 6 for the max_stack etc...
+ int max_stack = codeStream.stackMax;
+ contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
+ contents[codeAttributeOffset + 7] = (byte) max_stack;
+ int max_locals = codeStream.maxLocals;
+ contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
+ contents[codeAttributeOffset + 9] = (byte) max_locals;
+ int code_length = codeStream.position;
+ contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
+ contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
+ contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
+ contents[codeAttributeOffset + 13] = (byte) code_length;
+ int contentsLength;
+ if ((localContentsOffset + 40) >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ // there is no exception table, so we need to offset by 2 the current offset and move
+ // on the attribute generation
+ localContentsOffset += 2;
+ // debug attributes
+ int codeAttributeAttributeOffset = localContentsOffset;
+ int attributeNumber = 0;
+ // leave two bytes for the attribute_length
+ localContentsOffset += 2;
+
+ // first we handle the linenumber attribute
+ if (codeStream.generateLineNumberAttributes) {
+ int index = 0, max = startLineIndexes.length;
+ int lineNumberNameIndex = constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
+ contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
+ contents[localContentsOffset++] = (byte) lineNumberNameIndex;
+ int lineNumberTableOffset = localContentsOffset;
+ localContentsOffset += 6; // leave space for attribute_length and line_number_table_length
+ // Seems like do would be better, but this preserves the existing behavior.
+ index = searchLineNumber(startLineIndexes, binding.sourceStart);
+ contents[localContentsOffset++] = 0;
+ contents[localContentsOffset++] = 0;
+ contents[localContentsOffset++] = (byte) (index >> 8);
+ contents[localContentsOffset++] = (byte) index;
+ // now we change the size of the line number attribute
+ contents[lineNumberTableOffset++] = 0;
+ contents[lineNumberTableOffset++] = 0;
+ contents[lineNumberTableOffset++] = 0;
+ contents[lineNumberTableOffset++] = 6;
+ contents[lineNumberTableOffset++] = 0;
+ contents[lineNumberTableOffset++] = 1;
+ attributeNumber++;
}
- /*
- * INTERNAL USE-ONLY
- * Innerclasses get their name computed as they are generated, since some may not
- * be actually outputed if sitting inside unreachable code.
- *
- * @param localType org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding
- */
- public char[] computeConstantPoolName(LocalTypeBinding localType) {
- if (localType.constantPoolName() != null) {
- return localType.constantPoolName();
- }
- // delegates to the outermost enclosing classfile, since it is the only one with a global vision of its innertypes.
- if (enclosingClassFile != null) {
- return this.outerMostEnclosingClassFile().computeConstantPoolName(localType);
- }
- if (nameUsage == null)
- nameUsage = new HashtableOfType();
-
- // ensure there is not already such a local type name defined by the user
- int index = 0;
- char[] candidateName;
- while(true) {
- if (localType.isMemberType()){
- if (index == 0){
- candidateName = CharOperation.concat(
- localType.enclosingType().constantPoolName(),
- localType.sourceName,
- '$');
- } else {
- // in case of collision, then member name gets extra $1 inserted
- // e.g. class X { { class L{} new X(){ class L{} } } }
- candidateName = CharOperation.concat(
- localType.enclosingType().constantPoolName(),
- '$',
- String.valueOf(index).toCharArray(),
- '$',
- localType.sourceName);
+ // then we do the local variable attribute
+ if (codeStream.generateLocalVariableTableAttributes) {
+ int localVariableTableOffset = localContentsOffset;
+ int numberOfEntries = 0;
+ int localVariableNameIndex = constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
+ if (localContentsOffset + 8 > (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
+ contents[localContentsOffset++] = (byte) localVariableNameIndex;
+ localContentsOffset += 6; // leave space for attribute_length and local_variable_table_length
+ int nameIndex;
+ int descriptorIndex;
+ for (int i = 0; i < codeStream.allLocalsCounter; i++) {
+ LocalVariableBinding localVariable = codeStream.locals[i];
+ for (int j = 0; j < localVariable.initializationCount; j++) {
+ int startPC = localVariable.initializationPCs[j << 1];
+ int endPC = localVariable.initializationPCs[(j << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ int currentLength;
+ if (endPC == -1) {
+ localVariable.declaringScope.problemReporter().abortDueToInternalError(Util.bind("abort.invalidAttribute"/*nonNLS*/,new String(localVariable.name)), (AstNode) localVariable.declaringScope.methodScope().referenceContext);
+ }
+ if (localContentsOffset + 10 > (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ // now we can safely add the local entry
+ numberOfEntries++;
+ contents[localContentsOffset++] = (byte) (startPC >> 8);
+ contents[localContentsOffset++] = (byte) startPC;
+ int length = endPC - startPC;
+ contents[localContentsOffset++] = (byte) (length >> 8);
+ contents[localContentsOffset++] = (byte) length;
+ nameIndex = constantPool.literalIndex(localVariable.name);
+ contents[localContentsOffset++] = (byte) (nameIndex >> 8);
+ contents[localContentsOffset++] = (byte) nameIndex;
+ descriptorIndex = constantPool.literalIndex(localVariable.type.signature());
+ contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
+ contents[localContentsOffset++] = (byte) descriptorIndex;
+ int resolvedPosition = localVariable.resolvedPosition;
+ contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
+ contents[localContentsOffset++] = (byte) resolvedPosition;
}
- } else if (localType.isAnonymousType()){
- candidateName = CharOperation.concat(
- referenceBinding.constantPoolName(),
- String.valueOf(index+1).toCharArray(),
- '$');
- } else {
- candidateName = CharOperation.concat(
- referenceBinding.constantPoolName(),
- '$',
- String.valueOf(index+1).toCharArray(),
- '$',
- localType.sourceName);
- }
- if (nameUsage.get(candidateName) != null) {
- index ++;
- } else {
- nameUsage.put(candidateName, localType);
- break;
}
}
- return candidateName;
+ int value = numberOfEntries * 10 + 2;
+ localVariableTableOffset += 2;
+ contents[localVariableTableOffset++] = (byte) (value >> 24);
+ contents[localVariableTableOffset++] = (byte) (value >> 16);
+ contents[localVariableTableOffset++] = (byte) (value >> 8);
+ contents[localVariableTableOffset++] = (byte) value;
+ contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
+ contents[localVariableTableOffset] = (byte) numberOfEntries;
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * Request the creation of a ClassFile compatible representation of a problematic type
- *
- * @param typeDeclaration org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
- * @param unitResult org.eclipse.jdt.internal.compiler.CompilationUnitResult
- */
- public static void createProblemType(
- TypeDeclaration typeDeclaration,
- CompilationResult unitResult) {
- SourceTypeBinding typeBinding = typeDeclaration.binding;
- ClassFile classFile = new ClassFile(typeBinding, null, true);
+ // update the number of attributes
+ // ensure first that there is enough space available inside the contents array
+ if (codeAttributeAttributeOffset + 2 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
+ }
+ contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
+
+ // update the attribute length
+ int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
+ contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
+ contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
+ contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
+ contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
+ contentsOffset = localContentsOffset;
+}
+/**
+ * INTERNAL USE-ONLY
+ * Complete the creation of a method info by setting up the number of attributes at the right offset.
+ *
+ * @param methodAttributeOffset <CODE>int</CODE>
+ * @param attributeNumber <CODE>int</CODE>
+ */
+public void completeMethodInfo(int methodAttributeOffset, int attributeNumber) {
+ // update the number of attributes
+ contents[methodAttributeOffset++] = (byte) (attributeNumber >> 8);
+ contents[methodAttributeOffset] = (byte) attributeNumber;
+}
+/*
+ * INTERNAL USE-ONLY
+ * Innerclasses get their name computed as they are generated, since some may not
+ * be actually outputed if sitting inside unreachable code.
+ *
+ * @param localType org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding
+ */
+public char[] computeConstantPoolName(LocalTypeBinding localType) {
+ if (localType.constantPoolName() != null) {
+ return localType.constantPoolName();
+ }
- // inner attributes
- if (typeBinding.isMemberType())
- classFile.recordEnclosingTypeAttributes(typeBinding);
+ // delegates to the outermost enclosing classfile, since it is the only one with a global vision of its innertypes.
+ if (enclosingClassFile != null) {
+ return this.outerMostEnclosingClassFile().computeConstantPoolName(localType);
+ }
- // add its fields
- FieldBinding[] fields = typeBinding.fields;
- if ((fields != null) && (fields != NoFields)) {
- for (int i = 0, max = fields.length; i < max; i++) {
- if (fields[i].constant == null) {
- FieldReference.getConstantFor(fields[i], false, null, 0);
- }
+ if (nameUsage == null) {
+ nameUsage = new CharArrayCache();
+ }
+ if (localType.isMemberType()) { // catches member types of local types
+ return CharOperation.concat(
+ localType.enclosingType().constantPoolName(),
+ localType.sourceName,
+ '$');
+ } else {
+ char[][] compoundName = (char[][]) referenceBinding.compoundName.clone();
+ int last = compoundName.length - 1;
+ StringBuffer nameBuffer = new StringBuffer().append(compoundName[last]);
+ // retrieve the number of use of the combination
+ char[] simpleName = localType.sourceName;
+ //if (simpleName == null) simpleName = new char[]{}; // for anonymous
+ int nameCount = nameUsage.get(simpleName); // -1 if not found
+ nameCount = nameCount == -1 ? 1 : nameCount + 1;
+ nameBuffer.append('$').append(nameCount);
+ nameUsage.put(simpleName, nameCount);
+ if (!localType.isAnonymousType()) { // named local type
+ nameBuffer.append('$').append(simpleName);
+ }
+ compoundName[last] = nameBuffer.toString().toCharArray();
+ return CharOperation.concatWith(compoundName, '/');
+ }
+}
+/**
+ * INTERNAL USE-ONLY
+ * Request the creation of a ClassFile compatible representation of a problematic type
+ *
+ * @param typeDeclaration org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
+ * @param unitResult org.eclipse.jdt.internal.compiler.CompilationUnitResult
+ */
+public static void createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult) {
+ SourceTypeBinding typeBinding = typeDeclaration.binding;
+ ClassFile classFile = new ClassFile(typeBinding, null, true);
+
+ // inner attributes
+ if (typeBinding.isMemberType())
+ classFile.recordEnclosingTypeAttributes(typeBinding);
+
+ // add its fields
+ FieldBinding[] fields = typeBinding.fields;
+ if ((fields != null) && (fields != NoFields)) {
+ for (int i = 0, max = fields.length; i < max; i++) {
+ if (fields[i].constant == null) {
+ FieldReference.getConstantFor(fields[i], false, null, 0);
}
- classFile.addFieldInfos();
- } else {
- // we have to set the number of fields to be equals to 0
- classFile.contents[classFile.contentsOffset++] = 0;
- classFile.contents[classFile.contentsOffset++] = 0;
}
- // leave some space for the methodCount
- classFile.setForMethodInfos();
- // add its user defined methods
- MethodBinding[] methods = typeBinding.methods;
- AbstractMethodDeclaration[] methodDeclarations = typeDeclaration.methods;
- int maxMethodDecl = methodDeclarations == null ? 0 : methodDeclarations.length;
- int problemsLength;
- IProblem[] problems = unitResult.getProblems();
- if (problems == null) {
- problems = new IProblem[0];
- }
- IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
- System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
- if (methods != null) {
- if (typeBinding.isInterface()) {
- // we cannot create problem methods for an interface. So we have to generate a clinit
- // which should contain all the problem
- classFile.addProblemClinit(problemsCopy);
- for (int i = 0, max = methods.length; i < max; i++) {
- MethodBinding methodBinding;
- if ((methodBinding = methods[i]) != null) {
- // find the corresponding method declaration
- for (int j = 0; j < maxMethodDecl; j++) {
- if ((methodDeclarations[j] != null)
- && (methodDeclarations[j].binding == methods[i])) {
- if (!methodBinding.isConstructor()) {
- classFile.addAbstractMethod(methodDeclarations[j], methodBinding);
- }
- break;
+ classFile.addFieldInfos();
+ } else {
+ // we have to set the number of fields to be equals to 0
+ classFile.contents[classFile.contentsOffset++] = 0;
+ classFile.contents[classFile.contentsOffset++] = 0;
+ }
+ // leave some space for the methodCount
+ classFile.setForMethodInfos();
+ // add its user defined methods
+ MethodBinding[] methods = typeBinding.methods;
+ AbstractMethodDeclaration[] methodDeclarations = typeDeclaration.methods;
+ int maxMethodDecl = methodDeclarations == null ? 0 : methodDeclarations.length;
+ int problemsLength;
+ IProblem[] problems = unitResult.getProblems();
+ if (problems == null) {
+ problems = new IProblem[0];
+ }
+ IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
+ System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
+ if (methods != null) {
+ if (typeBinding.isInterface()) {
+ // we cannot create problem methods for an interface. So we have to generate a clinit
+ // which should contain all the problem
+ classFile.addProblemClinit(problemsCopy);
+ for (int i = 0, max = methods.length; i < max; i++) {
+ MethodBinding methodBinding;
+ if ((methodBinding = methods[i]) != null) {
+ // find the corresponding method declaration
+ for (int j = 0; j < maxMethodDecl; j++) {
+ if ((methodDeclarations[j] != null) && (methodDeclarations[j].binding == methods[i])) {
+ if (!methodBinding.isConstructor()) {
+ classFile.addAbstractMethod(methodDeclarations[j], methodBinding);
}
+ break;
}
}
}
- } else {
- for (int i = 0, max = methods.length; i < max; i++) {
- MethodBinding methodBinding;
- if ((methodBinding = methods[i]) != null) {
- // find the corresponding method declaration
- for (int j = 0; j < maxMethodDecl; j++) {
- if ((methodDeclarations[j] != null)
- && (methodDeclarations[j].binding == methods[i])) {
- AbstractMethodDeclaration methodDecl;
- if ((methodDecl = methodDeclarations[j]).isConstructor()) {
- classFile.addProblemConstructor(methodDecl, methodBinding, problemsCopy);
- } else {
- classFile.addProblemMethod(methodDecl, methodBinding, problemsCopy);
- }
- break;
+ }
+ } else {
+ for (int i = 0, max = methods.length; i < max; i++) {
+ MethodBinding methodBinding;
+ if ((methodBinding = methods[i]) != null) {
+ // find the corresponding method declaration
+ for (int j = 0; j < maxMethodDecl; j++) {
+ if ((methodDeclarations[j] != null) && (methodDeclarations[j].binding == methods[i])) {
+ AbstractMethodDeclaration methodDecl;
+ if ((methodDecl = methodDeclarations[j]).isConstructor()) {
+ classFile.addProblemConstructor(methodDecl, methodBinding, problemsCopy);
+ } else {
+ classFile.addProblemMethod(methodDecl, methodBinding, problemsCopy);
}
+ break;
}
}
}
}
- // add abstract methods
- classFile.addDefaultAbstractMethods();
}
- // propagate generation of (problem) member types
- if (typeDeclaration.memberTypes != null) {
- CompilationResult result =
- typeDeclaration.scope.referenceCompilationUnit().compilationResult;
- for (int i = 0, max = typeDeclaration.memberTypes.length; i < max; i++) {
- TypeDeclaration memberType = typeDeclaration.memberTypes[i];
- if (memberType.binding != null) {
- classFile.recordNestedMemberAttribute(memberType.binding);
- ClassFile.createProblemType(memberType, unitResult);
- }
+ // add abstract methods
+ classFile.addDefaultAbstractMethods();
+ }
+ // propagate generation of (problem) member types
+ if (typeDeclaration.memberTypes != null) {
+ CompilationResult result = typeDeclaration.scope.referenceCompilationUnit().compilationResult;
+ for (int i = 0, max = typeDeclaration.memberTypes.length; i < max; i++) {
+ TypeDeclaration memberType = typeDeclaration.memberTypes[i];
+ if (memberType.binding != null) {
+ classFile.recordNestedMemberAttribute(memberType.binding);
+ ClassFile.createProblemType(memberType, unitResult);
}
}
- classFile.addAttributes();
- unitResult.record(typeBinding.constantPoolName(), classFile);
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods returns a char[] representing the file name of the receiver
- *
- * @return char[]
- */
- public char[] fileName() {
- return constantPool.UTF8Cache.returnKeyFor(1);
+ classFile.addAttributes();
+ unitResult.record(typeBinding.constantPoolName(), classFile);
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods returns a char[] representing the file name of the receiver
+ *
+ * @return char[]
+ */
+public char[] fileName() {
+ return constantPool.UTF8Cache.returnKeyFor(1);
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method generates the header of a code attribute.
+ * - the index inside the constant pool for the attribute name (i.e. Code)
+ * - leave some space for attribute_length(4), max_stack(2), max_locals(2), code_length(4).
+ */
+public void generateCodeAttributeHeader() {
+ int contentsLength;
+ if (contentsOffset + 20 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * That method generates the header of a code attribute.
- * - the index inside the constant pool for the attribute name (i.e. Code)
- * - leave some space for attribute_length(4), max_stack(2), max_locals(2), code_length(4).
- */
- public void generateCodeAttributeHeader() {
- int contentsLength;
- if (contentsOffset + 20 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int constantValueNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.CodeName);
- contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
- contents[contentsOffset++] = (byte) constantValueNameIndex;
- // leave space for attribute_length(4), max_stack(2), max_locals(2), code_length(4)
- contentsOffset += 12;
+ int constantValueNameIndex = constantPool.literalIndex(AttributeNamesConstants.CodeName);
+ contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
+ contents[contentsOffset++] = (byte) constantValueNameIndex;
+ // leave space for attribute_length(4), max_stack(2), max_locals(2), code_length(4)
+ contentsOffset += 12;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method generates the attributes of a code attribute.
+ * They could be:
+ * - an exception attribute for each try/catch found inside the method
+ * - a deprecated attribute
+ * - a synthetic attribute for synthetic access methods
+ *
+ * It returns the number of attributes created for the code attribute.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
+ * @return <CODE>int</CODE>
+ */
+public int generateMethodInfoAttribute(MethodBinding methodBinding) {
+ // leave two bytes for the attribute_number
+ contentsOffset += 2;
+ // now we can handle all the attribute for that method info:
+ // it could be:
+ // - a CodeAttribute
+ // - a ExceptionAttribute
+ // - a DeprecatedAttribute
+ // - a SyntheticAttribute
+
+ // Exception attribute
+ ReferenceBinding[] thrownsExceptions;
+ int contentsLength;
+ int attributeNumber = 0;
+ if ((thrownsExceptions = methodBinding.thrownExceptions) != NoExceptions) {
+ // The method has a throw clause. So we need to add an exception attribute
+ // check that there is enough space to write all the bytes for the exception attribute
+ int length = thrownsExceptions.length;
+ if (contentsOffset + (8 + length * 2) >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + Math.max(INCREMENT_SIZE, (8 + length * 2))]), 0, contentsLength);
+ }
+ int exceptionNameIndex = constantPool.literalIndex(AttributeNamesConstants.ExceptionsName);
+ contents[contentsOffset++] = (byte) (exceptionNameIndex >> 8);
+ contents[contentsOffset++] = (byte) exceptionNameIndex;
+ // The attribute length = length * 2 + 2 in case of a exception attribute
+ int attributeLength = length * 2 + 2;
+ contents[contentsOffset++] = (byte) (attributeLength >> 24);
+ contents[contentsOffset++] = (byte) (attributeLength >> 16);
+ contents[contentsOffset++] = (byte) (attributeLength >> 8);
+ contents[contentsOffset++] = (byte) attributeLength;
+ contents[contentsOffset++] = (byte) (length >> 8);
+ contents[contentsOffset++] = (byte) length;
+ for (int i = 0; i < length; i++) {
+ int exceptionIndex = constantPool.literalIndex(thrownsExceptions[i]);
+ contents[contentsOffset++] = (byte) (exceptionIndex >> 8);
+ contents[contentsOffset++] = (byte) exceptionIndex;
+ }
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * That method generates the attributes of a code attribute.
- * They could be:
- * - an exception attribute for each try/catch found inside the method
- * - a deprecated attribute
- * - a synthetic attribute for synthetic access methods
- *
- * It returns the number of attributes created for the code attribute.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- * @return <CODE>int</CODE>
- */
- public int generateMethodInfoAttribute(MethodBinding methodBinding) {
- // leave two bytes for the attribute_number
- contentsOffset += 2;
- // now we can handle all the attribute for that method info:
- // it could be:
- // - a CodeAttribute
- // - a ExceptionAttribute
- // - a DeprecatedAttribute
- // - a SyntheticAttribute
-
- // Exception attribute
- ReferenceBinding[] thrownsExceptions;
- int contentsLength;
- int attributeNumber = 0;
- if ((thrownsExceptions = methodBinding.thrownExceptions) != NoExceptions) {
- // The method has a throw clause. So we need to add an exception attribute
- // check that there is enough space to write all the bytes for the exception attribute
- int length = thrownsExceptions.length;
- if (contentsOffset + (8 + length * 2) >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents =
- new byte[contentsLength + Math.max(INCREMENT_SIZE, (8 + length * 2))]),
- 0,
- contentsLength);
- }
- int exceptionNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.ExceptionsName);
- contents[contentsOffset++] = (byte) (exceptionNameIndex >> 8);
- contents[contentsOffset++] = (byte) exceptionNameIndex;
- // The attribute length = length * 2 + 2 in case of a exception attribute
- int attributeLength = length * 2 + 2;
- contents[contentsOffset++] = (byte) (attributeLength >> 24);
- contents[contentsOffset++] = (byte) (attributeLength >> 16);
- contents[contentsOffset++] = (byte) (attributeLength >> 8);
- contents[contentsOffset++] = (byte) attributeLength;
- contents[contentsOffset++] = (byte) (length >> 8);
- contents[contentsOffset++] = (byte) length;
- for (int i = 0; i < length; i++) {
- int exceptionIndex = constantPool.literalIndex(thrownsExceptions[i]);
- contents[contentsOffset++] = (byte) (exceptionIndex >> 8);
- contents[contentsOffset++] = (byte) exceptionIndex;
- }
- attributeNumber++;
- }
- // Deprecated attribute
- // Check that there is enough space to write the deprecated attribute
- if (contentsOffset + 6 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- if (methodBinding.isDeprecated()) {
- int deprecatedAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
- contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
- // the length of a deprecated attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
-
- attributeNumber++;
- }
- // Synthetic attribute
- // Check that there is enough space to write the deprecated attribute
- if (contentsOffset + 6 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- if (methodBinding.isSynthetic()) {
- int syntheticAttributeNameIndex =
- constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
- contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
- contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
- // the length of a synthetic attribute is equals to 0
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 0;
-
- attributeNumber++;
- }
- return attributeNumber;
+ // Deprecated attribute
+ // Check that there is enough space to write the deprecated attribute
+ if (contentsOffset + 6 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
+ if (methodBinding.isDeprecated()) {
+ int deprecatedAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
+ contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
+ // the length of a deprecated attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
- /**
- * INTERNAL USE-ONLY
- * That method generates the header of a method info:
- * The header consists in:
- * - the access flags
- * - the name index of the method name inside the constant pool
- * - the descriptor index of the signature of the method inside the constant pool.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- */
- public void generateMethodInfoHeader(MethodBinding methodBinding) {
- // check that there is enough space to write all the bytes for the method info corresponding
- // to the @methodBinding
- int contentsLength;
- methodCount++; // add one more method
- if (contentsOffset + 10 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- int accessFlags = methodBinding.getAccessFlags();
- if (methodBinding.isRequiredToClearPrivateModifier()) {
- accessFlags &= ~AccPrivate;
- }
- contents[contentsOffset++] = (byte) (accessFlags >> 8);
- contents[contentsOffset++] = (byte) accessFlags;
- int nameIndex = constantPool.literalIndex(methodBinding.selector);
- contents[contentsOffset++] = (byte) (nameIndex >> 8);
- contents[contentsOffset++] = (byte) nameIndex;
- int descriptorIndex = constantPool.literalIndex(methodBinding.signature());
- contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
- contents[contentsOffset++] = (byte) descriptorIndex;
+ attributeNumber++;
}
- /**
- * INTERNAL USE-ONLY
- * That method generates the method info header of a clinit:
- * The header consists in:
- * - the access flags (always default access + static)
- * - the name index of the method name (always <clinit>) inside the constant pool
- * - the descriptor index of the signature (always ()V) of the method inside the constant pool.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- */
- public void generateMethodInfoHeaderForClinit() {
- // check that there is enough space to write all the bytes for the method info corresponding
- // to the @methodBinding
- int contentsLength;
- methodCount++; // add one more method
- if (contentsOffset + 10 >= (contentsLength = contents.length)) {
- System.arraycopy(
- contents,
- 0,
- (contents = new byte[contentsLength + INCREMENT_SIZE]),
- 0,
- contentsLength);
- }
- contents[contentsOffset++] = (byte) ((AccDefault | AccStatic) >> 8);
- contents[contentsOffset++] = (byte) (AccDefault | AccStatic);
- int nameIndex = constantPool.literalIndex(QualifiedNamesConstants.Clinit);
- contents[contentsOffset++] = (byte) (nameIndex >> 8);
- contents[contentsOffset++] = (byte) nameIndex;
- int descriptorIndex =
- constantPool.literalIndex(QualifiedNamesConstants.ClinitSignature);
- contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
- contents[contentsOffset++] = (byte) descriptorIndex;
- // We know that we won't get more than 1 attribute: the code attribute
- contents[contentsOffset++] = 0;
- contents[contentsOffset++] = 1;
+ // Synthetic attribute
+ // Check that there is enough space to write the deprecated attribute
+ if (contentsOffset + 6 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
+ if (methodBinding.isSynthetic()) {
+ int syntheticAttributeNameIndex = constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
+ contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
+ contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
+ // the length of a synthetic attribute is equals to 0
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 0;
- /**
- * EXTERNAL API
- * Answer the actual bytes of the class file
- *
- * This method encodes the receiver structure into a byte array which is the content of the classfile.
- * Returns the byte array that represents the encoded structure of the receiver.
- *
- * @return byte[]
- */
- public byte[] getBytes() {
- byte[] fullContents = new byte[headerOffset + contentsOffset];
- System.arraycopy(header, 0, fullContents, 0, headerOffset);
- System.arraycopy(contents, 0, fullContents, headerOffset, contentsOffset);
- return fullContents;
+ attributeNumber++;
}
-
- /**
- * EXTERNAL API
- * Answer the compound name of the class file.
- * @return char[][]
- * e.g. {{java}, {util}, {Hashtable}}.
- */
- public char[][] getCompoundName() {
- return CharOperation.splitOn('/', fileName());
+ return attributeNumber;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method generates the header of a method info:
+ * The header consists in:
+ * - the access flags
+ * - the name index of the method name inside the constant pool
+ * - the descriptor index of the signature of the method inside the constant pool.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
+ */
+public void generateMethodInfoHeader(MethodBinding methodBinding) {
+ // check that there is enough space to write all the bytes for the method info corresponding
+ // to the @methodBinding
+ int contentsLength;
+ methodCount++; // add one more method
+ if (contentsOffset + 10 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * EXTERNAL API
- * Answer a smaller byte format, which is only contains some structural information.
- *
- * Those bytes are decodable with a regular class file reader, such as:
- * DietClassFileReader
- */
- public byte[] getReducedBytes() {
- return getBytes(); // might be improved
+ int accessFlags = methodBinding.getAccessFlags();
+ if (methodBinding.isRequiredToClearPrivateModifier()) {
+ accessFlags &= ~AccPrivate;
}
-
- /**
- * INTERNAL USE-ONLY
- * Returns the most enclosing classfile of the receiver. This is used know to store the constant pool name
- * for all inner types of the receiver.
- * @return org.eclipse.jdt.internal.compiler.codegen.ClassFile
- */
- public ClassFile outerMostEnclosingClassFile() {
- ClassFile current = this;
- while (current.enclosingClassFile != null)
- current = current.enclosingClassFile;
- return current;
+ contents[contentsOffset++] = (byte) (accessFlags >> 8);
+ contents[contentsOffset++] = (byte) accessFlags;
+ int nameIndex = constantPool.literalIndex(methodBinding.selector);
+ contents[contentsOffset++] = (byte) (nameIndex >> 8);
+ contents[contentsOffset++] = (byte) nameIndex;
+ int descriptorIndex = constantPool.literalIndex(methodBinding.signature());
+ contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
+ contents[contentsOffset++] = (byte) descriptorIndex;
+}
+/**
+ * INTERNAL USE-ONLY
+ * That method generates the method info header of a clinit:
+ * The header consists in:
+ * - the access flags (always default access + static)
+ * - the name index of the method name (always <clinit>) inside the constant pool
+ * - the descriptor index of the signature (always ()V) of the method inside the constant pool.
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
+ */
+public void generateMethodInfoHeaderForClinit() {
+ // check that there is enough space to write all the bytes for the method info corresponding
+ // to the @methodBinding
+ int contentsLength;
+ methodCount++; // add one more method
+ if (contentsOffset + 10 >= (contentsLength = contents.length)) {
+ System.arraycopy(contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength);
}
-
- /**
- * INTERNAL USE-ONLY
- * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
- * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
- *
- * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
- */
- public void recordEnclosingTypeAttributes(ReferenceBinding binding) {
- // add all the enclosing types
- ReferenceBinding enclosingType = referenceBinding.enclosingType();
- int depth = 0;
- while (enclosingType != null) {
- depth++;
+ contents[contentsOffset++] = (byte) ((AccDefault | AccStatic) >> 8);
+ contents[contentsOffset++] = (byte) (AccDefault | AccStatic);
+ int nameIndex = constantPool.literalIndex(QualifiedNamesConstants.Clinit);
+ contents[contentsOffset++] = (byte) (nameIndex >> 8);
+ contents[contentsOffset++] = (byte) nameIndex;
+ int descriptorIndex = constantPool.literalIndex(QualifiedNamesConstants.ClinitSignature);
+ contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
+ contents[contentsOffset++] = (byte) descriptorIndex;
+ // We know that we won't get more than 1 attribute: the code attribute
+ contents[contentsOffset++] = 0;
+ contents[contentsOffset++] = 1;
+}
+/**
+ * EXTERNAL API
+ * Answer the actual bytes of the class file
+ *
+ * This method encodes the receiver structure into a byte array which is the content of the classfile.
+ * Returns the byte array that represents the encoded structure of the receiver.
+ *
+ * @return byte[]
+ */
+public byte[] getBytes() {
+ byte[] fullContents = new byte[headerOffset + contentsOffset];
+ System.arraycopy(header, 0, fullContents, 0, headerOffset);
+ System.arraycopy(contents, 0, fullContents, headerOffset, contentsOffset);
+ return fullContents;
+}
+/**
+ * EXTERNAL API
+ * Answer the compound name of the class file.
+ * @return char[][]
+ * e.g. {{java}, {util}, {Hashtable}}.
+ */
+public char[][] getCompoundName() {
+ return CharOperation.splitOn('/', fileName());
+}
+/**
+ * EXTERNAL API
+ * Answer a smaller byte format, which is only contains some structural information.
+ *
+ * Those bytes are decodable with a regular class file reader, such as:
+ * DietClassFileReader
+ */
+
+public byte[] getReducedBytes() {
+ return getBytes(); // might be improved
+}
+/**
+ * INTERNAL USE-ONLY
+ * Returns the most enclosing classfile of the receiver. This is used know to store the constant pool name
+ * for all inner types of the receiver.
+ * @return org.eclipse.jdt.internal.compiler.codegen.ClassFile
+ */
+public ClassFile outerMostEnclosingClassFile() {
+ ClassFile current = this;
+ while (current.enclosingClassFile != null)
+ current = current.enclosingClassFile;
+ return current;
+}
+/**
+ * INTERNAL USE-ONLY
+ * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
+ * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
+ *
+ * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
+ */
+public void recordEnclosingTypeAttributes(ReferenceBinding binding) {
+ // add all the enclosing types
+ ReferenceBinding enclosingType = referenceBinding.enclosingType();
+ int depth = 0;
+ while (enclosingType != null) {
+ depth++;
+ enclosingType = enclosingType.enclosingType();
+ }
+ enclosingType = referenceBinding;
+ ReferenceBinding enclosingTypes[];
+ if (depth >= 2) {
+ enclosingTypes = new ReferenceBinding[depth];
+ for (int i = depth - 1; i >= 0; i--) {
+ enclosingTypes[i] = enclosingType;
enclosingType = enclosingType.enclosingType();
}
- enclosingType = referenceBinding;
- ReferenceBinding enclosingTypes[];
- if (depth >= 2) {
- enclosingTypes = new ReferenceBinding[depth];
- for (int i = depth - 1; i >= 0; i--) {
- enclosingTypes[i] = enclosingType;
- enclosingType = enclosingType.enclosingType();
- }
- for (int i = 0; i < depth; i++) {
- addInnerClasses(enclosingTypes[i]);
- }
- } else {
- addInnerClasses(referenceBinding);
+ for (int i = 0; i < depth; i++) {
+ addInnerClasses(enclosingTypes[i]);
}
+ } else {
+ addInnerClasses(referenceBinding);
}
-
- /**
- * INTERNAL USE-ONLY
- * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
- * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
- *
- * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
- */
- public void recordNestedLocalAttribute(ReferenceBinding binding) {
- // add all the enclosing types
- ReferenceBinding enclosingType = referenceBinding.enclosingType();
- int depth = 0;
- while (enclosingType != null) {
- depth++;
+}
+/**
+ * INTERNAL USE-ONLY
+ * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
+ * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
+ *
+ * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
+ */
+public void recordNestedLocalAttribute(ReferenceBinding binding) {
+ // add all the enclosing types
+ ReferenceBinding enclosingType = referenceBinding.enclosingType();
+ int depth = 0;
+ while (enclosingType != null) {
+ depth++;
+ enclosingType = enclosingType.enclosingType();
+ }
+ enclosingType = referenceBinding;
+ ReferenceBinding enclosingTypes[];
+ if (depth >= 2) {
+ enclosingTypes = new ReferenceBinding[depth];
+ for (int i = depth - 1; i >= 0; i--) {
+ enclosingTypes[i] = enclosingType;
enclosingType = enclosingType.enclosingType();
}
- enclosingType = referenceBinding;
- ReferenceBinding enclosingTypes[];
- if (depth >= 2) {
- enclosingTypes = new ReferenceBinding[depth];
- for (int i = depth - 1; i >= 0; i--) {
- enclosingTypes[i] = enclosingType;
- enclosingType = enclosingType.enclosingType();
- }
- for (int i = 0; i < depth; i++)
- addInnerClasses(enclosingTypes[i]);
- } else {
- addInnerClasses(binding);
- }
- }
-
- /**
- * INTERNAL USE-ONLY
- * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
- * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
- *
- * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
- */
- public void recordNestedMemberAttribute(ReferenceBinding binding) {
+ for (int i = 0; i < depth; i++)
+ addInnerClasses(enclosingTypes[i]);
+ } else {
addInnerClasses(binding);
}
-
- /**
- * INTERNAL USE-ONLY
- * Search the line number corresponding to a specific position
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
- */
- public static final int searchLineNumber(
- int[] startLineIndexes,
- int position) {
- // this code is completely useless, but it is the same implementation than
- // org.eclipse.jdt.internal.compiler.problem.ProblemHandler.searchLineNumber(int[], int)
- // if (startLineIndexes == null)
- // return 1;
- int length = startLineIndexes.length;
- if (length == 0)
- return 1;
- int g = 0, d = length - 1;
- int m = 0;
- while (g <= d) {
- m = (g + d) / 2;
- if (position < startLineIndexes[m]) {
- d = m - 1;
- } else
- if (position > startLineIndexes[m]) {
- g = m + 1;
- } else {
- return m + 1;
- }
- }
+}
+/**
+ * INTERNAL USE-ONLY
+ * This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
+ * collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
+ *
+ * @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
+ */
+public void recordNestedMemberAttribute(ReferenceBinding binding) {
+ addInnerClasses(binding);
+}
+/**
+ * INTERNAL USE-ONLY
+ * Search the line number corresponding to a specific position
+ *
+ * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
+ */
+public static final int searchLineNumber(int[] startLineIndexes, int position) {
+ // this code is completely useless, but it is the same implementation than
+ // org.eclipse.jdt.internal.compiler.problem.ProblemHandler.searchLineNumber(int[], int)
+ // if (startLineIndexes == null)
+ // return 1;
+ int length = startLineIndexes.length;
+ if (length == 0)
+ return 1;
+ int g = 0, d = length - 1;
+ int m = 0;
+ while (g <= d) {
+ m = (g + d) /2;
if (position < startLineIndexes[m]) {
+ d = m-1;
+ } else if (position > startLineIndexes[m]) {
+ g = m+1;
+ } else {
return m + 1;
}
- return m + 2;
}
-
- /**
- * INTERNAL USE-ONLY
- * This methods leaves the space for method counts recording.
- */
- public void setForMethodInfos() {
- // leave some space for the methodCount
- methodCountOffset = contentsOffset;
- contentsOffset += 2;
+ if (position < startLineIndexes[m]) {
+ return m+1;
}
-
- /**
- * INTERNAL USE-ONLY
- * outputPath is formed like:
- * c:\temp\ the last character is a file separator
- * relativeFileName is formed like:
- * java\lang\String.class
- * @param fileName java.lang.String
- * @param content byte[]
- */
- public static void writeToDisk(
- String outputPath,
- String relativeFileName,
- byte[] contents)
- throws IOException {
- String fileName;
- File file;
- FileOutputStream output =
- new FileOutputStream(
- file =
- new File((fileName = buildAllDirectoriesInto(outputPath, relativeFileName))));
- output.write(contents);
- output.flush();
- output.close();
- }
-} \ No newline at end of file
+ return m+2;
+}
+/**
+ * INTERNAL USE-ONLY
+ * This methods leaves the space for method counts recording.
+ */
+public void setForMethodInfos() {
+ // leave some space for the methodCount
+ methodCountOffset = contentsOffset;
+ contentsOffset += 2;
+}
+/**
+ * INTERNAL USE-ONLY
+ * outputPath is formed like:
+ * c:\temp\ the last character is a file separator
+ * relativeFileName is formed like:
+ * java\lang\String.class
+ * @param fileName java.lang.String
+ * @param content byte[]
+ */
+public static void writeToDisk(String outputPath, String relativeFileName, byte[] contents) throws IOException {
+ String fileName;
+ File file;
+ FileOutputStream output = new FileOutputStream(file = new File((fileName = buildAllDirectoriesInto(outputPath, relativeFileName))));
+ output.write(contents);
+ output.flush();
+ output.close();
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
index 7c708fc669..f7cf45edfe 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -18,11 +18,11 @@ import java.io.*;
import java.util.*;
public class Compiler implements ITypeRequestor, ProblemSeverities {
- public Parser parser;
+ public Parser parser;
ICompilerRequestor requestor;
public CompilerOptions options;
public ProblemReporter problemReporter;
-
+
// management of unit to be processed
//public CompilationUnitResult currentCompilationUnitResult;
CompilationUnitDeclaration[] unitsToProcess;
@@ -32,481 +32,407 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
public LookupEnvironment lookupEnvironment;
// ONCE STABILIZED, THESE SHOULD RETURN TO A FINAL FIELD
- public static final boolean DEBUG = false;
- public int parseThreshold = -1;
- // number of initial units parsed at once (-1: none)
- /**
- * Answer a new compiler using the given name environment and compiler options.
- * The environment and options will be in effect for the lifetime of the compiler.
- * When the compiler is run, compilation results are sent to the given requestor.
- *
- * @param environment org.eclipse.jdt.internal.compiler.api.env.INameEnvironment
- * Environment used by the compiler in order to resolve type and package
- * names. The name environment implements the actual connection of the compiler
- * to the outside world (e.g. in batch mode the name environment is performing
- * pure file accesses, reuse previous build state or connection to repositories).
- * Note: the name environment is responsible for implementing the actual classpath
- * rules.
- *
- * @param policy org.eclipse.jdt.internal.compiler.api.problem.IErrorHandlingPolicy
- * Configurable part for problem handling, allowing the compiler client to
- * specify the rules for handling problems (stop on first error or accumulate
- * them all) and at the same time perform some actions such as opening a dialog
- * in UI when compiling interactively.
- * @see org.eclipse.jdt.internal.compiler.api.problem.DefaultErrorHandlingPolicies
- *
- * @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
- * Component which will receive and persist all compilation results and is intended
- * to consume them as they are produced. Typically, in a batch compiler, it is
- * responsible for writing out the actual .class files to the file system.
- * @see org.eclipse.jdt.internal.compiler.api.CompilationResult
- *
- * @param problemFactory org.eclipse.jdt.internal.compiler.api.problem.IProblemFactory
- * Factory used inside the compiler to create problem descriptors. It allows the
- * compiler client to supply its own representation of compilation problems in
- * order to avoid object conversions. Note that the factory is not supposed
- * to accumulate the created problems, the compiler will gather them all and hand
- * them back as part of the compilation unit result.
- */
- public Compiler(
- INameEnvironment environment,
- IErrorHandlingPolicy policy,
- ConfigurableOption[] settings,
- ICompilerRequestor requestor,
- IProblemFactory problemFactory) {
-
- // create a problem handler given a handling policy
- this.options = new CompilerOptions(settings);
- this.requestor = requestor;
- this.problemReporter =
- new ProblemReporter(policy, this.options, problemFactory);
- this.lookupEnvironment =
- new LookupEnvironment(this, options, problemReporter, environment);
- this.parser =
- new Parser(
- problemReporter,
- this.options.parseLiteralExpressionsAsConstants,
- this.options.getAssertMode());
- }
-
- /**
- * Add an additional binary type
- */
- public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
- lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
+ public static final boolean DEBUG = false;
+ public int parseThreshold = -1; // number of initial units parsed at once (-1: none)
+/**
+ * Answer a new compiler using the given name environment and compiler options.
+ * The environment and options will be in effect for the lifetime of the compiler.
+ * When the compiler is run, compilation results are sent to the given requestor.
+ *
+ * @param environment org.eclipse.jdt.internal.compiler.api.env.INameEnvironment
+ * Environment used by the compiler in order to resolve type and package
+ * names. The name environment implements the actual connection of the compiler
+ * to the outside world (e.g. in batch mode the name environment is performing
+ * pure file accesses, reuse previous build state or connection to repositories).
+ * Note: the name environment is responsible for implementing the actual classpath
+ * rules.
+ *
+ * @param policy org.eclipse.jdt.internal.compiler.api.problem.IErrorHandlingPolicy
+ * Configurable part for problem handling, allowing the compiler client to
+ * specify the rules for handling problems (stop on first error or accumulate
+ * them all) and at the same time perform some actions such as opening a dialog
+ * in UI when compiling interactively.
+ * @see org.eclipse.jdt.internal.compiler.api.problem.DefaultErrorHandlingPolicies
+ *
+ * @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
+ * Component which will receive and persist all compilation results and is intended
+ * to consume them as they are produced. Typically, in a batch compiler, it is
+ * responsible for writing out the actual .class files to the file system.
+ * @see org.eclipse.jdt.internal.compiler.api.CompilationResult
+ *
+ * @param problemFactory org.eclipse.jdt.internal.compiler.api.problem.IProblemFactory
+ * Factory used inside the compiler to create problem descriptors. It allows the
+ * compiler client to supply its own representation of compilation problems in
+ * order to avoid object conversions. Note that the factory is not supposed
+ * to accumulate the created problems, the compiler will gather them all and hand
+ * them back as part of the compilation unit result.
+ */
+public Compiler(
+ INameEnvironment environment,
+ IErrorHandlingPolicy policy,
+ ConfigurableOption[] settings,
+ ICompilerRequestor requestor,
+ IProblemFactory problemFactory) {
+
+ // create a problem handler given a handling policy
+ this.options = new CompilerOptions(settings);
+ this.requestor = requestor;
+ this.problemReporter =
+ new ProblemReporter(
+ policy,
+ this.options,
+ problemFactory);
+ this.lookupEnvironment = new LookupEnvironment(this, options, problemReporter, environment);
+ this.parser =
+ new Parser(problemReporter, this.options.parseLiteralExpressionsAsConstants);
+}
+/**
+ * Add an additional binary type
+ */
+
+public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
+ lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
+}
+/**
+ * Add an additional compilation unit into the loop
+ * -> build compilation unit declarations, their bindings and record their results.
+ */
+
+public void accept(ICompilationUnit sourceUnit) {
+ // Switch the current policy and compilation result for this unit to the requested one.
+ CompilationResult unitResult =
+ new CompilationResult(sourceUnit, totalUnits, totalUnits);
+ try {
+ // diet parsing for large collection of unit
+ CompilationUnitDeclaration parsedUnit;
+ if (totalUnits < parseThreshold) {
+ parsedUnit = parser.parse(sourceUnit, unitResult);
+ } else {
+ parsedUnit = parser.dietParse(sourceUnit, unitResult);
+ }
+
+ if (options.verbose) {
+ System.out.println(Util.bind("compilation.request"/*nonNLS*/,new String[]{String.valueOf(totalUnits + 1),String.valueOf(totalUnits + 1),new String(sourceUnit.getFileName())}));
+ }
+
+ // initial type binding creation
+ lookupEnvironment.buildTypeBindings(parsedUnit);
+ this.addCompilationUnit(sourceUnit, parsedUnit);
+
+ // binding resolution
+ lookupEnvironment.completeTypeBindings(parsedUnit);
+ } catch (AbortCompilationUnit e) {
+ // at this point, currentCompilationUnitResult may not be sourceUnit, but some other
+ // one requested further along to resolve sourceUnit.
+ if (unitResult.compilationUnit == sourceUnit) { // only report once
+ requestor.acceptResult(unitResult.tagAsAccepted());
+ } else {
+ throw e; // want to abort enclosing request to compile
+ }
}
+}
+/**
+ * Add an additional source type
+ */
- /**
- * Add an additional compilation unit into the loop
- * -> build compilation unit declarations, their bindings and record their results.
- */
- public void accept(ICompilationUnit sourceUnit) {
- // Switch the current policy and compilation result for this unit to the requested one.
- CompilationResult unitResult =
- new CompilationResult(sourceUnit, totalUnits, totalUnits);
+public void accept(ISourceType sourceType, PackageBinding packageBinding) {
+ problemReporter.abortDueToInternalError(Util.bind("abort.againstSourceModel "/*nonNLS*/,String.valueOf(sourceType.getName()),String.valueOf(sourceType.getFileName())));
+}
+protected void addCompilationUnit(ICompilationUnit sourceUnit, CompilationUnitDeclaration parsedUnit) {
+
+ // append the unit to the list of ones to process later on
+ int size = unitsToProcess.length;
+ if (totalUnits == size) // when growing reposition units starting at position 0
+ System.arraycopy(unitsToProcess, 0, (unitsToProcess = new CompilationUnitDeclaration[size * 2]), 0, totalUnits);
+ unitsToProcess[totalUnits++] = parsedUnit;
+}
+/**
+ * Add the initial set of compilation units into the loop
+ * -> build compilation unit declarations, their bindings and record their results.
+ */
+protected void beginToCompile(ICompilationUnit[] sourceUnits) {
+ int maxUnits = sourceUnits.length;
+ totalUnits = 0;
+ unitsToProcess = new CompilationUnitDeclaration[maxUnits];
+
+ // Switch the current policy and compilation result for this unit to the requested one.
+ for (int i = 0; i < maxUnits; i++) {
+ CompilationUnitDeclaration parsedUnit;
+ CompilationResult unitResult = new CompilationResult(sourceUnits[i], i, maxUnits);
try {
- // diet parsing for large collection of unit
- CompilationUnitDeclaration parsedUnit;
- if (totalUnits < parseThreshold) {
- parsedUnit = parser.parse(sourceUnit, unitResult);
- } else {
- parsedUnit = parser.dietParse(sourceUnit, unitResult);
- }
-
+ // diet parsing for large collection of units
+ if (totalUnits < parseThreshold)
+ { parsedUnit = parser.parse(sourceUnits[i], unitResult);}
+ else
+ { parsedUnit = parser.dietParse(sourceUnits[i], unitResult);}
if (options.verbose) {
- System.out.println(
- Util.bind(
- "compilation.request" , //$NON-NLS-1$
- new String[] {
- String.valueOf(totalUnits + 1),
- String.valueOf(totalUnits + 1),
- new String(sourceUnit.getFileName())}));
+ System.out.println(Util.bind("compilation.request"/*nonNLS*/,new String[]{String.valueOf(i+1),String.valueOf(maxUnits),new String(sourceUnits[i].getFileName())}));
}
-
// initial type binding creation
lookupEnvironment.buildTypeBindings(parsedUnit);
- this.addCompilationUnit(sourceUnit, parsedUnit);
-
- // binding resolution
- lookupEnvironment.completeTypeBindings(parsedUnit);
- } catch (AbortCompilationUnit e) {
- // at this point, currentCompilationUnitResult may not be sourceUnit, but some other
- // one requested further along to resolve sourceUnit.
- if (unitResult.compilationUnit == sourceUnit) { // only report once
- requestor.acceptResult(unitResult.tagAsAccepted());
- } else {
- throw e; // want to abort enclosing request to compile
- }
+ this.addCompilationUnit(sourceUnits[i], parsedUnit);
+ //} catch (AbortCompilationUnit e) {
+ // requestor.acceptResult(unitResult.tagAsAccepted());
+ } finally {
+ sourceUnits[i] = null; // no longer hold onto the unit
}
}
+ // binding resolution
+ lookupEnvironment.completeTypeBindings();
+}
+/**
+ * General API
+ * -> compile each of supplied files
+ * -> recompile any required types for which we have an incomplete principle structure
+ */
- /**
- * Add additional source types
- */
- public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
- problemReporter.abortDueToInternalError(
- Util.bind(
- "abort.againstSourceModel " , //$NON-NLS-1$
- String.valueOf(sourceTypes[0].getName()),
- String.valueOf(sourceTypes[0].getFileName())));
- }
+public void compile(ICompilationUnit[] sourceUnits) {
+ CompilationUnitDeclaration unit = null;
+ int i = 0;
+ try {
+ // build and record parsed units
- protected void addCompilationUnit(
- ICompilationUnit sourceUnit,
- CompilationUnitDeclaration parsedUnit) {
-
- // append the unit to the list of ones to process later on
- int size = unitsToProcess.length;
- if (totalUnits == size)
- // when growing reposition units starting at position 0
- System.arraycopy(
- unitsToProcess,
- 0,
- (unitsToProcess = new CompilationUnitDeclaration[size * 2]),
- 0,
- totalUnits);
- unitsToProcess[totalUnits++] = parsedUnit;
- }
+ beginToCompile(sourceUnits);
- /**
- * Add the initial set of compilation units into the loop
- * -> build compilation unit declarations, their bindings and record their results.
- */
- protected void beginToCompile(ICompilationUnit[] sourceUnits) {
- int maxUnits = sourceUnits.length;
- totalUnits = 0;
- unitsToProcess = new CompilationUnitDeclaration[maxUnits];
-
- // Switch the current policy and compilation result for this unit to the requested one.
- for (int i = 0; i < maxUnits; i++) {
- CompilationUnitDeclaration parsedUnit;
- CompilationResult unitResult =
- new CompilationResult(sourceUnits[i], i, maxUnits);
+ // process all units (some more could be injected in the loop by the lookup environment)
+ for (; i < totalUnits; i++) {
+ unit = unitsToProcess[i];
try {
- // diet parsing for large collection of units
- if (totalUnits < parseThreshold) {
- parsedUnit = parser.parse(sourceUnits[i], unitResult);
- } else {
- parsedUnit = parser.dietParse(sourceUnits[i], unitResult);
- }
- if (options.verbose) {
- System.out.println(
- Util.bind(
- "compilation.request" , //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(maxUnits),
- new String(sourceUnits[i].getFileName())}));
- }
- // initial type binding creation
- lookupEnvironment.buildTypeBindings(parsedUnit);
- this.addCompilationUnit(sourceUnits[i], parsedUnit);
- //} catch (AbortCompilationUnit e) {
- // requestor.acceptResult(unitResult.tagAsAccepted());
+ if (options.verbose) System.out.println(Util.bind("compilation.process"/*nonNLS*/,new String[]{String.valueOf(i + 1),String.valueOf(totalUnits),new String(unitsToProcess[i].getFileName())}));
+ process(unit, i);
} finally {
- sourceUnits[i] = null; // no longer hold onto the unit
+ // cleanup compilation unit result
+ unit.cleanUp();
+ if (options.verbose)
+ System.out.println(Util.bind("compilation.done"/*nonNLS*/,new String[]{String.valueOf(i + 1),String.valueOf(totalUnits),new String(unitsToProcess[i].getFileName())}));
}
+ unitsToProcess[i] = null; // release reference to processed unit declaration
+ requestor.acceptResult(unit.compilationResult.tagAsAccepted());
}
- // binding resolution
- lookupEnvironment.completeTypeBindings();
+ } catch (AbortCompilation e) {
+ this.handleInternalException(e, unit);
+ } catch (Error e) {
+ this.handleInternalException(e, unit, null);
+ throw e; // rethrow
+ } catch (RuntimeException e) {
+ this.handleInternalException(e, unit, null);
+ throw e; // rethrow
+ } finally {
+ this.reset();
}
-
- /**
- * General API
- * -> compile each of supplied files
- * -> recompile any required types for which we have an incomplete principle structure
- */
- public void compile(ICompilationUnit[] sourceUnits) {
- CompilationUnitDeclaration unit = null;
- int i = 0;
- try {
- // build and record parsed units
-
- beginToCompile(sourceUnits);
-
- // process all units (some more could be injected in the loop by the lookup environment)
- for (; i < totalUnits; i++) {
- unit = unitsToProcess[i];
- try {
- if (options.verbose)
- System.out.println(
- Util.bind(
- "compilation.process" , //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(totalUnits),
- new String(unitsToProcess[i].getFileName())}));
- process(unit, i);
- } finally {
- // cleanup compilation unit result
- unit.cleanUp();
- if (options.verbose)
- System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(totalUnits),
- new String(unitsToProcess[i].getFileName())}));
- }
- unitsToProcess[i] = null; // release reference to processed unit declaration
- requestor.acceptResult(unit.compilationResult.tagAsAccepted());
- }
- } catch (AbortCompilation e) {
- this.handleInternalException(e, unit);
- } catch (Error e) {
- this.handleInternalException(e, unit, null);
- throw e; // rethrow
- } catch (RuntimeException e) {
- this.handleInternalException(e, unit, null);
- throw e; // rethrow
- } finally {
- this.reset();
- }
- if (options.verbose) {
- if (totalUnits > 1) {
- System.out.println(
- Util.bind("compilation.units" , String.valueOf(totalUnits))); //$NON-NLS-1$
- } else {
- System.out.println(
- Util.bind("compilation.unit" , String.valueOf(totalUnits))); //$NON-NLS-1$
- }
+ if (options.verbose) {
+ if (totalUnits > 1) {
+ System.out.println(Util.bind("compilation.units"/*nonNLS*/,String.valueOf(totalUnits)));
+ } else {
+ System.out.println(Util.bind("compilation.unit"/*nonNLS*/,String.valueOf(totalUnits)));
}
}
+}
+/**
+ * Answer an array of descriptions for the configurable options.
+ * The descriptions may be changed and passed back to a different
+ * compiler.
+ *
+ * @return ConfigurableOption[] - array of configurable options
+ */
+public static ConfigurableOption[] getDefaultOptions(Locale locale) {
+ return new CompilerOptions().getConfigurableOptions(locale);
+}
+protected void getMethodBodies(CompilationUnitDeclaration unit, int place) {
+ //fill the methods bodies in order for the code to be generated
+
+ if (unit.ignoreMethodBodies) {
+ unit.ignoreFurtherInvestigation = true;
+ return; // if initial diet parse did not work, no need to dig into method bodies.
+ }
+
+ if (place < parseThreshold)
+ return; //work already done ...
+
+ //real parse of the method....
+ parser.scanner.setSourceBuffer(unit.compilationResult.compilationUnit.getContents());
+ if (unit.types != null) {
+ for (int i = unit.types.length; --i >= 0;)
+ unit.types[i].parseMethod(parser, unit);
+ }
+}
+/*
+ * Compiler crash recovery in case of unexpected runtime exceptions
+ */
+protected void handleInternalException(Throwable internalException, CompilationUnitDeclaration unit, CompilationResult result) {
- protected void getMethodBodies(CompilationUnitDeclaration unit, int place) {
- //fill the methods bodies in order for the code to be generated
-
- if (unit.ignoreMethodBodies) {
- unit.ignoreFurtherInvestigation = true;
- return;
- // if initial diet parse did not work, no need to dig into method bodies.
- }
-
- if (place < parseThreshold)
- return; //work already done ...
+ /* dump a stack trace to the console */
+ internalException.printStackTrace();
+
+ /* find a compilation result */
+ if ((unit != null)) // basing result upon the current unit if available
+ result = unit.compilationResult; // current unit being processed ?
+ if ((result == null) && (unitsToProcess != null) && (totalUnits > 0))
+ result = unitsToProcess[totalUnits - 1].compilationResult; // last unit in beginToCompile ?
+
+ if (result != null) {
+ /* create and record a compilation problem */
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter writer = new PrintWriter(stringWriter);
+ internalException.printStackTrace(writer);
+ StringBuffer buffer = stringWriter.getBuffer();
+
+ result.record(
+ problemReporter.createProblem(
+ result.getFileName(),
+ ProblemIrritants.UnclassifiedProblem,
+ new String[] {Util.bind("compilation.internalError"/*nonNLS*/)+"\n"/*nonNLS*/ + buffer.toString()},
+ Error, // severity
+ 0, // source start
+ 0, // source end
+ 0)); // line number
- //real parse of the method....
- parser.scanner.setSourceBuffer(
- unit.compilationResult.compilationUnit.getContents());
- if (unit.types != null) {
- for (int i = unit.types.length; --i >= 0;)
- unit.types[i].parseMethod(parser, unit);
+ /* hand back the compilation result */
+ if (!result.hasBeenAccepted) {
+ requestor.acceptResult(result.tagAsAccepted());
}
}
+}
+/*
+ * Compiler recovery in case of internal AbortCompilation event
+ */
+protected void handleInternalException(AbortCompilation abortException, CompilationUnitDeclaration unit){
- /*
- * Compiler crash recovery in case of unexpected runtime exceptions
- */
- protected void handleInternalException(
- Throwable internalException,
- CompilationUnitDeclaration unit,
- CompilationResult result) {
-
- /* dump a stack trace to the console */
- internalException.printStackTrace();
-
- /* find a compilation result */
- if ((unit != null)) // basing result upon the current unit if available
- result = unit.compilationResult; // current unit being processed ?
- if ((result == null) && (unitsToProcess != null) && (totalUnits > 0))
- result = unitsToProcess[totalUnits - 1].compilationResult;
- // last unit in beginToCompile ?
-
- if (result != null) {
- /* create and record a compilation problem */
- StringWriter stringWriter = new StringWriter();
- PrintWriter writer = new PrintWriter(stringWriter);
- internalException.printStackTrace(writer);
- StringBuffer buffer = stringWriter.getBuffer();
-
- result
- .record(
- problemReporter
- .createProblem(
- result.getFileName(),
- ProblemIrritants.UnclassifiedProblem,
- new String[] {
- Util.bind("compilation.internalError" ) //$NON-NLS-1$
- + "\n" //$NON-NLS-1$
- + buffer.toString()},
- Error,
- // severity
- 0, // source start
- 0, // source end
- 0)); // line number
-
- /* hand back the compilation result */
- if (!result.hasBeenAccepted) {
- requestor.acceptResult(result.tagAsAccepted());
- }
+ /* special treatment for SilentAbort: silently cancelling the compilation process */
+ if (abortException.isSilent){
+ if (abortException.silentException == null) {
+ return;
+ } else {
+ throw abortException.silentException;
}
}
-
- /*
- * Compiler recovery in case of internal AbortCompilation event
- */
- protected void handleInternalException(
- AbortCompilation abortException,
- CompilationUnitDeclaration unit) {
-
- /* special treatment for SilentAbort: silently cancelling the compilation process */
- if (abortException.isSilent) {
- if (abortException.silentException == null) {
+
+ /* uncomment following line to see where the abort came from */
+ // abortException.printStackTrace();
+
+ // Exception may tell which compilation result it is related, and which problem caused it
+ CompilationResult result = abortException.compilationResult;
+ if ((result == null) && (unit != null)) result = unit.compilationResult; // current unit being processed ?
+ if ((result == null) && (unitsToProcess != null) && (totalUnits > 0)) result = unitsToProcess[totalUnits - 1].compilationResult; // last unit in beginToCompile ?
+ if (result != null && !result.hasBeenAccepted){
+ /* distant problem which could not be reported back there */
+ if (abortException.problemId != 0){
+ result.record(
+ problemReporter.createProblem(
+ result.getFileName(),
+ abortException.problemId,
+ abortException.problemArguments,
+ Error, // severity
+ 0, // source start
+ 0, // source end
+ 0)); // line number
+ } else {
+ /* distant internal exception which could not be reported back there */
+ if (abortException.exception != null){
+ this.handleInternalException(abortException.exception, null, result);
return;
- } else {
- throw abortException.silentException;
}
}
-
- /* uncomment following line to see where the abort came from */
- // abortException.printStackTrace();
-
- // Exception may tell which compilation result it is related, and which problem caused it
- CompilationResult result = abortException.compilationResult;
- if ((result == null) && (unit != null))
- result = unit.compilationResult; // current unit being processed ?
- if ((result == null) && (unitsToProcess != null) && (totalUnits > 0))
- result = unitsToProcess[totalUnits - 1].compilationResult;
- // last unit in beginToCompile ?
- if (result != null && !result.hasBeenAccepted) {
- /* distant problem which could not be reported back there */
- if (abortException.problemId != 0) {
- result
- .record(
- problemReporter
- .createProblem(
- result.getFileName(),
- abortException.problemId,
- abortException.problemArguments,
- Error,
- // severity
- 0, // source start
- 0, // source end
- 0)); // line number
- } else {
- /* distant internal exception which could not be reported back there */
- if (abortException.exception != null) {
- this.handleInternalException(abortException.exception, null, result);
- return;
- }
- }
- /* hand back the compilation result */
- if (!result.hasBeenAccepted) {
- requestor.acceptResult(result.tagAsAccepted());
- }
- } else {
- /*
- if (abortException.problemId != 0){
- IProblem problem =
- problemReporter.createProblem(
- "???".toCharArray(),
- abortException.problemId,
- abortException.problemArguments,
- Error, // severity
- 0, // source start
- 0, // source end
- 0); // line number
- System.out.println(problem.getMessage());
- }
- */
- abortException.printStackTrace();
+ /* hand back the compilation result */
+ if (!result.hasBeenAccepted) {
+ requestor.acceptResult(result.tagAsAccepted());
}
+ } else {
+ /*
+ if (abortException.problemId != 0){
+ IProblem problem =
+ problemReporter.createProblem(
+ "???".toCharArray(),
+ abortException.problemId,
+ abortException.problemArguments,
+ Error, // severity
+ 0, // source start
+ 0, // source end
+ 0); // line number
+ System.out.println(problem.getMessage());
+ }
+ */
+ abortException.printStackTrace();
}
+}
+/**
+ * Process a compilation unit already parsed and build.
+ */
+private void process(CompilationUnitDeclaration unit,int i) {
+
+ getMethodBodies(unit,i);
+
+ // fault in fields & methods
+ if (unit.scope != null)
+ unit.scope.faultInTypes();
+
+ // verify inherited methods
+ if (unit.scope != null)
+ unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
+
+ // type checking
+ long startTime = System.currentTimeMillis();
+ unit.resolve();
+
+ // flow analysis
+ startTime = System.currentTimeMillis();
+ unit.analyseCode();
+
+ // code generation
+ startTime = System.currentTimeMillis();
+ unit.generateCode();
+
+ // reference info
+ if (options.produceReferenceInfo && unit.scope != null)
+ unit.scope.storeDependencyInfo();
+
+ // refresh the total number of units known at this stage
+ unit.compilationResult.totalUnitsKnown = totalUnits;
+}
+public void reset(){
+ lookupEnvironment.reset();
+ parser.scanner.source = null;
+ unitsToProcess = null;
+}
+/**
+ * Internal API used to resolve a compilation unit minimally for code assist engine
+ */
- /**
- * Process a compilation unit already parsed and build.
- */
- private void process(CompilationUnitDeclaration unit, int i) {
-
- getMethodBodies(unit, i);
-
- // fault in fields & methods
- if (unit.scope != null)
+public CompilationUnitDeclaration resolve(ICompilationUnit sourceUnit) {
+ CompilationUnitDeclaration unit = null;
+ try {
+ // build and record parsed units
+ parseThreshold = 1; // will request a full parse
+ beginToCompile(new ICompilationUnit[] { sourceUnit });
+ // process all units (some more could be injected in the loop by the lookup environment)
+ unit = unitsToProcess[0];
+ //getMethodBodies(unit,i);
+ if (unit.scope != null) {
+ // fault in fields & methods
unit.scope.faultInTypes();
-
- // verify inherited methods
- if (unit.scope != null)
- unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
-
- // type checking
- long startTime = System.currentTimeMillis();
- unit.resolve();
-
- // flow analysis
- startTime = System.currentTimeMillis();
- unit.analyseCode();
-
- // code generation
- startTime = System.currentTimeMillis();
- unit.generateCode();
-
- // reference info
- if (options.produceReferenceInfo && unit.scope != null)
- unit.scope.storeDependencyInfo();
-
- // refresh the total number of units known at this stage
- unit.compilationResult.totalUnitsKnown = totalUnits;
- }
- public void reset() {
- lookupEnvironment.reset();
- parser.scanner.source = null;
- unitsToProcess = null;
- }
-
- /**
- * Internal API used to resolve a compilation unit minimally for code assist engine
- */
- public CompilationUnitDeclaration resolve(ICompilationUnit sourceUnit) {
- CompilationUnitDeclaration unit = null;
- try {
- // build and record parsed units
- parseThreshold = 1; // will request a full parse
- beginToCompile(new ICompilationUnit[] { sourceUnit });
- // process all units (some more could be injected in the loop by the lookup environment)
- unit = unitsToProcess[0];
- //getMethodBodies(unit,i);
- if (unit.scope != null) {
- // fault in fields & methods
- unit.scope.faultInTypes();
- // type checking
- unit.resolve();
- }
- unitsToProcess[0] = null; // release reference to processed unit declaration
- requestor.acceptResult(unit.compilationResult.tagAsAccepted());
- return unit;
- } catch (AbortCompilation e) {
- this.handleInternalException(e, unit);
- return unit == null ? unitsToProcess[0] : unit;
- } catch (Error e) {
- this.handleInternalException(e, unit, null);
- throw e; // rethrow
- } catch (RuntimeException e) {
- this.handleInternalException(e, unit, null);
- throw e; // rethrow
- } finally {
- // No reset is performed there anymore since,
- // within the CodeAssist (or related tools),
- // the compiler may be called *after* a call
- // to this resolve(...) method. And such a call
- // needs to have a compiler with a non-empty
- // environment.
- // this.reset();
+ // type checking
+ unit.resolve();
}
+ unitsToProcess[0] = null; // release reference to processed unit declaration
+ requestor.acceptResult(unit.compilationResult.tagAsAccepted());
+ return unit;
+ } catch (AbortCompilation e) {
+ this.handleInternalException(e, unit);
+ return unit == null ? unitsToProcess[0] : unit;
+ } catch (Error e) {
+ this.handleInternalException(e, unit, null);
+ throw e; // rethrow
+ } catch (RuntimeException e) {
+ this.handleInternalException(e, unit, null);
+ throw e; // rethrow
+ } finally {
+ // No reset is performed there anymore since,
+ // within the CodeAssist (or related tools),
+ // the compiler may be called *after* a call
+ // to this resolve(...) method. And such a call
+ // needs to have a compiler with a non-empty
+ // environment.
+ // this.reset();
}
-
- /**
- * Returns all the options of the compiler to be shown by the UI
- *
- * @param locale java.util.Locale
- * @return org.eclipse.jdt.internal.compiler.ConfigurableOption[]
- */
- public static ConfigurableOption[] getDefaultOptions(Locale locale) {
- String[] ids = ConfigurableOption.getIDs(Compiler.class.getName(),locale);
-
- ConfigurableOption[] result = new ConfigurableOption[ids.length];
- for(int i = 0 ; i < ids.length ; i++){
- result[i] = new ConfigurableOption(ids[i],locale);
- }
-
- return result;
- }
-} \ No newline at end of file
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
index 632250ac5d..6a88d97064 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
@@ -7,502 +7,206 @@ package org.eclipse.jdt.internal.compiler;
/**
* Generic option description, which can be modified independently from the
* component it belongs to.
- *
- * File to modify when adding an option :
- * Add option in option file of component
- * Modify setOption method of component option class
- *
- * Option file syntax
- * <code>
- * com.foo.Bar.optionOne.category=Category One
- * com.foo.Bar.optionOne.name=Option One
- * com.foo.Bar.optionOne.possibleValues=2|Value 1|Value 2
- * com.foo.Bar.optionOne.description=Description of Option One
- * com.foo.Bar.optionOne.default=0
- *
- * com.foo.Bar.optionTwo.category=Category One
- * com.foo.Bar.optionTwo.name=Option Two
- * com.foo.Bar.optionTwo.possibleValues=-1|string
- * com.foo.Bar.optionTwo.description=Description of Option Two
- * com.foo.Bar.optionTwo.default=Value
- *
- * com.foo.Bar.optionThree.category=Category Two
- * com.foo.Bar.optionThree.name=Option Three
- * com.foo.Bar.optionThree.possibleValues=-1|int|0|no
- * com.foo.Bar.optionThree.description=Description of Option Three
- * com.foo.Bar.optionThree.default=4
- * </code>
- *
- * possibleValues values :
- * - A positive number and the list of the value
- * - Value -1 following by type. If type is a number
- * there is min and max value (with value no if there is no max or min
- *
- * e.g.
- * 2|Value 1|Value 2
- * 3|Value 1|Value 2|Value 3
- * -1|string
- * -1|int|0|20
- * -1|int|no|20
- * -1|int|-10|no
- * -1|int|no|no
- * -1|int
- * -1|float|0.0|20.0
- * -1|float|no|20.0
- * -1|float|-10.0|no
- * -1|float|no|no
- * -1|float
- *
*/
+
import java.util.*;
public class ConfigurableOption {
- public final static String STRING = "string"; //$NON-NLS-1$
- public final static String INT = "int"; //$NON-NLS-1$
- public final static String FLOAT = "float"; //$NON-NLS-1$
- public final static String DISCRETE = "discrete"; //$NON-NLS-1$
-
- // special value for <possibleValues> indicating that
- // the <currentValueIndex> is the actual value
- public final static String[] NoDiscreteValue = {};
+ private String componentName;
+ private int id;
- private String id;
- private String value;
- private int valueIndex = -1;
- private String defaultValue;
- private int defaultValueIndex = -1;
private String category;
private String name;
private String description;
+ private int currentValueIndex;
+ private int defaultValueIndex;
private String[] possibleValues;
- private int order;
-
- private String type;
- private boolean maxExisting = false;
- private boolean minExisting = false;
- private int maxInt;
- private int minInt;
- private float maxFloat;
- private float minFloat;
-
-
- private Locale loc;
-
- private String componentName;
- private String missing;
-
- public ConfigurableOption(String id, Locale loc) {
- this.id = id;
- this.value = value;
- this.loc = loc;
- this.componentName = id.substring(0,id.lastIndexOf('.'));
-
- ResourceBundle bundle = null;
- missing = "Missing ressources entries for" + componentName + " options"; //$NON-NLS-2$ //$NON-NLS-1$
- try {
- bundle = ResourceBundle.getBundle(componentName,loc);
- } catch (MissingResourceException e) {
- id = missing;
- defaultValue = missing;
- category = missing;
- name = missing;
- description = missing;
- possibleValues = NoDiscreteValue;
- }
- if (bundle == null) return;
- try{
- StringTokenizer tokenizer =
- new StringTokenizer(
- bundle.getString(id + ".possibleValues"), //$NON-NLS-1$
- "|"); //$NON-NLS-1$
- int numberOfValues = Integer.parseInt(tokenizer.nextToken());
- if (numberOfValues == -1) {
- // the possible value are not discrete
- possibleValues = NoDiscreteValue;
-
- String token = tokenizer.nextToken();
- type = token;
- if(token.equals(STRING)){
-
- }
- else if(token.equals(INT) && tokenizer.hasMoreTokens()){
- token = tokenizer.nextToken();
- if(!token.equals("no")){ //$NON-NLS-1$
- minExisting = true;
- minInt = Integer.parseInt(token);
- }
- token = tokenizer.nextToken();
- if(!token.equals("no")){ //$NON-NLS-1$
- maxExisting = true;
- maxInt = Integer.parseInt(token);
- }
- }
- else if(token.equals(FLOAT) && tokenizer.hasMoreTokens()){
- token = tokenizer.nextToken();
- if(!token.equals("no")){ //$NON-NLS-1$
- minExisting = true;
- minFloat = Float.parseFloat(token);
- }
- token = tokenizer.nextToken();
- if(!token.equals("no")){ //$NON-NLS-1$
- maxExisting = true;
- maxFloat = Float.parseFloat(token);
- }
- }
- } else {
- // possible value are discrete
- type = DISCRETE;
- possibleValues = new String[numberOfValues];
- int index = 0;
- while (tokenizer.hasMoreTokens()) {
- possibleValues[index] = tokenizer.nextToken();
- index++;
- }
- }
-
- } catch (MissingResourceException e) {
- possibleValues = NoDiscreteValue;
- type = missing;
- } catch (NoSuchElementException e) {
- possibleValues = NoDiscreteValue;
- type = missing;
- } catch (NumberFormatException e) {
- possibleValues = NoDiscreteValue;
- type = missing;
- }
- try{
- if(possibleValues == NoDiscreteValue){
- defaultValue = bundle.getString(id + ".default"); //$NON-NLS-1$
- }
- else{
- defaultValueIndex = Integer.parseInt(bundle.getString(id + ".default")); //$NON-NLS-1$
- }
- } catch (MissingResourceException e) {
- defaultValue = missing;
- } catch (NumberFormatException e) {
- defaultValueIndex = -1;
- }
- try{
- order = Integer.parseInt(bundle.getString(id + ".order")); //$NON-NLS-1$
- } catch (NumberFormatException e) {
- order = -1;
- } catch (MissingResourceException e) {
- order = -1;
- }
- try{
- category = bundle.getString(id + ".category"); //$NON-NLS-1$
- } catch (MissingResourceException e) {
- category = missing;
- }
- try{
- name = bundle.getString(id + ".name"); //$NON-NLS-1$
- } catch (MissingResourceException e) {
- name = missing;
- }
- try{
- description = bundle.getString(id + ".description"); //$NON-NLS-1$
- } catch (MissingResourceException e) {
- description = missing;
- }
- }
-
- /**
- * Internal ID which allows the configurable component to identify this particular option.
- *
- * @return String
- */
- public String getID() {
- return id;
- }
-
- /**
- * Answer the value of the current setting for this particular option.
- *
- * @return String
- */
- public String getValue() {
- if(possibleValues == NoDiscreteValue){
- if (value == null)
- return getDefaultValue();
- return value;
- }
- else {
- if (valueIndex == -1)
- return getDefaultValue();
- return possibleValues[valueIndex];
- }
- }
-
- /**
- * Change the value of the current setting for this particular option.
- *
- * @param value String
- */
- public void setValue(String value) {
- if(possibleValues == NoDiscreteValue){
- this.value = value;
- }
- else{
- for(int i = 0 ; i < possibleValues.length ; i++){
- if(possibleValues[i].equals(value)){
- this.valueIndex = i;
- break;
- }
- }
- }
- }
-
- /**
- * Gets the valueIndex
- * @return Returns a int
- */
- public int getValueIndex() {
- if(possibleValues == NoDiscreteValue)
- return -1;
- if (valueIndex == -1)
- return getDefaultValueIndex();
- return valueIndex;
- }
- /**
- * Sets the valueIndex
- * @param valueIndex The valueIndex to set
- */
- public void setValueIndex(int valueIndex) {
- if(valueIndex < 0 || valueIndex >= possibleValues.length){
- this.valueIndex = -1;
- }
- else {
- this.valueIndex = valueIndex;
- }
- }
+ // special value for <possibleValues> indicating that
+ // the <currentValueIndex> is the actual value
+ public final static String[] NoDiscreteValue = {};
+/**
+ * INTERNAL USE ONLY
+ *
+ * Initialize an instance of this class according to a specific locale
+ *
+ * @param loc java.util.Locale
+ */
+public ConfigurableOption(
+ String componentName,
+ String optionName,
+ Locale loc,
+ int currentValueIndex) {
- /**
- * Answer the value of the default setting for this particular option.
- *
- * @return String
- */
- public String getDefaultValue() {
- if(possibleValues != NoDiscreteValue){
- if(defaultValueIndex == -1)
- return missing;
- return possibleValues[defaultValueIndex];
- }
- return defaultValue;
- }
-
- /**
- * Change the value of the default setting for this particular option.
- *
- * @param value String
- */
- public void setDefaultValue(String defaultValue) {
- if(possibleValues == NoDiscreteValue){
- this.defaultValue = defaultValue;
- }
- else{
- for(int i = 0 ; i < possibleValues.length ; i++){
- if(possibleValues[i].equals(defaultValue)){
- this.defaultValueIndex = i;
- break;
- }
- }
- }
- }
-
- public void setToDefault(){
- value = null;
- valueIndex = -1;
- }
-
- /**
- * Gets the defaultValueIndex
- * @return Returns a int
- */
- public int getDefaultValueIndex() {
- if(possibleValues == NoDiscreteValue)
- return -1;
+ this.componentName = componentName;
+ this.currentValueIndex = currentValueIndex;
- return defaultValueIndex;
- }
- /**
- * Sets the defaultValueIndex
- * @param defaultValueIndex The defaultValueIndex to set
- */
- public void setDefaultValueIndex(int defaultValueIndex) {
- if(defaultValueIndex < 0 || defaultValueIndex >= possibleValues.length){
- this.defaultValueIndex = -1;
- }
- else {
- this.defaultValueIndex = defaultValueIndex;
- }
- }
- /**
- * Return a String that represents the localized category of the receiver.
- * @return java.lang.String
- */
- public String getCategory() {
- return category;
- }
-
- /**
- * Return a String that represents the localized name of the receiver.
- * @return java.lang.String
- */
- public String getName() {
- return name;
- }
-
- /**
- * Return an String that represents the localized description of the receiver.
- *
- * @return java.lang.String
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Return an array of String that represents the localized possible values of the receiver.
- *
- * @return java.lang.String[]
- */
- public String[] getPossibleValues() {
- return possibleValues;
- }
-
- /**
- * Return a String that identifies the component owner (typically the qualified
- * type name of the class which it corresponds to).
- *
- * e.g. "org.eclipse.jdt.internal.compiler.api.Compiler"
- *
- * @return java.lang.String
- */
- public String getComponentName() {
- return componentName;
- }
-
- /**
- * Gets the type
- * @return Returns a int
- */
- public String getType() {
- return type;
- }
-
- /**
- * Gets the max
- * @return Returns a Number
- */
- public Number getMax() {
- if(possibleValues == NoDiscreteValue){
- if(type.equals(INT)){
- if(maxExisting){
- return new Integer(maxInt);
- }
- else {
- return new Integer(Integer.MAX_VALUE);
- }
- }
- else if(type.equals(FLOAT)){
- if(maxExisting){
- return new Float(maxFloat);
- }
- else {
- return new Float(Float.MAX_VALUE);
- }
+ ResourceBundle resource = null;
+ try {
+ String location = componentName.substring(0, componentName.lastIndexOf('.'));
+ resource = ResourceBundle.getBundle(location + ".Options"/*nonNLS*/, loc);
+ } catch (MissingResourceException e) {
+ category = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
+ name = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
+ description = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
+ possibleValues = new String[0];
+ id = -1;
+ }
+ if (resource == null) return;
+ try {
+ id = Integer.parseInt(resource.getString(optionName + ".number"/*nonNLS*/));
+ } catch (MissingResourceException e) {
+ id = -1;
+ } catch (NumberFormatException e) {
+ id = -1;
+ }
+ try {
+ category = resource.getString(optionName + ".category"/*nonNLS*/);
+ } catch (MissingResourceException e) {
+ category = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
+ }
+ try {
+ name = resource.getString(optionName + ".name"/*nonNLS*/);
+ } catch (MissingResourceException e) {
+ name = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
+ }
+ try {
+ StringTokenizer tokenizer = new StringTokenizer(resource.getString(optionName + ".possibleValues"/*nonNLS*/), "|"/*nonNLS*/);
+ int numberOfValues = Integer.parseInt(tokenizer.nextToken());
+ if(numberOfValues == -1){
+ possibleValues = NoDiscreteValue;
+ } else {
+ possibleValues = new String[numberOfValues];
+ int index = 0;
+ while (tokenizer.hasMoreTokens()) {
+ possibleValues[index] = tokenizer.nextToken();
+ index++;
}
}
- return null;
+ } catch (MissingResourceException e) {
+ possibleValues = new String[0];
+ } catch (NoSuchElementException e) {
+ possibleValues = new String[0];
+ } catch (NumberFormatException e) {
+ possibleValues = new String[0];
}
-
- /**
- * Gets the min
- * @return Returns a Number
- */
- public Number getMin() {
- if(possibleValues == NoDiscreteValue){
- if(type.equals(INT)){
- if(minExisting){
- return new Integer(minInt);
- }
- else {
- return new Integer(Integer.MIN_VALUE);
- }
- }
- else if(type.equals(FLOAT)){
- if(minExisting){
- return new Float(minFloat);
- }
- else {
- return new Float(Float.MIN_VALUE);
- }
- }
- }
- return null;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Configurable option for "); //$NON-NLS-1$
- buffer.append(this.componentName).append("\n"); //$NON-NLS-1$
- buffer.append("- category: ").append(this.category).append("\n"); //$NON-NLS-2$ //$NON-NLS-1$
- buffer.append("- name: ").append(this.name).append("\n"); //$NON-NLS-2$ //$NON-NLS-1$
- /* display current value */
- buffer.append("- current value: ").append(this.value).append("\n"); //$NON-NLS-2$ //$NON-NLS-1$
- /* display possible values */
- if (possibleValues != NoDiscreteValue){
- buffer.append("- possible values: ["); //$NON-NLS-1$
- for (int i = 0, max = possibleValues.length; i < max; i++) {
- if (i != 0)
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(possibleValues[i]);
- }
- buffer.append("]\n"); //$NON-NLS-1$
- }
- buffer.append("- description: ").append(description).append("\n"); //$NON-NLS-2$ //$NON-NLS-1$
- return buffer.toString();
+ try {
+ description = resource.getString(optionName + ".description"/*nonNLS*/);
+ } catch (MissingResourceException e) {
+ description = "Missing ressources entries for"/*nonNLS*/ + componentName + " options"/*nonNLS*/;
}
+}
+/**
+ * Return a String that represents the localized category of the receiver.
+ * @return java.lang.String
+ */
+public String getCategory() {
+ return category;
+}
+/**
+ * Return a String that identifies the component owner (typically the qualified
+ * type name of the class which it corresponds to).
+ *
+ * e.g. "org.eclipse.jdt.internal.compiler.api.Compiler"
+ *
+ * @return java.lang.String
+ */
+public String getComponentName() {
+ return componentName;
+}
+/**
+ * Answer the index (in possibleValues array) of the current setting for this
+ * particular option.
+ *
+ * In case the set of possibleValues is NoDiscreteValue, then this index is the
+ * actual value (e.g. max line lenght set to 80).
+ *
+ * @return int
+ */
+public int getCurrentValueIndex() {
+ return currentValueIndex;
+}
+/**
+ * Answer the index (in possibleValues array) of the default setting for this
+ * particular option.
+ *
+ * In case the set of possibleValues is NoDiscreteValue, then this index is the
+ * actual value (e.g. max line lenght set to 80).
+ *
+ * @return int
+ */
+public int getDefaultValueIndex() {
+ return defaultValueIndex;
+}
+/**
+ * Return an String that represents the localized description of the receiver.
+ *
+ * @return java.lang.String
+ */
+public String getDescription() {
+ return description;
+}
+/**
+ * Internal ID which allows the configurable component to identify this particular option.
+ *
+ * @return int
+ */
+public int getID() {
+ return id;
+}
+/**
+ * Return a String that represents the localized name of the receiver.
+ * @return java.lang.String
+ */
+public String getName() {
+ return name;
+}
+/**
+ * Return an array of String that represents the localized possible values of the receiver.
+ * @return java.lang.String[]
+ */
+public String[] getPossibleValues() {
+ return possibleValues;
+}
+/**
+ * Change the index (in possibleValues array) of the current setting for this
+ * particular option.
+ *
+ * In case the set of possibleValues is NoDiscreteValue, then this index is the
+ * actual value (e.g. max line lenght set to 80).
+ *
+ * @return int
+ */
+public void setValueIndex(int newIndex) {
+ currentValueIndex = newIndex;
+}
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Configurable option for "/*nonNLS*/);
+ buffer.append(this.componentName).append("\n"/*nonNLS*/);
+ buffer.append("- category: "/*nonNLS*/).append(this.category).append("\n"/*nonNLS*/);
+ buffer.append("- name: "/*nonNLS*/).append(this.name).append("\n"/*nonNLS*/);
+ /* display current value */
+ buffer.append("- current value: "/*nonNLS*/);
+ if (possibleValues == NoDiscreteValue){
+ buffer.append(this.currentValueIndex);
+ } else {
+ buffer.append(this.possibleValues[this.currentValueIndex]);
+ }
+ buffer.append("\n"/*nonNLS*/);
- public static String[] getIDs(String componentName,Locale locale){
- try {
- ResourceBundle bundle = ResourceBundle.getBundle(componentName,locale);
- Enumeration bundleKeys = bundle.getKeys();
-
- String partialResult[] = new String[100];
- int resultCount = 0;
-
- while(bundleKeys.hasMoreElements()){
- String bundleKey = (String)bundleKeys.nextElement();
- if(bundleKey.endsWith("order")){ //$NON-NLS-1$
- int order;
- try{
- order = Integer.parseInt(bundle.getString(bundleKey));
-
- String id = bundleKey.substring(0,bundleKey.lastIndexOf('.'));
- int length = partialResult.length;
- if(length <= order)
- System.arraycopy(partialResult,0,partialResult = new String[order+1],0,length);
- partialResult[order]= id;
- resultCount++;
- } catch (NumberFormatException e) {
- //if order can not be read, option is not add
- }
- }
- }
- String[] result = new String[resultCount];
- resultCount = 0;
- for(int i = 0; i < partialResult.length;i++){
- if(partialResult[i]!= null){
- result[resultCount++]=partialResult[i];
-
- }
- }
- return result;
-
- } catch (MissingResourceException e) {
- return new String[0];
- }
- }
-} \ No newline at end of file
+ /* display possible values */
+ if (possibleValues != NoDiscreteValue){
+ buffer.append("- possible values: ["/*nonNLS*/);
+ for (int i = 0, max = possibleValues.length; i < max; i++) {
+ if (i != 0)
+ buffer.append(", "/*nonNLS*/);
+ buffer.append(possibleValues[i]);
+ }
+ buffer.append("]\n"/*nonNLS*/);
+ buffer.append("- curr. val. index: "/*nonNLS*/).append(currentValueIndex).append("\n"/*nonNLS*/);
+ }
+ buffer.append("- description: "/*nonNLS*/).append(description).append("\n"/*nonNLS*/);
+ return buffer.toString();
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
index 89e34b59b1..d49cd5c942 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
@@ -27,8 +27,6 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
-
-import java.util.Locale;
public class DocumentElementParser extends Parser {
IDocumentElementRequestor requestor;
@@ -46,27 +44,18 @@ public class DocumentElementParser extends Parser {
int intArrayPtr;
public DocumentElementParser(
final IDocumentElementRequestor requestor,
- IProblemFactory problemFactory,
- CompilerOptions options) {
+ IProblemFactory problemFactory) {
super(new ProblemReporter(
DefaultErrorHandlingPolicies.exitAfterAllProblems(),
- options,
+ new CompilerOptions(),
problemFactory) {
public void record(IProblem problem, CompilationResult unitResult) {
requestor.acceptProblem(problem);
}
- },
- false,
- options.getAssertMode());
+ }, false);
this.requestor = requestor;
intArrayStack = new int[30][];
}
-
-public DocumentElementParser(
- final IDocumentElementRequestor requestor,
- IProblemFactory problemFactory) {
- this(requestor, problemFactory, new CompilerOptions(Compiler.getDefaultOptions(Locale.getDefault())));
-}
/**
*
* INTERNAL USE-ONLY
@@ -1270,7 +1259,7 @@ private char[] returnTypeName(TypeReference type) {
}
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("intArrayPtr = " + intArrayPtr + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("intArrayPtr = "/*nonNLS*/ + intArrayPtr + "\n"/*nonNLS*/);
buffer.append(super.toString());
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/HierarchyResolver.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/HierarchyResolver.java
index 15db337aba..0ff225f614 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/HierarchyResolver.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/HierarchyResolver.java
@@ -25,8 +25,6 @@ import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
-import java.util.Locale;
-
public class HierarchyResolver implements ITypeRequestor {
IHierarchyRequestor requestor;
LookupEnvironment lookupEnvironment;
@@ -74,22 +72,22 @@ public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
public void accept(ICompilationUnit sourceUnit) {
//System.out.println("Cannot accept compilation units inside the HierarchyResolver.");
lookupEnvironment.problemReporter.abortDueToInternalError(
- new StringBuffer(Util.bind("accept.cannot")) //$NON-NLS-1$
+ new StringBuffer(Util.bind("accept.cannot"/*nonNLS*/))
.append(sourceUnit.getFileName())
.toString());
}
/**
- * Add additional source types
+ * Add an additional source type
*/
-public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
- CompilationResult result = new CompilationResult(sourceTypes[0].getFileName(), 1, 1);
+public void accept(ISourceType sourceType, PackageBinding packageBinding) {
+ CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1);
CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(sourceTypes, false, true, lookupEnvironment.problemReporter, result);
+ SourceTypeConverter.buildCompilationUnit(sourceType, false, true, lookupEnvironment.problemReporter, result);
if (unit != null) {
lookupEnvironment.buildTypeBindings(unit);
- rememberWithMemberTypes(sourceTypes[0], unit.types[0].binding);
+ rememberWithMemberTypes(sourceType, unit.types[0].binding);
lookupEnvironment.completeTypeBindings(unit, false);
}
@@ -244,7 +242,7 @@ public void resolve(IGenericType[] suppliedTypes, ICompilationUnit[] sourceUnits
while (topLevelType.getEnclosingType() != null)
topLevelType = topLevelType.getEnclosingType();
CompilationResult result = new CompilationResult(topLevelType.getFileName(), i, suppliedLength);
- units[++count] = SourceTypeConverter.buildCompilationUnit(new ISourceType[]{topLevelType}, false, true, lookupEnvironment.problemReporter, result);
+ units[++count] = SourceTypeConverter.buildCompilationUnit(topLevelType, false, true, lookupEnvironment.problemReporter, result);
if (units[count] == null) {
count--;
@@ -262,8 +260,7 @@ public void resolve(IGenericType[] suppliedTypes, ICompilationUnit[] sourceUnits
ICompilationUnit sourceUnit = sourceUnits[i];
sourceUnits[i] = null; // no longer needed pass this point
CompilationResult unitResult = new CompilationResult(sourceUnit, suppliedLength+i, suppliedLength+sourceLength);
- CompilerOptions options = new CompilerOptions(Compiler.getDefaultOptions(Locale.getDefault()));
- Parser parser = new Parser(lookupEnvironment.problemReporter, false, options.getAssertMode());
+ Parser parser = new Parser(lookupEnvironment.problemReporter);
CompilationUnitDeclaration parsedUnit = parser.dietParse(sourceUnit, unitResult);
if (parsedUnit != null) {
units[++count] = parsedUnit;
@@ -302,7 +299,7 @@ public void resolve(IGenericType suppliedType) {
topLevelType = topLevelType.getEnclosingType();
CompilationResult result = new CompilationResult(topLevelType.getFileName(), 1, 1);
CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(new ISourceType[]{topLevelType}, false, true, lookupEnvironment.problemReporter, result);
+ SourceTypeConverter.buildCompilationUnit(topLevelType, false, true, lookupEnvironment.problemReporter, result);
if (unit != null) {
lookupEnvironment.buildTypeBindings(unit);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
index a47f2731fa..cee2764747 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
@@ -23,7 +23,6 @@ public interface IAbstractSyntaxTreeVisitor {
void endVisit(ArrayReference arrayReference, BlockScope scope);
void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope);
void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope);
- void endVisit(AssertStatement assertStatement, BlockScope scope);
void endVisit(Assignment assignment, BlockScope scope);
void endVisit(BinaryExpression binaryExpression, BlockScope scope);
void endVisit(Block block, BlockScope scope);
@@ -99,7 +98,6 @@ public interface IAbstractSyntaxTreeVisitor {
boolean visit(ArrayReference arrayReference, BlockScope scope);
boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope);
boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope);
- boolean visit(AssertStatement assertStatement, BlockScope scope);
boolean visit(Assignment assignment, BlockScope scope);
boolean visit(BinaryExpression binaryExpression, BlockScope scope);
boolean visit(Block block, BlockScope scope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
index 9a130fb27f..45290561eb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
@@ -31,7 +31,6 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
-import java.util.Locale;
public class SourceElementParser extends Parser {
ISourceElementRequestor requestor;
@@ -43,36 +42,26 @@ public class SourceElementParser extends Parser {
private char[][] typeNames;
private char[][] superTypeNames;
private int nestedTypeIndex;
- private static final char[] JAVA_LANG_OBJECT = "java.lang.Object".toCharArray(); //$NON-NLS-1$
+ private static final char[] JAVA_LANG_OBJECT = "java.lang.Object"/*nonNLS*/.toCharArray();
public SourceElementParser(
final ISourceElementRequestor requestor,
- IProblemFactory problemFactory,
- CompilerOptions options) {
+ IProblemFactory problemFactory) {
// we want to notify all syntax error with the acceptProblem API
// To do so, we define the record method of the ProblemReporter
super(new ProblemReporter(
- DefaultErrorHandlingPolicies.exitAfterAllProblems(),
- options,
+ DefaultErrorHandlingPolicies.exitAfterAllProblems(),
+ new CompilerOptions(),
problemFactory) {
public void record(IProblem problem, CompilationResult unitResult) {
unitResult.record(problem);
requestor.acceptProblem(problem);
}
- },
- false,
- options.getAssertMode());
+ }, false);
this.requestor = requestor;
typeNames = new char[4][];
superTypeNames = new char[4][];
nestedTypeIndex = 0;
}
-
-public SourceElementParser(
- final ISourceElementRequestor requestor,
- IProblemFactory problemFactory) {
- this(requestor, problemFactory, new CompilerOptions(Compiler.getDefaultOptions(Locale.getDefault())));
-}
-
protected void classInstanceCreation(boolean alwaysQualified) {
boolean previousFlag = reportReferenceInfo;
@@ -835,7 +824,7 @@ public void parseTypeMemberDeclarations(
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
- new ISourceType[]{sourceType},
+ sourceType,
false,
false,
problemReporter(),
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index d867c09ae4..14e6800dc2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -29,7 +29,7 @@ public abstract class AbstractMethodDeclaration extends AstNode implements Probl
public boolean ignoreFurtherInvestigation = false;
public boolean needFreeReturn = false;
public LocalVariableBinding secretReturnValue;
- static final char[] SecretLocalDeclarationName = " returnValue".toCharArray(); //$NON-NLS-1$
+ static final char[] SecretLocalDeclarationName = " returnValue"/*nonNLS*/.toCharArray();
public int bodyStart;
public int bodyEnd = -1;
@@ -249,7 +249,7 @@ public void resolve(ClassScope upperScope) {
public String returnTypeToString(int tab) {
/*slow code */
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
public void tagAsHavingErrors() {
ignoreFurtherInvestigation = true;
@@ -264,21 +264,21 @@ public String toString(int tab) {
s += returnTypeToString(0);
- s += new String(selector) + "("; //$NON-NLS-1$
+ s += new String(selector) + "("/*nonNLS*/;
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
s += arguments[i].toString(0);
if (i != (arguments.length - 1))
- s = s + ", "; //$NON-NLS-1$
+ s = s + ", "/*nonNLS*/;
};
};
- s += ")"; //$NON-NLS-1$
+ s += ")"/*nonNLS*/;
if (thrownExceptions != null) {
- s += " throws "; //$NON-NLS-1$
+ s += " throws "/*nonNLS*/;
for (int i = 0; i < thrownExceptions.length; i++) {
s += thrownExceptions[i].toString(0);
if (i != (thrownExceptions.length - 1))
- s = s + ", "; //$NON-NLS-1$
+ s = s + ", "/*nonNLS*/;
};
};
@@ -289,18 +289,18 @@ public String toString(int tab) {
public String toStringStatements(int tab) {
/* slow code */
- if (isAbstract() || (this.modifiers & AccSemicolonBody) != 0) return ";"; //$NON-NLS-1$
+ if (isAbstract() || (this.modifiers & AccSemicolonBody) != 0) return ";"/*nonNLS*/;
- String s = " {"; //$NON-NLS-1$
+ String s = " {"/*nonNLS*/;
if (statements != null) {
for (int i = 0; i < statements.length; i++){
- s = s + "\n" + statements[i].toString(tab); //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + statements[i].toString(tab);
if (!(statements[i] instanceof Block)){
- s += ";"; //$NON-NLS-1$
+ s += ";"/*nonNLS*/;
}
}
}
- s += "\n" + tabString(tab == 0 ? 0 : tab - 1) + "}"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += "\n"/*nonNLS*/ + tabString(tab == 0 ? 0 : tab - 1) + "}"/*nonNLS*/;
return s;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
index 0f2b24b529..853943111d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
@@ -21,7 +21,7 @@ public abstract class AbstractVariableDeclaration extends Statement {
public AbstractVariableDeclaration(){}
public String name(){
- return "anonymous storage box"; } //$NON-NLS-1$
+ return "anonymous storage box"/*nonNLS*/; }
public String toString(int tab) {
/*slow code*/
@@ -29,9 +29,9 @@ public String toString(int tab) {
if (modifiers != AccDefault) {
s += modifiersString(modifiers);
}
- s += type.toString(0) + " " + new String(name()); //$NON-NLS-1$
+ s += type.toString(0) + " "/*nonNLS*/ + new String(name());
if (initialization != null)
- s += " = " + initialization.toStringExpression(tab); //$NON-NLS-1$
+ s += " = "/*nonNLS*/ + initialization.toStringExpression(tab);
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index 9261fd449b..4ae4b54877 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -139,21 +139,21 @@ public TypeBinding resolveType(BlockScope scope) {
if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null)
argHasError = true;
if (argHasError)
- return typeBinding;
+ return null;
}
if (typeBinding == null)
return null;
if (!typeBinding.canBeInstantiated()) {
scope.problemReporter().cannotInstantiate(type, typeBinding);
- return typeBinding;
+ return null;
}
ReferenceBinding allocatedType = (ReferenceBinding) typeBinding;
if (!(binding = scope.getConstructor(allocatedType, argumentTypes, this)).isValidBinding()) {
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return null;
}
if (isMethodUseDeprecated(binding, scope))
scope.problemReporter().deprecatedMethod(binding, this);
@@ -172,17 +172,17 @@ public void setFieldIndex(int i) {
public String toStringExpression() {
/* slow code */
- String s = "new " + type.toString(0); //$NON-NLS-1$
+ String s = "new "/*nonNLS*/ + type.toString(0);
if (arguments == null)
- s = s + "()" ; //$NON-NLS-1$
+ s = s + "()"/*nonNLS*/ ;
else
- { s = s + "("; //$NON-NLS-1$
+ { s = s + "("/*nonNLS*/;
for (int i = 0 ; i < arguments.length ; i++)
{ s = s + arguments[i].toStringExpression();
if (i == (arguments.length-1))
- s = s + ")" ; //$NON-NLS-1$
+ s = s + ")"/*nonNLS*/ ;
else
- s = s + ", "; };}; //$NON-NLS-1$
+ s = s + ", "/*nonNLS*/; };};
return s ;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
index 62067ca120..aaa8ee66b5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
@@ -23,7 +23,7 @@ public MethodBinding createsInternalConstructorWithBinding(MethodBinding inherit
//Add to method'set, the default constuctor that just recall the
//super constructor with the same arguments
- String baseName = "$anonymous"; //$NON-NLS-1$
+ String baseName = "$anonymous"/*nonNLS*/;
TypeBinding[] argumentTypes = inheritedConstructorBinding.parameters;
int argumentsLength = argumentTypes.length;
//the constructor
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
index d78048d1ae..0b3a7cb5ec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
@@ -42,14 +42,14 @@ public TypeBinding resolveForCatch(BlockScope scope) {
public String toString(int tab){
/* slow code */
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if (modifiers != AccDefault){
s += modifiersString(modifiers);
}
if (type == null){
- s += "<no type> "; //$NON-NLS-1$
+ s += "<no type> "/*nonNLS*/;
} else {
- s += type.toString(tab) + " "; //$NON-NLS-1$
+ s += type.toString(tab) + " "/*nonNLS*/;
}
s += new String(name);
return s;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
index 0196dab725..d50691d755 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
@@ -134,12 +134,12 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression() {
/* slow code */
- String s = "new " + type.toString(0); //$NON-NLS-1$
+ String s = "new "/*nonNLS*/ + type.toString(0);
for (int i = 0 ; i < dimensions.length ; i++)
{ if (dimensions[i] == null)
- s = s + "[]"; //$NON-NLS-1$
+ s = s + "[]"/*nonNLS*/;
else
- s = s + "[" + dimensions[i].toStringExpression() + "]" ;} //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + "["/*nonNLS*/ + dimensions[i].toStringExpression() + "]"/*nonNLS*/ ;}
if (initializer != null)
s = s + initializer.toStringExpression();
return s;}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
index 83ac3060da..3a24fb11e2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
@@ -139,15 +139,15 @@ public TypeBinding resolveTypeExpecting(BlockScope scope, TypeBinding expectedTb
public String toStringExpression() {
/* slow code */
- String s = "{" ; //$NON-NLS-1$
+ String s = "{"/*nonNLS*/ ;
if (expressions != null)
{ int j = 20 ;
for (int i = 0 ; i < expressions.length ; i++)
- { s = s + expressions[i].toStringExpression() + "," ; //$NON-NLS-1$
+ { s = s + expressions[i].toStringExpression() + ","/*nonNLS*/ ;
j -- ;
if (j == 0)
- { s = s + "\n "; j = 20;}}}; //$NON-NLS-1$
- s = s + "}"; //$NON-NLS-1$
+ { s = s + "\n "/*nonNLS*/; j = 20;}}};
+ s = s + "}"/*nonNLS*/;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
index 0efc107d14..7553690e6a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
@@ -30,9 +30,9 @@ public String toStringExpression(int tab){
/* slow speed */
String s = super.toStringExpression(tab) ;
- if (dimensions == 1 ) return s + "[]" ; //$NON-NLS-1$
+ if (dimensions == 1 ) return s + "[]"/*nonNLS*/ ;
for (int i=1 ; i <= dimensions ; i++)
- s = s + "[]" ; //$NON-NLS-1$
+ s = s + "[]"/*nonNLS*/ ;
return s ;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
index 8532c8cc17..e3491a0e32 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
@@ -122,9 +122,9 @@ public String toStringExpression(){
/* slow code */
return receiver.toStringExpression()
- + "[" //$NON-NLS-1$
+ + "["/*nonNLS*/
+ position.toStringExpression()
- + "]" ;} //$NON-NLS-1$
+ + "]"/*nonNLS*/ ;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
receiver.traverse(visitor, scope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
index 67b3a11e0e..6776245d54 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
@@ -35,9 +35,9 @@ public String toStringExpression(int tab){
/* slow speed */
String s = super.toStringExpression(tab) ;
- if (dimensions == 1 ) return s + "[]" ; //$NON-NLS-1$
+ if (dimensions == 1 ) return s + "[]"/*nonNLS*/ ;
for (int i=1 ; i <= dimensions ; i++)
- s = s + "[]" ; //$NON-NLS-1$
+ s = s + "[]"/*nonNLS*/ ;
return s ;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
deleted file mode 100644
index aea7acd013..0000000000
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.eclipse.jdt.internal.compiler.ast;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
-
-public class AssertStatement extends Statement {
- public Expression assertExpression, exceptionArgument;
-
- // for local variable attribute
- int preAssertInitStateIndex = -1;
- private FieldBinding assertionSyntheticFieldBinding;
-
- public AssertStatement(
- Expression exceptionArgument,
- Expression assertExpression,
- int startPosition) {
- this.assertExpression = assertExpression;
- this.exceptionArgument = exceptionArgument;
- sourceStart = startPosition;
- sourceEnd = exceptionArgument.sourceEnd;
- }
-
- public AssertStatement(Expression assertExpression, int startPosition) {
- this.assertExpression = assertExpression;
- sourceStart = startPosition;
- sourceEnd = assertExpression.sourceEnd;
- }
-
- public FlowInfo analyseCode(
- BlockScope currentScope,
- FlowContext flowContext,
- FlowInfo flowInfo) {
-
- Constant constant = assertExpression.constant;
- if (constant != NotAConstant && constant.booleanValue() == true) {
- return flowInfo;
- }
-
- preAssertInitStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo);
- FlowInfo assertInfo = flowInfo.copy();
-
- if (exceptionArgument != null) {
- assertInfo = exceptionArgument.analyseCode(
- currentScope,
- flowContext,
- assertExpression.analyseCode(currentScope, flowContext, assertInfo).unconditionalInits())
- .unconditionalInits();
- } else {
- assertInfo = assertExpression.analyseCode(currentScope, flowContext, assertInfo).unconditionalInits();
- }
-
- // assertion might throw AssertionError (unchecked), which can have consequences in term of
- // definitely assigned variables (depending on caught exception in the context)
- // DISABLED - AssertionError is unchecked, try statements are already protected against these.
- //flowContext.checkExceptionHandlers(currentScope.getJavaLangAssertionError(), this, assertInfo, currentScope);
-
- // only retain potential initializations
- flowInfo.addPotentialInitializationsFrom(assertInfo.unconditionalInits());
-
- // add the assert support in the clinit
- manageSyntheticAccessIfNecessary(currentScope);
-
- return flowInfo;
- }
-
- public void generateCode(BlockScope currentScope, CodeStream codeStream) {
- if ((bits & IsReachableMASK) == 0) {
- return;
- }
- int pc = codeStream.position, divergePC;
-
- // codegen here
- if (this.assertionSyntheticFieldBinding != null) {
- Label assertionActivationLabel = new Label(codeStream);
- codeStream.getstatic(this.assertionSyntheticFieldBinding);
- codeStream.ifne(assertionActivationLabel);
- Label falseLabel = new Label(codeStream);
- assertExpression.generateOptimizedBoolean(currentScope, codeStream, (falseLabel = new Label(codeStream)), null , true);
- codeStream.newJavaLangAssertionError();
- codeStream.dup();
- if (exceptionArgument != null) {
- exceptionArgument.generateCode(currentScope, codeStream, true);
- if (exceptionArgument.constant != NotAConstant) {
- codeStream.invokeJavaLangAssertionErrorConstructor(exceptionArgument.constant.typeID());
- } else {
- codeStream.invokeJavaLangAssertionErrorConstructor(exceptionArgument.implicitConversion & 0xF);
- }
- } else {
- codeStream.invokeJavaLangAssertionErrorDefaultConstructor();
- }
- codeStream.athrow();
- falseLabel.place();
- assertionActivationLabel.place();
- }
-
- // May loose some local variable initializations : affecting the local variable attributes
- if (preAssertInitStateIndex != -1) {
- codeStream.removeNotDefinitelyAssignedVariables(currentScope, preAssertInitStateIndex);
- }
- codeStream.recordPositionsFrom(pc, this);
- }
-
- public void resolve(BlockScope scope) {
- assertExpression.resolveTypeExpecting(scope, BooleanBinding);
- if (exceptionArgument != null) {
- TypeBinding exceptionArgumentTB = exceptionArgument.resolveType(scope);
- exceptionArgument.implicitConversion = (exceptionArgumentTB.id << 4) + exceptionArgumentTB.id;
- }
- }
-
- public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
- if (visitor.visit(this, scope)) {
- assertExpression.traverse(visitor, scope);
- if (exceptionArgument != null) {
- exceptionArgument.traverse(visitor, scope);
- }
- }
- visitor.endVisit(this, scope);
- }
-
- public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
-
- // need assertion flag: $assertionsDisabled on outer most source type
- ClassScope outerMostClassScope = currentScope.outerMostClassScope();
- SourceTypeBinding sourceTypeBinding = outerMostClassScope.enclosingSourceType();
- this.assertionSyntheticFieldBinding = sourceTypeBinding.addSyntheticField(this, currentScope);
-
- // find <clinit> and enable assertion support
- TypeDeclaration typeDeclaration = outerMostClassScope.referenceType();
- AbstractMethodDeclaration[] methods = typeDeclaration.methods;
- for (int i = 0, max = methods.length; i < max; i++) {
- AbstractMethodDeclaration method = methods[i];
- if (method.isClinit()) {
- ((Clinit) method).addSupportForAssertion(assertionSyntheticFieldBinding);
- break;
- }
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
index e3d89aaaaa..1d142c97ec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
@@ -101,15 +101,15 @@ public String toStringExpression(){
//subclass redefine toStringExpressionNoParenthesis()
- return "(" + toStringExpressionNoParenthesis() + ")"; } //$NON-NLS-2$ //$NON-NLS-1$
+ return "("/*nonNLS*/ + toStringExpressionNoParenthesis() + ")"/*nonNLS*/; }
public String toStringExpressionNoParenthesis() {
- return lhs.toStringExpression() + " " + //$NON-NLS-1$
- "=" + //$NON-NLS-1$
+ return lhs.toStringExpression() + " "/*nonNLS*/ +
+ "="/*nonNLS*/ +
( (expression.constant != null ) && (expression.constant != NotAConstant) ?
- " /*cst:"+expression.constant.toString()+"*/ " : //$NON-NLS-1$ //$NON-NLS-2$
- " " ) + //$NON-NLS-1$
+ " /*cst:"/*nonNLS*/+expression.constant.toString()+"*/ "/*nonNLS*/ :
+ " "/*nonNLS*/ ) +
expression.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
index 8b1bb6550b..c7ce48f89f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
@@ -63,27 +63,27 @@ public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) {
}
public static String modifiersString(int modifiers) {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if ((modifiers & AccPublic) != 0)
- s = s + "public "; //$NON-NLS-1$
+ s = s + "public "/*nonNLS*/;
if ((modifiers & AccPrivate) != 0)
- s = s + "private "; //$NON-NLS-1$
+ s = s + "private "/*nonNLS*/;
if ((modifiers & AccProtected) != 0)
- s = s + "protected "; //$NON-NLS-1$
+ s = s + "protected "/*nonNLS*/;
if ((modifiers & AccStatic) != 0)
- s = s + "static "; //$NON-NLS-1$
+ s = s + "static "/*nonNLS*/;
if ((modifiers & AccFinal) != 0)
- s = s + "final "; //$NON-NLS-1$
+ s = s + "final "/*nonNLS*/;
if ((modifiers & AccSynchronized) != 0)
- s = s + "synchronized "; //$NON-NLS-1$
+ s = s + "synchronized "/*nonNLS*/;
if ((modifiers & AccVolatile) != 0)
- s = s + "volatile "; //$NON-NLS-1$
+ s = s + "volatile "/*nonNLS*/;
if ((modifiers & AccTransient) != 0)
- s = s + "transient "; //$NON-NLS-1$
+ s = s + "transient "/*nonNLS*/;
if ((modifiers & AccNative) != 0)
- s = s + "native "; //$NON-NLS-1$
+ s = s + "native "/*nonNLS*/;
if ((modifiers & AccAbstract) != 0)
- s = s + "abstract "; //$NON-NLS-1$
+ s = s + "abstract "/*nonNLS*/;
return s;
}
/** @Deprecated
@@ -97,8 +97,8 @@ public int sourceStart() {
public static String tabString(int tab){
/*slow code*/
- String s = "" ; //$NON-NLS-1$
- for (int i = tab ; i > 0 ; i--) s = s + " " ; //$NON-NLS-1$
+ String s = ""/*nonNLS*/ ;
+ for (int i = tab ; i > 0 ; i--) s = s + " "/*nonNLS*/ ;
return s;}
public String toString() {
/* low speed */
@@ -109,7 +109,7 @@ public String toString(int tab){
/* low speed */
/*If reach here fetchs the default display*/
- return "****"+ super.toString()+ "****";} //$NON-NLS-2$ //$NON-NLS-1$
+ return "****"/*nonNLS*/+ super.toString()+ "****"/*nonNLS*/;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope){
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
index c33b663016..c3d772b0a0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
@@ -1402,8 +1402,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpressionNoParenthesis(){
/* slow code*/
- return left.toStringExpression() + " " + //$NON-NLS-1$
- operatorToString() + " " + //$NON-NLS-1$
+ return left.toStringExpression() + " "/*nonNLS*/ +
+ operatorToString() + " "/*nonNLS*/ +
right.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
index 68af753317..2443f2b4a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
@@ -86,9 +86,9 @@ public String toString(int tab) {
String s = tabString(tab);
if (this.statements == null) {
- s += "{\n"; //$NON-NLS-1$
+ s += "{\n"/*nonNLS*/;
s += tabString(tab);
- s += "}"; //$NON-NLS-1$
+ s += "}"/*nonNLS*/;
return s;
}
@@ -96,22 +96,22 @@ public String toString(int tab) {
// ? " { // ---scope needed for "+String.valueOf(explicitDeclarations) +" locals------------ \n"
// : "{// ---NO scope needed------ \n") ;
- s += "{\n"; //$NON-NLS-1$
+ s += "{\n"/*nonNLS*/;
s += this.toStringStatements(tab);
s += tabString(tab);
- s += "}"; //$NON-NLS-1$
+ s += "}"/*nonNLS*/;
return s;
}
public String toStringStatements(int tab) {
/* slow code */
- if (this.statements == null) return ""; //$NON-NLS-1$
+ if (this.statements == null) return ""/*nonNLS*/;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < statements.length; i++) {
buffer.append(statements[i].toString(tab + 1));
if (statements[i] instanceof Block){
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
} else {
- buffer.append(";\n"); //$NON-NLS-1$
+ buffer.append(";\n"/*nonNLS*/);
}
};
return buffer.toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
index 7bd0d7d809..1a1786e129 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
@@ -65,7 +65,7 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab) ;
- s = s + "break "; //$NON-NLS-1$
+ s = s + "break "/*nonNLS*/;
if (label != null )
s = s + new String(label) ;
return s;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
index 09fabb4c89..fadea5a860 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
@@ -27,8 +27,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
currentScope.referenceType().recordReferenceTo(binding);
}
*/
- if (constantExpression.constant == NotAConstant)
- currentScope.problemReporter().caseExpressionMustBeConstant(constantExpression);
+
return flowInfo;
}
/**
@@ -54,6 +53,8 @@ public Constant resolveCase(BlockScope scope, TypeBinding testTb, SwitchStatemen
// add into the collection of cases of the associated switch statement
switchStatement.cases[switchStatement.caseCount++] = this;
TypeBinding caseTb = constantExpression.resolveType(scope);
+ if (constantExpression.constant == NotAConstant)
+ scope.problemReporter().caseExpressionMustBeConstant(constantExpression);
if (caseTb == null || testTb == null)
return null;
if (constantExpression.isConstantValueOfTypeAssignableToType(caseTb, testTb))
@@ -67,7 +68,7 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab);
- s = s + "case " + constantExpression.toStringExpression() + " : " ; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "case "/*nonNLS*/ + constantExpression.toStringExpression() + " : "/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
index 55971387be..6ceaa8d0f0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
@@ -234,7 +234,7 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/*slow code*/
- return "(" + type.toString(0)+ ") " + //$NON-NLS-2$ //$NON-NLS-1$
+ return "("/*nonNLS*/ + type.toString(0)+ ") "/*nonNLS*/ +
expression.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
index 9b7d3336bc..45214460a9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
@@ -59,8 +59,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/*slow code*/
- String s = ""; //$NON-NLS-1$
- s = s + type.toString(0) + ".class" ; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
+ s = s + type.toString(0) + ".class"/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
index b0771d8e74..a8ff9eca58 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
@@ -14,193 +14,136 @@ import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
public class Clinit extends AbstractMethodDeclaration {
- public final static char[] ConstantPoolName = "<clinit>" .toCharArray(); //$NON-NLS-1$
-
- private FieldBinding assertionSyntheticFieldBinding = null;
- private FieldBinding classLiteralSyntheticField = null;
-
- public Clinit() {
- modifiers = 0;
- selector = ConstantPoolName;
- }
+ public final static char[] ConstantPoolName = "<clinit>"/*nonNLS*/.toCharArray();
+public Clinit() {
+ modifiers = 0;
+ selector = ConstantPoolName;
+}
+public void analyseCode(ClassScope classScope, InitializationFlowContext staticInitializerFlowContext, FlowInfo flowInfo){
- public void analyseCode(
- ClassScope classScope,
- InitializationFlowContext staticInitializerFlowContext,
- FlowInfo flowInfo) {
-
- if (ignoreFurtherInvestigation)
- return;
- try {
- ExceptionHandlingFlowContext clinitContext =
- new ExceptionHandlingFlowContext(
- staticInitializerFlowContext.parent,
- this,
- NoExceptions,
- scope,
- FlowInfo.DeadEnd);
-
- // check for missing returning path
- needFreeReturn =
- !((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable());
-
- // check missing blank final field initializations
- flowInfo = flowInfo.mergedWith(staticInitializerFlowContext.initsOnReturn);
- FieldBinding[] fields = scope.enclosingSourceType().fields();
- for (int i = 0, count = fields.length; i < count; i++) {
- FieldBinding field;
- if ((field = fields[i]).isStatic()
- && field.isFinal()
- && (!flowInfo.isDefinitelyAssigned(fields[i]))) {
- scope.problemReporter().uninitializedBlankFinalField(
- field,
- scope.referenceType().declarationOf(field));
- // can complain against the field decl, since only one <clinit>
- }
+ if (ignoreFurtherInvestigation)
+ return;
+ try {
+ ExceptionHandlingFlowContext clinitContext = new ExceptionHandlingFlowContext(
+ staticInitializerFlowContext.parent,
+ this,
+ NoExceptions,
+ scope,
+ FlowInfo.DeadEnd);
+
+ // check for missing returning path
+ needFreeReturn = !((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable());
+
+ // check missing blank final field initializations
+ flowInfo = flowInfo.mergedWith(staticInitializerFlowContext.initsOnReturn);
+ FieldBinding[] fields = scope.enclosingSourceType().fields();
+ for (int i = 0, count = fields.length; i < count; i++) {
+ FieldBinding field;
+ if ((field = fields[i]).isStatic()
+ && field.isFinal()
+ && (!flowInfo.isDefinitelyAssigned(fields[i]))) {
+ scope.problemReporter().uninitializedBlankFinalField(field, scope.referenceType().declarationOf(field)); // can complain against the field decl, since only one <clinit>
}
- // check static initializers thrown exceptions
- staticInitializerFlowContext.checkInitializerExceptions(
- scope,
- clinitContext,
- flowInfo);
- } catch (AbortMethod e) {
- this.ignoreFurtherInvestigation = true;
}
+ // check static initializers thrown exceptions
+ staticInitializerFlowContext.checkInitializerExceptions(scope, clinitContext, flowInfo);
+ } catch (AbortMethod e) {
+ this.ignoreFurtherInvestigation = true;
}
-
- /**
- * Bytecode generation for a <clinit> method
- *
- * @param classScope org.eclipse.jdt.internal.compiler.lookup.ClassScope
- * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
- */
- public void generateCode(ClassScope classScope, ClassFile classFile) {
- int clinitOffset = 0;
- if (ignoreFurtherInvestigation) {
- // should never have to add any <clinit> problem method
- return;
- }
- try {
- clinitOffset = classFile.contentsOffset;
- ConstantPool constantPool = classFile.constantPool;
- int constantPoolOffset = constantPool.currentOffset;
- int constantPoolIndex = constantPool.currentIndex;
- classFile.generateMethodInfoHeaderForClinit();
- int codeAttributeOffset = classFile.contentsOffset;
- classFile.generateCodeAttributeHeader();
- CodeStream codeStream = classFile.codeStream;
- this.resolve(classScope);
-
- codeStream.reset(this, classFile);
- TypeDeclaration declaringType = classScope.referenceContext;
-
- // initialize local positions - including initializer scope.
- scope.computeLocalVariablePositions(0, codeStream); // should not be necessary
- MethodScope staticInitializerScope = declaringType.staticInitializerScope;
- staticInitializerScope.computeLocalVariablePositions(0, codeStream);
- // offset by the argument size
-
- // 1.4 feature
- // This has to be done before any other initialization
- if (this.assertionSyntheticFieldBinding != null) {
- // generate code related to the activation of assertion for this class
- codeStream.generateClassLiteralAccessForType(
- classScope.enclosingSourceType(),
- classLiteralSyntheticField);
- codeStream.invokeJavaLangClassDesiredAssertionStatus();
- Label falseLabel = new Label(codeStream);
- codeStream.ifne(falseLabel);
- codeStream.iconst_1();
- Label jumpLabel = new Label(codeStream);
- codeStream.goto_(jumpLabel);
- falseLabel.place();
- codeStream.iconst_0();
- jumpLabel.place();
- codeStream.putstatic(this.assertionSyntheticFieldBinding);
- }
- // generate initializers
- if (declaringType.fields != null) {
- for (int i = 0, max = declaringType.fields.length; i < max; i++) {
- FieldDeclaration fieldDecl;
- if ((fieldDecl = declaringType.fields[i]).isStatic()) {
- fieldDecl.generateCode(staticInitializerScope, codeStream);
- }
- }
- }
- if (codeStream.position == 0) {
- // do not need to output a Clinit if no bytecodes
- // so we reset the offset inside the byte array contents.
- classFile.contentsOffset = clinitOffset;
- // like we don't addd a method we need to undo the increment on the method count
- classFile.methodCount--;
- // reset the constant pool to its state before the clinit
- constantPool.resetForClinit(constantPoolIndex, constantPoolOffset);
- } else {
- if (needFreeReturn) {
- int oldPosition = codeStream.position;
- codeStream.return_();
- codeStream.updateLocalVariablesAttribute(oldPosition);
+}
+/**
+ * Bytecode generation for a <clinit> method
+ *
+ * @param classScope org.eclipse.jdt.internal.compiler.lookup.ClassScope
+ * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
+ */
+public void generateCode(ClassScope classScope, ClassFile classFile) {
+ int clinitOffset = 0;
+ if (ignoreFurtherInvestigation) {
+ // should never have to add any <clinit> problem method
+ return;
+ }
+ try {
+ clinitOffset = classFile.contentsOffset;
+ ConstantPool constantPool = classFile.constantPool;
+ int constantPoolOffset = constantPool.currentOffset;
+ int constantPoolIndex = constantPool.currentIndex;
+ classFile.generateMethodInfoHeaderForClinit();
+ int codeAttributeOffset = classFile.contentsOffset;
+ classFile.generateCodeAttributeHeader();
+ CodeStream codeStream = classFile.codeStream;
+ codeStream.reset(this, classFile);
+ TypeDeclaration declaringType = classScope.referenceContext;
+
+ // initialize local positions - including initializer scope.
+ scope.computeLocalVariablePositions(0, codeStream); // should not be necessary
+ MethodScope staticInitializerScope = declaringType.staticInitializerScope;
+ staticInitializerScope.computeLocalVariablePositions(0, codeStream); // offset by the argument size
+
+ // generate initializers
+ if (declaringType.fields != null) {
+ for (int i = 0, max = declaringType.fields.length; i < max; i++) {
+ FieldDeclaration fieldDecl;
+ if ((fieldDecl = declaringType.fields[i]).isStatic()) {
+ fieldDecl.generateCode(staticInitializerScope, codeStream);
}
- // Record the end of the clinit: point to the declaration of the class
- codeStream.recordPositionsFrom(0, declaringType);
- classFile.completeCodeAttributeForClinit(codeAttributeOffset);
}
- } catch (AbortMethod e) {
- // should never occur
- // the clinit referenceContext is the type declaration
- // All clinit problems will be reported against the type: AbortType instead of AbortMethod
- // reset the contentsOffset to the value before generating the clinit code
- // decrement the number of method info as well.
- // This is done in the addProblemMethod and addProblemConstructor for other
- // cases.
+ }
+ if (codeStream.position == 0) {
+ // do not need to output a Clinit if no bytecodes
+ // so we reset the offset inside the byte array contents.
classFile.contentsOffset = clinitOffset;
+ // like we don't addd a method we need to undo the increment on the method count
classFile.methodCount--;
+ // reset the constant pool to its state before the clinit
+ constantPool.resetForClinit(constantPoolIndex, constantPoolOffset);
+ } else {
+ if (needFreeReturn) {
+ int oldPosition = codeStream.position;
+ codeStream.return_();
+ codeStream.updateLocalVariablesAttribute(oldPosition);
+ }
+ // Record the end of the clinit: point to the declaration of the class
+ codeStream.recordPositionsFrom(0, declaringType);
+ classFile.completeCodeAttributeForClinit(codeAttributeOffset);
}
+ } catch (AbortMethod e) {
+ // should never occur
+ // the clinit referenceContext is the type declaration
+ // All clinit problems will be reported against the type: AbortType instead of AbortMethod
+ // reset the contentsOffset to the value before generating the clinit code
+ // decrement the number of method info as well.
+ // This is done in the addProblemMethod and addProblemConstructor for other
+ // cases.
+ classFile.contentsOffset = clinitOffset;
+ classFile.methodCount--;
}
-
- public boolean isClinit() {
- return true;
- }
-
- public boolean isInitializationMethod() {
- return true;
- }
-
- public boolean isStatic() {
- return true;
- }
- public void parseStatements(Parser parser, CompilationUnitDeclaration unit) {
- //the clinit is filled by hand ....
- }
- public void resolve(ClassScope scope) {
- this.scope = new MethodScope(scope, scope.referenceContext, true);
- }
-
- public String toString(int tab) {
- /* slow code */
- String s = "" ; //$NON-NLS-1$
- s = s + tabString(tab);
- s = s + "<clinit>()" ; //$NON-NLS-1$
- s = s + toStringStatements(tab + 1);
- return s;
- }
-
- public void traverse(
- IAbstractSyntaxTreeVisitor visitor,
- ClassScope classScope) {
- visitor.visit(this, classScope);
- visitor.endVisit(this, classScope);
- }
-
- // 1.4 feature
- public void addSupportForAssertion(FieldBinding assertionSyntheticFieldBinding) {
- this.assertionSyntheticFieldBinding = assertionSyntheticFieldBinding;
-
- // we need to add the field right now, because the field infos are generated before the methods
- SourceTypeBinding sourceType =
- this.scope.outerMostMethodScope().enclosingSourceType();
- this.classLiteralSyntheticField =
- sourceType.addSyntheticField(sourceType, scope);
- }
-
-} \ No newline at end of file
+}
+public boolean isClinit() {
+ return true;
+}
+public boolean isInitializationMethod(){
+ return true;
+}
+public boolean isStatic() {
+ return true;
+}
+public void parseStatements(Parser parser, CompilationUnitDeclaration unit){
+ //the clinit is filled by hand ....
+}
+public void resolve(ClassScope scope) {
+ this.scope = new MethodScope(scope, scope.referenceContext, true);
+}
+public String toString(int tab){
+ /* slow code */
+
+ String s = ""/*nonNLS*/ ;
+ s = s + tabString(tab);
+ s = s + "<clinit>()"/*nonNLS*/ ;
+ s = s + toStringStatements(tab + 1);
+ return s ;}
+public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope) {
+ visitor.visit(this, classScope);
+ visitor.endVisit(this, classScope);
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 52af376cee..5fe113fec4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -197,18 +197,18 @@ public void tagAsHavingErrors(){
public String toString(int tab) {
/*very slow code*/
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if (currentPackage != null)
- s = tabString(tab) + "package " + currentPackage.toString(0, false) + ";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = tabString(tab) + "package "/*nonNLS*/ + currentPackage.toString(0, false) + ";\n"/*nonNLS*/;
if (imports != null)
for (int i = 0; i < imports.length; i++) {
- s += tabString(tab) + "import " + imports[i].toString() + ";\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += tabString(tab) + "import "/*nonNLS*/ + imports[i].toString() + ";\n"/*nonNLS*/;
};
if (types != null)
for (int i = 0; i < types.length; i++) {
- s += types[i].toString(tab) + "\n"; //$NON-NLS-1$
+ s += types[i].toString(tab) + "\n"/*nonNLS*/;
}
return s;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
index fec4e8c405..8f3df73445 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
@@ -48,29 +48,29 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
public String operatorToString() {
switch (operator) {
case PLUS :
- return "+="; //$NON-NLS-1$
+ return "+="/*nonNLS*/;
case MINUS :
- return "-="; //$NON-NLS-1$
+ return "-="/*nonNLS*/;
case MULTIPLY :
- return "*="; //$NON-NLS-1$
+ return "*="/*nonNLS*/;
case DIVIDE :
- return "/="; //$NON-NLS-1$
+ return "/="/*nonNLS*/;
case AND :
- return "&="; //$NON-NLS-1$
+ return "&="/*nonNLS*/;
case OR :
- return "|="; //$NON-NLS-1$
+ return "|="/*nonNLS*/;
case XOR :
- return "^="; //$NON-NLS-1$
+ return "^="/*nonNLS*/;
case REMAINDER :
- return "%="; //$NON-NLS-1$
+ return "%="/*nonNLS*/;
case LEFT_SHIFT :
- return "<<="; //$NON-NLS-1$
+ return "<<="/*nonNLS*/;
case RIGHT_SHIFT :
- return ">>="; //$NON-NLS-1$
+ return ">>="/*nonNLS*/;
case UNSIGNED_RIGHT_SHIFT :
- return ">>>="; //$NON-NLS-1$
+ return ">>>="/*nonNLS*/;
};
- return "unknown operator"; //$NON-NLS-1$
+ return "unknown operator"/*nonNLS*/;
}
public TypeBinding resolveType(BlockScope scope) {
constant = NotAConstant;
@@ -119,8 +119,8 @@ public boolean restrainUsageToNumericTypes(){
return false ;}
public String toStringExpressionNoParenthesis() {
- return lhs.toStringExpression() + " " + //$NON-NLS-1$
- operatorToString() + " " + //$NON-NLS-1$
+ return lhs.toStringExpression() + " "/*nonNLS*/ +
+ operatorToString() + " "/*nonNLS*/ +
expression.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
index 70a97df38d..da05963bcf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
@@ -254,8 +254,8 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpressionNoParenthesis(){
/* slow code*/
- return condition.toStringExpression() + " ? " + //$NON-NLS-1$
- valueIfTrue.toStringExpression() + " : " + //$NON-NLS-1$
+ return condition.toStringExpression() + " ? "/*nonNLS*/ +
+ valueIfTrue.toStringExpression() + " : "/*nonNLS*/ +
valueIfFalse.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
index 911fda0dc8..78f87850fa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
@@ -15,7 +15,7 @@ import org.eclipse.jdt.internal.compiler.util.*;
public class ConstructorDeclaration extends AbstractMethodDeclaration {
public ExplicitConstructorCall constructorCall;
- public final static char[] ConstantPoolName = "<init>".toCharArray(); //$NON-NLS-1$
+ public final static char[] ConstantPoolName = "<init>"/*nonNLS*/.toCharArray();
public boolean isDefaultConstructor = false;
public int referenceCount = 0; // count how many times this constructor is referenced from other local constructors
@@ -257,19 +257,19 @@ public void resolve(ClassScope upperScope) {
public String toStringStatements(int tab) {
/* slow code */
- String s = " {"; //$NON-NLS-1$
+ String s = " {"/*nonNLS*/;
if (constructorCall != null) {
- s = s + "\n" + constructorCall.toString(tab) + ";"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "\n"/*nonNLS*/ + constructorCall.toString(tab) + ";"/*nonNLS*/;
}
if (statements != null){
for (int i = 0; i < statements.length; i++){
- s = s + "\n" + statements[i].toString(tab); //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + statements[i].toString(tab);
if (!(statements[i] instanceof Block)){
- s += ";"; //$NON-NLS-1$
+ s += ";"/*nonNLS*/;
}
}
}
- s+="\n"+tabString(tab == 0 ? 0 : tab - 1)+"}"; //$NON-NLS-2$ //$NON-NLS-1$
+ s+="\n"/*nonNLS*/+tabString(tab == 0 ? 0 : tab - 1)+"}"/*nonNLS*/;
return s;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
index 2d08037c54..56b5dd7d4d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
@@ -69,7 +69,7 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab) ;
- s = s + "continue "; //$NON-NLS-1$
+ s = s + "continue "/*nonNLS*/;
if (label != null )
s = s + new String(label) ;
return s;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
index b2c7d596aa..b69135998e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
@@ -53,7 +53,7 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab);
- s = s + "default : " ; //$NON-NLS-1$
+ s = s + "default : "/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
visitor.visit(this, blockScope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
index efac89ddcb..f69a0badde 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
@@ -125,15 +125,15 @@ public String toString(int tab) {
String inFront, s = tabString(tab);
inFront = s;
- s = s + "do"; //$NON-NLS-1$
+ s = s + "do"/*nonNLS*/;
if (action == null)
- s = s + " {}\n"; //$NON-NLS-1$
+ s = s + " {}\n"/*nonNLS*/;
else
if (action instanceof Block)
- s = s + "\n" + action.toString(tab + 1) + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + action.toString(tab + 1) + "\n"/*nonNLS*/;
else
- s = s + " {\n" + action.toString(tab + 1) + ";}\n"; //$NON-NLS-1$ //$NON-NLS-2$
- s = s + inFront + "while (" + condition.toStringExpression() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + " {\n"/*nonNLS*/ + action.toString(tab + 1) + ";}\n"/*nonNLS*/;
+ s = s + inFront + "while ("/*nonNLS*/ + condition.toStringExpression() + ")"/*nonNLS*/;
return s;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
index ec468b107f..8df58818df 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
@@ -224,17 +224,17 @@ public String toString(int tab){
String s = tabString(tab);
if (qualification != null)
- s = s + qualification.toStringExpression() + "." ; //$NON-NLS-1$
+ s = s + qualification.toStringExpression() + "."/*nonNLS*/ ;
if (accessMode == This){
- s = s + "this("; //$NON-NLS-1$
+ s = s + "this("/*nonNLS*/;
} else {
- s = s + "super("; //$NON-NLS-1$
+ s = s + "super("/*nonNLS*/;
}
if (arguments != null)
for (int i=0 ; i < arguments.length ; i++)
{ s = s + arguments[i].toStringExpression();
- if (i != arguments.length-1) s = s + ", ";};; //$NON-NLS-1$
- s = s+")" ; //$NON-NLS-1$
+ if (i != arguments.length-1) s = s + ", "/*nonNLS*/;};;
+ s = s+")"/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 45627ee074..8595400d8c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -155,7 +155,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
codeStream.recordPositionsFrom(pc, this);
} else {
// actual non-constant code generation
- throw new ShouldNotImplement(Util.bind("ast.missingCode")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.missingCode"/*nonNLS*/));
}
}
/**
@@ -344,7 +344,7 @@ public String toString(int tab) {
//before TC has runned
if (constant != NotAConstant)
//after the TC has runned
- s += " /*cst:" + constant.toString() + "*/ "; //$NON-NLS-1$ //$NON-NLS-2$
+ s += " /*cst:"/*nonNLS*/ + constant.toString() + "*/ "/*nonNLS*/;
return s + toStringExpression(tab);
}
public String toStringExpression() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
index 99ffa5dfd6..be9c90d626 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
@@ -46,7 +46,7 @@ public ExtendedStringLiteral extendWith(StringLiteral lit){
public String toStringExpression() {
/* slow code */
- String str = "ExtendedStringLiteral{"+ new String(source) +"}"; //$NON-NLS-2$ //$NON-NLS-1$
+ String str = "ExtendedStringLiteral{"/*nonNLS*/+ new String(source) +"}"/*nonNLS*/;
return str;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
index 1eb5c7cbe4..144cdecf26 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
@@ -365,7 +365,7 @@ public String toStringExpression(){
/* slow code */
return receiver.toString()
- + "." //$NON-NLS-1$
+ + "."/*nonNLS*/
+ new String(token);}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
index 16ef556f6a..37e6887305 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
@@ -208,32 +208,32 @@ public void resolve(BlockScope upperScope) {
public String toString(int tab ){
/* slow code */
- String s = tabString(tab) + "for ("; //$NON-NLS-1$
+ String s = tabString(tab) + "for ("/*nonNLS*/;
if (!neededScope)
- s = s + " //--NO upperscope scope needed\n" + tabString(tab) + " " ; //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + " //--NO upperscope scope needed\n"/*nonNLS*/ + tabString(tab) + " "/*nonNLS*/ ;
//inits
if (initializations != null)
{ for (int i = 0 ; i < initializations.length ; i++){
//nice only with expressions
s = s + initializations[i].toString(0);
- if (i != (initializations.length -1)) s = s + " , " ;}}; //$NON-NLS-1$
- s = s + "; " ; //$NON-NLS-1$
+ if (i != (initializations.length -1)) s = s + " , "/*nonNLS*/ ;}};
+ s = s + "; "/*nonNLS*/ ;
//cond
if (condition != null)
s = s + condition.toStringExpression() ;
- s = s + "; " ; //$NON-NLS-1$
+ s = s + "; "/*nonNLS*/ ;
//updates
if (increments != null)
{ for (int i = 0 ; i < increments.length ; i++){
//nice only with expressions
s = s + increments[i].toString(0);
- if (i != (increments.length -1)) s = s + " , " ;}}; //$NON-NLS-1$
- s = s + ") " ; //$NON-NLS-1$
+ if (i != (increments.length -1)) s = s + " , "/*nonNLS*/ ;}};
+ s = s + ") "/*nonNLS*/ ;
//block
if (action == null)
- s = s + "{}" ; //$NON-NLS-1$
+ s = s + "{}"/*nonNLS*/ ;
else
- s = s + "\n"+ action.toString(tab+1) ; //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/+ action.toString(tab+1) ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
index 3b66dcdfef..48a5d34051 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
@@ -187,10 +187,10 @@ public String toString(int tab){
String inFront , s = tabString(tab) ;
inFront = s ;
- s = s + "if ("+ condition.toStringExpression()+") \n"; //$NON-NLS-1$ //$NON-NLS-2$
- s = s + thenStatement.toString(tab+2) + ";" ; //$NON-NLS-1$
+ s = s + "if ("/*nonNLS*/+ condition.toStringExpression()+") \n"/*nonNLS*/;
+ s = s + thenStatement.toString(tab+2) + ";"/*nonNLS*/ ;
if (elseStatement != null)
- s = s + "\n" + inFront + "else\n" + elseStatement.toString(tab+2) + ";"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ s = s + "\n"/*nonNLS*/ + inFront + "else\n"/*nonNLS*/ + elseStatement.toString(tab+2) + ";"/*nonNLS*/;
return s ;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
index 753b055403..af82fee206 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
@@ -38,11 +38,11 @@ public String toString(int tab, boolean withOnDemand) {
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
if (withOnDemand && onDemand) {
- buffer.append(".*"); //$NON-NLS-1$
+ buffer.append(".*"/*nonNLS*/);
}
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
index 7b862a141f..b796c10281 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
@@ -72,10 +72,10 @@ public String toString(int tab){
StringBuffer buffer = new StringBuffer();
buffer.append(tabString(tab));
buffer.append(modifiersString(modifiers));
- buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("{\n"/*nonNLS*/);
buffer.append(block.toStringStatements(tab));
buffer.append(tabString(tab));
- buffer.append("}"); //$NON-NLS-1$
+ buffer.append("}"/*nonNLS*/);
return buffer.toString();
} else {
return block.toString(tab);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
index bf5fda1d56..fbf019b34f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
@@ -199,7 +199,7 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpressionNoParenthesis(){
/* slow code*/
- return expression.toStringExpression() + " instanceof " + //$NON-NLS-1$
+ return expression.toStringExpression() + " instanceof "/*nonNLS*/ +
type.toString(0) ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
index b4e3c5a05a..436ded9dda 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
@@ -77,7 +77,7 @@ public String toString(int tab) {
/* slow code */
String s = tabString(tab);
- s += new String(label) + ": " + statement.toString(0); //$NON-NLS-1$
+ s += new String(label) + ": "/*nonNLS*/ + statement.toString(0);
return s;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index 08786d24e6..656ea2a984 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -239,15 +239,15 @@ public void setFieldIndex(int depth) {
public String toStringExpression(){
/*slow code*/
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if (receiver != ThisReference.ThisImplicit)
- s = s + receiver.toStringExpression()+"."; //$NON-NLS-1$
- s = s + new String(selector) + "(" ; //$NON-NLS-1$
+ s = s + receiver.toStringExpression()+"."/*nonNLS*/;
+ s = s + new String(selector) + "("/*nonNLS*/ ;
if (arguments != null)
for (int i = 0; i < arguments.length ; i ++)
{ s = s + arguments[i].toStringExpression();
- if ( i != arguments.length -1 ) s = s + " , " ;};; //$NON-NLS-1$
- s =s + ")" ; //$NON-NLS-1$
+ if ( i != arguments.length -1 ) s = s + " , "/*nonNLS*/ ;};;
+ s =s + ")"/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
index d6a2bee534..4fa13ebda7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
@@ -70,8 +70,8 @@ public String returnTypeToString(int tab) {
/*slow code */
if (returnType == null)
- return ""; //$NON-NLS-1$
- return returnType.toString(tab)+" "; //$NON-NLS-1$
+ return ""/*nonNLS*/;
+ return returnType.toString(tab)+" "/*nonNLS*/;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope) {
if (visitor.visit(this, classScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
index 6dc69751c5..2b674f691d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
@@ -53,80 +53,80 @@ public static final String generateTableTestCase(){
class Decode {
public final String constant(int code){
switch(code){
- case T_boolean : return "true" ; //$NON-NLS-1$
- case T_byte : return "((byte) 3)" ; //$NON-NLS-1$
- case T_char : return "'A'" ; //$NON-NLS-1$
- case T_double : return "300.0d" ; //$NON-NLS-1$
- case T_float : return "100.0f" ; //$NON-NLS-1$
- case T_int : return "1" ; //$NON-NLS-1$
- case T_long : return "7L" ; //$NON-NLS-1$
- case T_String : return "\"hello-world\"" ; //$NON-NLS-1$
- case T_null : return "null"; //$NON-NLS-1$
- case T_short : return "((short) 5)"; //$NON-NLS-1$
- case T_Object : return "null";} //$NON-NLS-1$
- return "";} //$NON-NLS-1$
+ case T_boolean : return "true"/*nonNLS*/ ;
+ case T_byte : return "((byte) 3)"/*nonNLS*/ ;
+ case T_char : return "'A'"/*nonNLS*/ ;
+ case T_double : return "300.0d"/*nonNLS*/ ;
+ case T_float : return "100.0f"/*nonNLS*/ ;
+ case T_int : return "1"/*nonNLS*/ ;
+ case T_long : return "7L"/*nonNLS*/ ;
+ case T_String : return "\"hello-world\""/*nonNLS*/ ;
+ case T_null : return "null"/*nonNLS*/;
+ case T_short : return "((short) 5)"/*nonNLS*/;
+ case T_Object : return "null"/*nonNLS*/;}
+ return ""/*nonNLS*/;}
public final String type(int code){
switch(code){
- case T_boolean : return "z" ; //$NON-NLS-1$
- case T_byte : return "b" ; //$NON-NLS-1$
- case T_char : return "c" ; //$NON-NLS-1$
- case T_double : return "d" ; //$NON-NLS-1$
- case T_float : return "f" ; //$NON-NLS-1$
- case T_int : return "i" ; //$NON-NLS-1$
- case T_long : return "l" ; //$NON-NLS-1$
- case T_String : return "str" ; //$NON-NLS-1$
- case T_null : return "null"; //$NON-NLS-1$
- case T_short : return "s"; //$NON-NLS-1$
- case T_Object : return "obj";} //$NON-NLS-1$
- return "xxx";} //$NON-NLS-1$
+ case T_boolean : return "z"/*nonNLS*/ ;
+ case T_byte : return "b"/*nonNLS*/ ;
+ case T_char : return "c"/*nonNLS*/ ;
+ case T_double : return "d"/*nonNLS*/ ;
+ case T_float : return "f"/*nonNLS*/ ;
+ case T_int : return "i"/*nonNLS*/ ;
+ case T_long : return "l"/*nonNLS*/ ;
+ case T_String : return "str"/*nonNLS*/ ;
+ case T_null : return "null"/*nonNLS*/;
+ case T_short : return "s"/*nonNLS*/;
+ case T_Object : return "obj"/*nonNLS*/;}
+ return "xxx"/*nonNLS*/;}
public final String operator(int operator){
switch (operator) {
- case EQUAL_EQUAL : return "=="; //$NON-NLS-1$
- case LESS_EQUAL : return "<="; //$NON-NLS-1$
- case GREATER_EQUAL :return ">="; //$NON-NLS-1$
- case LEFT_SHIFT : return "<<"; //$NON-NLS-1$
- case RIGHT_SHIFT : return ">>"; //$NON-NLS-1$
- case UNSIGNED_RIGHT_SHIFT : return ">>>"; //$NON-NLS-1$
- case OR_OR :return "||"; //$NON-NLS-1$
- case AND_AND : return "&&"; //$NON-NLS-1$
- case PLUS : return "+"; //$NON-NLS-1$
- case MINUS : return "-"; //$NON-NLS-1$
- case NOT : return "!"; //$NON-NLS-1$
- case REMAINDER : return "%"; //$NON-NLS-1$
- case XOR : return "^"; //$NON-NLS-1$
- case AND : return "&"; //$NON-NLS-1$
- case MULTIPLY : return "*"; //$NON-NLS-1$
- case OR : return "|"; //$NON-NLS-1$
- case TWIDDLE : return "~"; //$NON-NLS-1$
- case DIVIDE : return "/"; //$NON-NLS-1$
- case GREATER : return ">"; //$NON-NLS-1$
- case LESS : return "<"; }; //$NON-NLS-1$
- return "????";} //$NON-NLS-1$
+ case EQUAL_EQUAL : return "=="/*nonNLS*/;
+ case LESS_EQUAL : return "<="/*nonNLS*/;
+ case GREATER_EQUAL :return ">="/*nonNLS*/;
+ case LEFT_SHIFT : return "<<"/*nonNLS*/;
+ case RIGHT_SHIFT : return ">>"/*nonNLS*/;
+ case UNSIGNED_RIGHT_SHIFT : return ">>>"/*nonNLS*/;
+ case OR_OR :return "||"/*nonNLS*/;
+ case AND_AND : return "&&"/*nonNLS*/;
+ case PLUS : return "+"/*nonNLS*/;
+ case MINUS : return "-"/*nonNLS*/;
+ case NOT : return "!"/*nonNLS*/;
+ case REMAINDER : return "%"/*nonNLS*/;
+ case XOR : return "^"/*nonNLS*/;
+ case AND : return "&"/*nonNLS*/;
+ case MULTIPLY : return "*"/*nonNLS*/;
+ case OR : return "|"/*nonNLS*/;
+ case TWIDDLE : return "~"/*nonNLS*/;
+ case DIVIDE : return "/"/*nonNLS*/;
+ case GREATER : return ">"/*nonNLS*/;
+ case LESS : return "<"/*nonNLS*/; };
+ return "????"/*nonNLS*/;}
}
Decode decode = new Decode();
String s ;
- s = "\tpublic static void binaryOperationTablesTestCase(){\n" + //$NON-NLS-1$
+ s = "\tpublic static void binaryOperationTablesTestCase(){\n"/*nonNLS*/ +
- "\t\t//TC test : all binary operation (described in tables)\n"+ //$NON-NLS-1$
- "\t\t//method automatically generated by\n"+ //$NON-NLS-1$
- "\t\t//org.eclipse.jdt.internal.compiler.ast.OperatorExpression.generateTableTestCase();\n"+ //$NON-NLS-1$
+ "\t\t//TC test : all binary operation (described in tables)\n"/*nonNLS*/+
+ "\t\t//method automatically generated by\n"/*nonNLS*/+
+ "\t\t//org.eclipse.jdt.internal.compiler.ast.OperatorExpression.generateTableTestCase();\n"/*nonNLS*/+
- "\t\tString str0 ;\t String str\t= "+decode.constant(T_String)+";\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tint i0 ;\t int i\t= "+decode.constant(T_int)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tboolean z0;\t boolean z\t= "+decode.constant(T_boolean)+";\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tchar c0; \t char c\t= "+decode.constant(T_char)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tfloat f0; \t float f\t= "+decode.constant(T_float)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tdouble d0;\t double d\t= "+decode.constant(T_double)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tbyte b0; \t byte b\t= "+decode.constant(T_byte)+";\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tshort s0; \t short s\t= "+decode.constant(T_short)+";\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tlong l0; \t long l\t= "+decode.constant(T_long)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
- "\t\tObject obj0; \t Object obj\t= "+decode.constant(T_Object)+" ;\n"+ //$NON-NLS-1$ //$NON-NLS-2$
+ "\t\tString str0 ;\t String str\t= "/*nonNLS*/+decode.constant(T_String)+";\n"/*nonNLS*/+
+ "\t\tint i0 ;\t int i\t= "/*nonNLS*/+decode.constant(T_int)+" ;\n"/*nonNLS*/+
+ "\t\tboolean z0;\t boolean z\t= "/*nonNLS*/+decode.constant(T_boolean)+";\n"/*nonNLS*/+
+ "\t\tchar c0; \t char c\t= "/*nonNLS*/+decode.constant(T_char)+" ;\n"/*nonNLS*/+
+ "\t\tfloat f0; \t float f\t= "/*nonNLS*/+decode.constant(T_float)+" ;\n"/*nonNLS*/+
+ "\t\tdouble d0;\t double d\t= "/*nonNLS*/+decode.constant(T_double)+" ;\n"/*nonNLS*/+
+ "\t\tbyte b0; \t byte b\t= "/*nonNLS*/+decode.constant(T_byte)+";\n"/*nonNLS*/+
+ "\t\tshort s0; \t short s\t= "/*nonNLS*/+decode.constant(T_short)+";\n"/*nonNLS*/+
+ "\t\tlong l0; \t long l\t= "/*nonNLS*/+decode.constant(T_long)+" ;\n"/*nonNLS*/+
+ "\t\tObject obj0; \t Object obj\t= "/*nonNLS*/+decode.constant(T_Object)+" ;\n"/*nonNLS*/+
- "\n"; //$NON-NLS-1$
+ "\n"/*nonNLS*/;
int error = 0;
for (int i=0; i < operators.length ; i++)
@@ -142,19 +142,19 @@ public static final String generateTableTestCase(){
// if ( z0 != (((short) 5) >= ((short) 5)))
// System.out.println(155);
- { s += "\t\t"+decode.type(result)+"0"+" = "+decode.type(left); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
- s += " "+decode.operator(operator)+" "+decode.type(right)+";\n"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
- String begin = result == T_String ? "\t\tif (! " : "\t\tif ( "; //$NON-NLS-2$ //$NON-NLS-1$
- String test = result == T_String ? ".equals(" : " != (" ; //$NON-NLS-2$ //$NON-NLS-1$
- s += begin +decode.type(result)+"0"+test //$NON-NLS-1$
- +decode.constant(left)+" " //$NON-NLS-1$
- +decode.operator(operator)+" " //$NON-NLS-1$
- +decode.constant(right)+"))\n"; //$NON-NLS-1$
- s += "\t\t\tSystem.out.println("+ (++error) +");\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ { s += "\t\t"/*nonNLS*/+decode.type(result)+"0"/*nonNLS*/+" = "/*nonNLS*/+decode.type(left);
+ s += " "/*nonNLS*/+decode.operator(operator)+" "/*nonNLS*/+decode.type(right)+";\n"/*nonNLS*/;
+ String begin = result == T_String ? "\t\tif (! "/*nonNLS*/ : "\t\tif ( "/*nonNLS*/;
+ String test = result == T_String ? ".equals("/*nonNLS*/ : " != ("/*nonNLS*/ ;
+ s += begin +decode.type(result)+"0"/*nonNLS*/+test
+ +decode.constant(left)+" "/*nonNLS*/
+ +decode.operator(operator)+" "/*nonNLS*/
+ +decode.constant(right)+"))\n"/*nonNLS*/;
+ s += "\t\t\tSystem.out.println("/*nonNLS*/+ (++error) +");\n"/*nonNLS*/;
}}}
- return s += "\n\t\tSystem.out.println(\"binary tables test : done\");}" ; //$NON-NLS-1$
+ return s += "\n\t\tSystem.out.println(\"binary tables test : done\");}"/*nonNLS*/ ;
}
public static final int[] get_AND(){
@@ -1539,60 +1539,60 @@ public static final int[] get_XOR(){
public String operatorToString() {
switch ((bits & OperatorMASK) >> OperatorSHIFT) {
case EQUAL_EQUAL :
- return "=="; //$NON-NLS-1$
+ return "=="/*nonNLS*/;
case LESS_EQUAL :
- return "<="; //$NON-NLS-1$
+ return "<="/*nonNLS*/;
case GREATER_EQUAL :
- return ">="; //$NON-NLS-1$
+ return ">="/*nonNLS*/;
case NOT_EQUAL :
- return "!="; //$NON-NLS-1$
+ return "!="/*nonNLS*/;
case LEFT_SHIFT :
- return "<<"; //$NON-NLS-1$
+ return "<<"/*nonNLS*/;
case RIGHT_SHIFT :
- return ">>"; //$NON-NLS-1$
+ return ">>"/*nonNLS*/;
case UNSIGNED_RIGHT_SHIFT :
- return ">>>"; //$NON-NLS-1$
+ return ">>>"/*nonNLS*/;
case OR_OR :
- return "||"; //$NON-NLS-1$
+ return "||"/*nonNLS*/;
case AND_AND :
- return "&&"; //$NON-NLS-1$
+ return "&&"/*nonNLS*/;
case PLUS :
- return "+"; //$NON-NLS-1$
+ return "+"/*nonNLS*/;
case MINUS :
- return "-"; //$NON-NLS-1$
+ return "-"/*nonNLS*/;
case NOT :
- return "!"; //$NON-NLS-1$
+ return "!"/*nonNLS*/;
case REMAINDER :
- return "%"; //$NON-NLS-1$
+ return "%"/*nonNLS*/;
case XOR :
- return "^"; //$NON-NLS-1$
+ return "^"/*nonNLS*/;
case AND :
- return "&"; //$NON-NLS-1$
+ return "&"/*nonNLS*/;
case MULTIPLY :
- return "*"; //$NON-NLS-1$
+ return "*"/*nonNLS*/;
case OR :
- return "|"; //$NON-NLS-1$
+ return "|"/*nonNLS*/;
case TWIDDLE :
- return "~"; //$NON-NLS-1$
+ return "~"/*nonNLS*/;
case DIVIDE :
- return "/"; //$NON-NLS-1$
+ return "/"/*nonNLS*/;
case GREATER :
- return ">"; //$NON-NLS-1$
+ return ">"/*nonNLS*/;
case LESS :
- return "<"; //$NON-NLS-1$
+ return "<"/*nonNLS*/;
case QUESTIONCOLON :
- return "?:"; //$NON-NLS-1$
+ return "?:"/*nonNLS*/;
case EQUAL :
- return "="; //$NON-NLS-1$
+ return "="/*nonNLS*/;
};
- return "unknown operator"; //$NON-NLS-1$
+ return "unknown operator"/*nonNLS*/;
}
public String toStringExpression(){
/* slow code*/
//subclass redefine toStringExpressionNoParenthesis()
- return "(" + toStringExpressionNoParenthesis() + ")"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "("/*nonNLS*/ + toStringExpressionNoParenthesis() + ")"/*nonNLS*/;
}
public abstract String toStringExpressionNoParenthesis();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
index 75dc1228e5..008c712c44 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
@@ -39,17 +39,17 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
public String operatorToString() {
switch (operator) {
case PLUS :
- return "++"; //$NON-NLS-1$
+ return "++"/*nonNLS*/;
case MINUS :
- return "--";} //$NON-NLS-1$
- return "unknown operator"; //$NON-NLS-1$
+ return "--"/*nonNLS*/;}
+ return "unknown operator"/*nonNLS*/;
}
public boolean restrainUsageToNumericTypes(){
return true ;}
public String toStringExpressionNoParenthesis(){
/* slow code*/
- return lhs.toStringExpression() + " " + operatorToString(); } //$NON-NLS-1$
+ return lhs.toStringExpression() + " "/*nonNLS*/ + operatorToString(); }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
lhs.traverse(visitor, scope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
index df18a476d3..7912487957 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
@@ -23,17 +23,17 @@ public PrefixExpression(Expression l, Expression e, int op, int pos) {
public String operatorToString() {
switch (operator) {
case PLUS :
- return "++"; //$NON-NLS-1$
+ return "++"/*nonNLS*/;
case MINUS :
- return "--";} //$NON-NLS-1$
- return "unknown operator"; //$NON-NLS-1$
+ return "--"/*nonNLS*/;}
+ return "unknown operator"/*nonNLS*/;
}
public boolean restrainUsageToNumericTypes(){
return true ;}
public String toStringExpressionNoParenthesis(){
/* slow code */
- return operatorToString() + " " + lhs.toStringExpression() ; //$NON-NLS-1$
+ return operatorToString() + " "/*nonNLS*/ + lhs.toStringExpression() ;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index f799256856..fc7d922aea 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -238,9 +238,9 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(int tab) {
/*slow code */
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if (enclosingInstance != null)
- s += enclosingInstance.toString() + "."; //$NON-NLS-1$
+ s += enclosingInstance.toString() + "."/*nonNLS*/;
s += super.toStringExpression(tab);
if (anonymousType != null) {
s += anonymousType.toString(tab);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
index 0a4f3a929a..9114662b63 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
@@ -597,7 +597,7 @@ public String toStringExpression() {
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
return buffer.toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
index c95539ec31..7b401150cc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
@@ -36,7 +36,7 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/* slow code */
- return qualification.toString(0)+".super" ; //$NON-NLS-1$
+ return qualification.toString(0)+".super"/*nonNLS*/ ;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
index f06e40f33b..45987d18c2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
@@ -119,7 +119,7 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpression(){
/* slow code */
- return qualification.toString(0)+".this" ; //$NON-NLS-1$
+ return qualification.toString(0)+".this"/*nonNLS*/ ;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
index c7006e55ac..cb2cccaef2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
@@ -41,7 +41,7 @@ public String toStringExpression(int tab) {
for (int i = 0; i < tokens.length; i++) {
buffer.append(tokens[i]);
if (i < (tokens.length - 1)) {
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
}
return buffer.toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
index 1bbc0d348b..04a336f08d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
@@ -19,7 +19,7 @@ public Reference() {
super();
}
public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) {
- throw new ShouldNotImplement(Util.bind("ast.variableShouldProvide")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.variableShouldProvide"/*nonNLS*/));
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
return flowInfo;
@@ -61,13 +61,13 @@ public void fieldStore(CodeStream codeStream, FieldBinding fieldBinding, MethodB
}
}
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.compoundPreShouldProvide")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.compoundPreShouldProvide"/*nonNLS*/));
}
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.compoundVariableShouldProvide")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.compoundVariableShouldProvide"/*nonNLS*/));
}
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.postIncrShouldProvide")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.postIncrShouldProvide"/*nonNLS*/));
}
public boolean isFieldReference() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index 041b3a07fe..e76ddc84fe 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -225,7 +225,7 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab) ;
- s = s + "return "; //$NON-NLS-1$
+ s = s + "return "/*nonNLS*/;
if (expression != null )
s = s + expression.toStringExpression() ;
return s;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 08f540c571..5060063c54 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -33,9 +33,6 @@ public abstract class Statement extends AstNode {
// for statements only
public static final int IsReachableMASK = 0x80000000; // highest bit
-
- // for type declaration only
- public static final int AddAssertionMASK = 1; // highest bit
/*
public final static int BitMask1= 0x1; // decimal 1
@@ -81,7 +78,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
return flowInfo;
}
public void generateCode(BlockScope currentScope, CodeStream codeStream){
- throw new ShouldNotImplement(Util.bind("ast.missingStatement")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("ast.missingStatement"/*nonNLS*/));
}
public boolean isEmptyBlock(){
return false;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
index fb3002d0ca..4f4b257b1d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
@@ -57,38 +57,38 @@ public char[] source() {
public String toStringExpression() {
// handle some special char.....
- StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
+ StringBuffer result = new StringBuffer("\""/*nonNLS*/);
for (int i = 0; i < source.length; i++) {
switch (source[i]) {
case '\b' :
- result.append("\\b"); //$NON-NLS-1$
+ result.append("\\b"/*nonNLS*/);
break;
case '\t' :
- result.append("\\t"); //$NON-NLS-1$
+ result.append("\\t"/*nonNLS*/);
break;
case '\n' :
- result.append("\\n"); //$NON-NLS-1$
+ result.append("\\n"/*nonNLS*/);
break;
case '\f' :
- result.append("\\f"); //$NON-NLS-1$
+ result.append("\\f"/*nonNLS*/);
break;
case '\r' :
- result.append("\\r"); //$NON-NLS-1$
+ result.append("\\r"/*nonNLS*/);
break;
case '\"' :
- result.append("\\\""); //$NON-NLS-1$
+ result.append("\\\""/*nonNLS*/);
break;
case '\'' :
- result.append("\\'"); //$NON-NLS-1$
+ result.append("\\'"/*nonNLS*/);
break;
case '\\' : //take care not to display the escape as a potential real char
- result.append("\\\\"); //$NON-NLS-1$
+ result.append("\\\\"/*nonNLS*/);
break;
default :
result.append(source[i]);
}
}
- result.append("\""); //$NON-NLS-1$
+ result.append("\""/*nonNLS*/);
return result.toString();
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
index 88f0cedd53..83e55fe5d0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
@@ -46,7 +46,7 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression(){
- return "super"; //$NON-NLS-1$
+ return "super"/*nonNLS*/;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index 904357b4c8..61c07768a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -193,6 +193,7 @@ public void resolve(BlockScope upperScope) {
if ((cst = statements[i].resolveCase(scope, testType, this)) != null) {
//----check for duplicate case statement------------
if (cst != NotAConstant) {
+ // a case with a welled typed constant, so intValue() is valid
int key = cst.intValue();
for (int j = 0; j < counter; j++) {
if (casesValues[j] == key) {
@@ -210,41 +211,41 @@ public String toString(int tab){
String inFront , s = tabString(tab) ;
inFront = s ;
- s = s + "switch (" + testExpression.toStringExpression() + ") "; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "switch ("/*nonNLS*/ + testExpression.toStringExpression() + ") "/*nonNLS*/;
if (statements == null)
- { s = s + "{}" ; //$NON-NLS-1$
+ { s = s + "{}"/*nonNLS*/ ;
return s;}
else
- s = s + "{"; //$NON-NLS-1$
+ s = s + "{"/*nonNLS*/;
s = s + (explicitDeclarations != 0
- ? "// ---scope needed for "+String.valueOf(explicitDeclarations) +" locals------------ \n" //$NON-NLS-2$ //$NON-NLS-1$
- : "// ---NO scope needed------ \n") ; //$NON-NLS-1$
+ ? "// ---scope needed for "/*nonNLS*/+String.valueOf(explicitDeclarations) +" locals------------ \n"/*nonNLS*/
+ : "// ---NO scope needed------ \n"/*nonNLS*/) ;
int i = 0;
- String tabulation = " "; //$NON-NLS-1$
+ String tabulation = " "/*nonNLS*/;
try {while(true){
//use instanceof in order not to polluate classes with behavior only needed for printing purpose.
if ( statements[i] instanceof Expression)
- s = s + "\n" + inFront + tabulation; //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + inFront + tabulation;
if ( statements[i] instanceof Break)
s = s + statements[i].toString(0) ;
else
- s = s + "\n" + statements[i].toString(tab+2) ; //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + statements[i].toString(tab+2) ;
//=============
if ( (statements[i] instanceof Case) || (statements[i] instanceof DefaultCase))
{ i++;
while(! ((statements[i] instanceof Case) || (statements[i] instanceof DefaultCase)))
{ if ( (statements[i] instanceof Expression) || (statements[i] instanceof Break))
- s = s + statements[i].toString(0) +" ; "; //$NON-NLS-1$
+ s = s + statements[i].toString(0) +" ; "/*nonNLS*/;
else
- s = s + "\n" + statements[i].toString(tab+6) + " ; "; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "\n"/*nonNLS*/ + statements[i].toString(tab+6) + " ; "/*nonNLS*/;
i++;}}
else
- { s = s + " ;" ; //$NON-NLS-1$
+ { s = s + " ;"/*nonNLS*/ ;
i++;}}}
catch(IndexOutOfBoundsException e){};
- s = s + "}"; //$NON-NLS-1$
+ s = s + "}"/*nonNLS*/;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
index 37d2ab7742..dc7cbe9075 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
@@ -17,7 +17,7 @@ public class SynchronizedStatement extends Statement {
boolean blockExit;
public LocalVariableBinding synchroVariable;
- static final char[] SecretLocalDeclarationName = " syncValue".toCharArray(); //$NON-NLS-1$
+ static final char[] SecretLocalDeclarationName = " syncValue"/*nonNLS*/.toCharArray();
public SynchronizedStatement(Expression expression , Block statement, int s, int e) {
this.expression = expression;
@@ -73,6 +73,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
// generate the body of the synchronized block
ExceptionLabel anyExceptionHandler = new ExceptionLabel(codeStream, null); //'null' denotes any kind of exception
block.generateCode(scope, codeStream);
+ anyExceptionHandler.placeEnd();
Label endLabel = new Label(codeStream);
if (!blockExit) {
codeStream.load(synchroVariable);
@@ -80,7 +81,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
codeStream.goto_(endLabel);
}
// generate the body of the exception handler
- anyExceptionHandler.placeEnd();
anyExceptionHandler.place();
codeStream.incrStackSize(1);
codeStream.load(synchroVariable);
@@ -128,8 +128,8 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab) ;
- s = s + "synchronized (" + expression.toStringExpression() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- s = s + "\n" + block.toString(tab+1) ; //$NON-NLS-1$
+ s = s + "synchronized ("/*nonNLS*/ + expression.toStringExpression() + ")"/*nonNLS*/;
+ s = s + "\n"/*nonNLS*/ + block.toString(tab+1) ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
index 366c46ae4f..e9cf7e2522 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
@@ -56,8 +56,8 @@ public TypeBinding resolveType(BlockScope scope) {
}
public String toStringExpression(){
- if (this == ThisImplicit) return "" ; //$NON-NLS-1$
- return "this"; //$NON-NLS-1$
+ if (this == ThisImplicit) return ""/*nonNLS*/ ;
+ return "this"/*nonNLS*/;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
visitor.visit(this, blockScope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
index 3ff90d53b1..f1adeb7a67 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
@@ -13,54 +13,57 @@ import org.eclipse.jdt.internal.compiler.lookup.*;
public class ThrowStatement extends Statement {
public Expression exception;
public TypeBinding exceptionType;
+public ThrowStatement(Expression exception,int startPosition) {
+ this.exception = exception;
+ this.sourceStart = startPosition ;
+ this.sourceEnd = exception.sourceEnd ;
+}
+public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
- public ThrowStatement(Expression exception, int startPosition) {
- this.exception = exception;
- this.sourceStart = startPosition;
- this.sourceEnd = exception.sourceEnd;
- }
-
- public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
-
- exception.analyseCode(currentScope, flowContext, flowInfo);
- // need to check that exception thrown is actually caught somewhere
- flowContext.checkExceptionHandlers(exceptionType, this, flowInfo, currentScope);
- return FlowInfo.DeadEnd;
- }
+ // need to check that exception thrown is actually caught somewhere
- /**
- * Throw 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 ((bits & IsReachableMASK) == 0)
- return;
- int pc = codeStream.position;
- exception.generateCode(currentScope, codeStream, true);
- codeStream.athrow();
- codeStream.recordPositionsFrom(pc, this);
- }
-
- public void resolve(BlockScope scope) {
- exceptionType = exception.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
- if (exceptionType == NullBinding)
- scope.problemReporter().cannotThrowNull(this);
- exception.implicitWidening(exceptionType, exceptionType);
- }
+ exception.analyseCode(currentScope, flowContext, flowInfo);
+ flowContext.checkExceptionHandlers(exceptionType, this, flowInfo, currentScope);
+ return FlowInfo.DeadEnd;
+}
+/**
+ * Throw 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) {
- public String toString(int tab) {
- String s = tabString(tab);
- s = s + "throw "; //$NON-NLS-1$
- s = s + exception.toStringExpression();
- return s;
+ if ((bits & IsReachableMASK) == 0) {
+ return;
}
+ int pc = codeStream.position;
+ exception.generateCode(currentScope, codeStream, true);
+ codeStream.athrow();
+ codeStream.recordPositionsFrom(pc, this);
+
+}
+public void resolve(BlockScope scope) {
+ exceptionType = exception.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
+ if (exceptionType == NullBinding)
+ scope.problemReporter().cannotThrowNull(this);
+ exception.implicitWidening(exceptionType, exceptionType);
+}
+/* SHOULDN'T IT RATHER DO -
+scope.checkThrowable(exceptionType = expression.resolveType(scope));
+*/
+public String toString(int tab){
+ /* slow code */
- public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
- if (visitor.visit(this, blockScope))
- exception.traverse(visitor, blockScope);
- visitor.endVisit(this, blockScope);
+ String s = tabString(tab) ;
+ s = s + "throw "/*nonNLS*/;
+ s = s + exception.toStringExpression() ;
+ return s;
+}
+public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
+ if (visitor.visit(this, blockScope)) {
+ exception.traverse(visitor, blockScope);
}
-} \ No newline at end of file
+ visitor.endVisit(this, blockScope);
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index 7531da270b..f2f4815f6d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -29,8 +29,8 @@ public class TryStatement extends Statement {
Label subRoutineStartLabel;
LocalVariableBinding anyExceptionVariable, returnAddressVariable;
- final static char[] SecretReturnName = " returnAddress".toCharArray() ; //$NON-NLS-1$
- final static char[] SecretAnyHandlerName = " anyExceptionHandler".toCharArray(); //$NON-NLS-1$
+ final static char[] SecretReturnName = " returnAddress"/*nonNLS*/.toCharArray() ;
+ final static char[] SecretAnyHandlerName = " anyExceptionHandler"/*nonNLS*/.toCharArray();
// for local variables table attributes
int preTryInitStateIndex = -1;
@@ -374,24 +374,24 @@ public String toString(int tab){
String s = tabString(tab) ;
//try
- s = s + "try " ; //$NON-NLS-1$
+ s = s + "try "/*nonNLS*/ ;
if (tryBlock == Block.None)
- s =s + "{}" ; //$NON-NLS-1$
+ s =s + "{}"/*nonNLS*/ ;
else
- s = s + "\n" + tryBlock.toString(tab+1) ; //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + tryBlock.toString(tab+1) ;
//catches
if (catchBlocks != null)
for (int i = 0; i < catchBlocks.length ; i++)
- s = s + "\n" + tabString(tab) + "catch (" //$NON-NLS-2$ //$NON-NLS-1$
- + catchArguments[i].toString(0) + ") " //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + tabString(tab) + "catch ("/*nonNLS*/
+ + catchArguments[i].toString(0) + ") "/*nonNLS*/
+ catchBlocks[i].toString(tab+1) ;
//finally
if (finallyBlock != null)
{ if (finallyBlock == Block.None)
- s = s + "\n" + tabString(tab)+ "finally {}" ; //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + tabString(tab)+ "finally {}"/*nonNLS*/ ;
else
- s = s + "\n" + tabString(tab)+ "finally\n" + //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + tabString(tab)+ "finally\n"/*nonNLS*/ +
finallyBlock.toString(tab+1) ;}
return s ;}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 8bc813f22f..38705e1b9c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -33,7 +33,6 @@ public class TypeDeclaration extends Statement implements ProblemSeverities, Ref
public int declarationSourceStart ;
public int declarationSourceEnd ;
public int bodyStart;
-
/*
* We cause the compilation task to abort to a given extent.
*/
@@ -651,9 +650,6 @@ public final boolean needClassInitMethod() {
return false ;}
----------------------------------------------------*/
- if ((this.bits & AddAssertionMASK) != 0) {
- return true;
- }
if (fields == null)
return false;
if (isInterface()) return true; // fields are implicitly statics
@@ -777,48 +773,48 @@ public String toString(int tab ){
public String toStringBody(int tab) {
/*slow code */
- String s = " {"; //$NON-NLS-1$
+ String s = " {"/*nonNLS*/;
if (memberTypes != null) {
for (int i = 0; i < memberTypes.length; i++) {
if (memberTypes[i] != null) {
- s += "\n" + memberTypes[i].toString(tab + 1); //$NON-NLS-1$
+ s += "\n"/*nonNLS*/ + memberTypes[i].toString(tab + 1);
}
}
}
if (fields != null) {
for (int fieldI = 0; fieldI < fields.length; fieldI++) {
if (fields[fieldI] != null) {
- s += "\n" + fields[fieldI].toString(tab + 1); //$NON-NLS-1$
- if (fields[fieldI].isField()) s += ";"; //$NON-NLS-1$
+ s += "\n"/*nonNLS*/ + fields[fieldI].toString(tab + 1);
+ if (fields[fieldI].isField()) s += ";"/*nonNLS*/;
}
}
}
if (methods != null) {
for (int i = 0; i < methods.length; i++) {
if (methods[i] != null) {
- s += "\n" + methods[i].toString(tab + 1); //$NON-NLS-1$
+ s += "\n"/*nonNLS*/ + methods[i].toString(tab + 1);
}
}
}
- s += "\n"+tabString(tab) + "}"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += "\n"/*nonNLS*/+tabString(tab) + "}"/*nonNLS*/;
return s;
}
public String toStringHeader() {
/*slow code */
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
if (modifiers != AccDefault) {
s += modifiersString(modifiers);
}
- s += (isInterface() ? "interface " : "class ") + new String(name); //$NON-NLS-1$ //$NON-NLS-2$
+ s += (isInterface() ? "interface "/*nonNLS*/ : "class "/*nonNLS*/) + new String(name);
if (superclass != null)
- s += " extends " + superclass.toString(0); //$NON-NLS-1$
+ s += " extends "/*nonNLS*/ + superclass.toString(0);
if (superInterfaces != null && superInterfaces.length > 0) {
- s += (isInterface() ? " extends " : " implements "); //$NON-NLS-2$ //$NON-NLS-1$
+ s += (isInterface() ? " extends "/*nonNLS*/ : " implements "/*nonNLS*/);
for (int i = 0; i < superInterfaces.length; i++) {
s += superInterfaces[i].toString(0);
if (i != superInterfaces.length-1)
- s += ", "; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
};
};
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
index 3093dd5036..d99021d677 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
@@ -245,7 +245,7 @@ public TypeBinding resolveType(BlockScope scope) {
public String toStringExpressionNoParenthesis(){
/* slow code*/
- return operatorToString() + " " + expression.toStringExpression() ; } //$NON-NLS-1$
+ return operatorToString() + " "/*nonNLS*/ + expression.toStringExpression() ; }
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
expression.traverse(visitor, blockScope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
index 86df1fcb60..b879a0c440 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
@@ -149,14 +149,14 @@ public String toString(int tab){
/* slow code */
String s = tabString(tab) ;
- s = s + "while (" + condition.toStringExpression() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "while ("/*nonNLS*/ + condition.toStringExpression() + ")"/*nonNLS*/;
if (action == null)
- s = s + " {} ;"; //$NON-NLS-1$
+ s = s + " {} ;"/*nonNLS*/;
else
if (action instanceof Block)
- s = s + "\n" + action.toString(tab+1) ; //$NON-NLS-1$
+ s = s + "\n"/*nonNLS*/ + action.toString(tab+1) ;
else
- s = s + " {\n" + action.toString(tab+1) + "}" ; //$NON-NLS-2$ //$NON-NLS-1$
+ s = s + " {\n"/*nonNLS*/ + action.toString(tab+1) + "}"/*nonNLS*/ ;
return s;}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
if (visitor.visit(this, blockScope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
index 24acdb2828..1a19a46e5f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
@@ -4,15 +4,12 @@ package org.eclipse.jdt.internal.compiler.classfmt;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.impl.NullConstant;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+
import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.codegen.*;
import java.io.*;
-import java.util.Arrays;
public class ClassFileReader extends ClassFileStruct implements AttributeNamesConstants, IBinaryType {
private int constantPoolCount;
@@ -511,216 +508,12 @@ public String toString() {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
java.io.PrintWriter print = new java.io.PrintWriter(out);
- print.println(this.getClass().getName() + "{"); //$NON-NLS-1$
- print.println(" className: " + new String(getName())); //$NON-NLS-1$
- print.println(" superclassName: " + (getSuperclassName() == null ? "null" : new String(getSuperclassName()))); //$NON-NLS-2$ //$NON-NLS-1$
- print.println(" access_flags: " + ClassFileStruct.printTypeModifiers(accessFlags()) + "(" + accessFlags() + ")"); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
+ print.println(this.getClass().getName() + "{"/*nonNLS*/);
+ print.println(" className: "/*nonNLS*/ + new String(getName()));
+ print.println(" superclassName: "/*nonNLS*/ + (getSuperclassName() == null ? "null"/*nonNLS*/ : new String(getSuperclassName())));
+ print.println(" access_flags: "/*nonNLS*/ + ClassFileStruct.printTypeModifiers(accessFlags()) + "("/*nonNLS*/ + accessFlags() + ")"/*nonNLS*/);
print.flush();
return out.toString();
}
-/**
- * Check if the receiver has structural changes compare to the byte array in argument.
- * Structural changes are:
- * - modifiers changes for the class, the fields or the methods
- * - signature changes for fields or methods.
- * - changes in the number of fields or methods
- * - changes for field constants
- * - changes for thrown exceptions
- * - change for the super class or any super interfaces.
- * - changes for member types name or modifiers
- * If any of these changes occurs, the method returns true. false otherwise.
- */
-public boolean hasStructuralChanges(byte[] newBytes) {
- try {
- ClassFileReader newClassFile =
- new ClassFileReader(newBytes, this.classFileName);
- // type level comparison
- // modifiers
- if (this.getModifiers() != newClassFile.getModifiers()) {
- return true;
- }
- // superclass
- if (!CharOperation.equals(this.getSuperclassName(), newClassFile.getSuperclassName())) {
- return true;
- }
- // interfaces
- char[][] newInterfacesNames = newClassFile.getInterfaceNames();
- int newInterfacesLength = newInterfacesNames == null ? 0 : newInterfacesNames.length;
- if (newInterfacesLength != this.interfacesCount) {
- return true;
- }
- if (this.interfacesCount != 0) {
- for (int i = 0, max = this.interfacesCount; i < max; i++) {
- if (!CharOperation.equals(this.interfaceNames[i], newInterfacesNames[i])) {
- return true;
- }
- }
- }
- // fields
- FieldInfo[] otherFieldInfos = (FieldInfo[]) newClassFile.getFields();
- int otherFieldInfosLength = otherFieldInfos == null ? 0 : otherFieldInfos.length;
- if (this.fieldsCount != otherFieldInfosLength) {
- return true;
- }
- if (otherFieldInfosLength != 0) {
-// Arrays.sort(this.fields);
-// Arrays.sort(otherFieldInfos);
- for (int i = 0; i < otherFieldInfosLength; i++) {
- FieldInfo currentFieldInfo = this.fields[i];
- FieldInfo otherFieldInfo = otherFieldInfos[i];
- if (currentFieldInfo.getModifiers() != otherFieldInfo.getModifiers()) {
- return true;
- }
- if (!CharOperation.equals(currentFieldInfo.getName(), otherFieldInfo.getName())) {
- return true;
- }
- if (!CharOperation.equals(currentFieldInfo.getTypeName(), otherFieldInfo.getTypeName())) {
- return true;
- }
- if (currentFieldInfo.hasConstant()) {
- if (!otherFieldInfo.hasConstant()) {
- return true;
- }
- Constant currentConstant = currentFieldInfo.getConstant();
- Constant otherConstant = otherFieldInfo.getConstant();
- if (!currentConstant.getClass().equals(otherConstant.getClass())) {
- return true;
- }
- switch (currentConstant.typeID()) {
- case TypeIds.T_int :
- if (otherConstant.typeID() != TypeIds.T_int) {
- return true;
- }
- if (otherConstant.intValue() != currentConstant.intValue()) {
- return true;
- }
- break;
- case TypeIds.T_byte :
- if (otherConstant.typeID() != TypeIds.T_byte) {
- return true;
- }
- if (otherConstant.byteValue() != currentConstant.byteValue()) {
- return true;
- }
- break;
- case TypeIds.T_short :
- if (otherConstant.typeID() != TypeIds.T_short) {
- return true;
- }
- if (otherConstant.shortValue() != currentConstant.shortValue()) {
- return true;
- }
- break;
- case TypeIds.T_char :
- if (otherConstant.typeID() != TypeIds.T_char) {
- return true;
- }
- if (otherConstant.charValue() != currentConstant.charValue()) {
- return true;
- }
- break;
- case TypeIds.T_float :
- if (otherConstant.typeID() != TypeIds.T_float) {
- return true;
- }
- if (otherConstant.floatValue() != currentConstant.floatValue()) {
- return true;
- }
- break;
- case TypeIds.T_double :
- if (otherConstant.typeID() != TypeIds.T_double) {
- return true;
- }
- if (otherConstant.doubleValue() != currentConstant.doubleValue()) {
- return true;
- }
- break;
- case TypeIds.T_boolean :
- if (otherConstant.typeID() != TypeIds.T_boolean) {
- return true;
- }
- if (otherConstant.booleanValue() != currentConstant.booleanValue()) {
- return true;
- }
- break;
- case TypeIds.T_String :
- if (otherConstant.typeID() != TypeIds.T_String) {
- return true;
- }
- if (otherConstant.stringValue() != currentConstant.stringValue()) {
- return true;
- }
- break;
- case TypeIds.T_null :
- if (otherConstant.typeID() != TypeIds.T_null) {
- return true;
- }
- if (otherConstant != NullConstant.Default) {
- return true;
- }
- }
- } else if (otherFieldInfo.hasConstant()) {
- return true;
- }
- }
- }
- // methods
- MethodInfo[] otherMethodInfos = (MethodInfo[]) newClassFile.getMethods();
- int otherMethodInfosLength = otherMethodInfos == null ? 0 : otherMethodInfos.length;
- if (this.methodsCount != otherMethodInfosLength) {
- return true;
- }
- if (otherMethodInfosLength != 0) {
-// Arrays.sort(this.methods);
-// Arrays.sort(otherMethodInfos);
- for (int i = 0; i < otherMethodInfosLength; i++) {
- MethodInfo otherMethodInfo = otherMethodInfos[i];
- MethodInfo currentMethodInfo = this.methods[i];
- if (otherMethodInfo.getModifiers() != currentMethodInfo.getModifiers()) {
- return true;
- }
- if (!CharOperation.equals(otherMethodInfo.getSelector(), currentMethodInfo.getSelector())) {
- return true;
- }
- if (!CharOperation.equals(otherMethodInfo.getMethodDescriptor(), currentMethodInfo.getMethodDescriptor())) {
- return true;
- }
- char[][] otherThrownExceptions = otherMethodInfo.getExceptionTypeNames();
- int otherThrownExceptionsLength = otherThrownExceptions == null ? 0 : otherThrownExceptions.length;
- char[][] currentThrownExceptions = currentMethodInfo.getExceptionTypeNames();
- int currentThrownExceptionsLength = currentThrownExceptions == null ? 0 : currentThrownExceptions.length;
- if (currentThrownExceptionsLength != otherThrownExceptionsLength) {
- return true;
- }
- if (currentThrownExceptionsLength != 0) {
- for (int k = 0; k < currentThrownExceptionsLength; k++) {
- if (!CharOperation.equals(currentThrownExceptions[k], otherThrownExceptions[k])) {
- return true;
- }
- }
- }
- }
- }
- // Member types
- InnerClassInfo[] currentMemberTypes = (InnerClassInfo[]) this.getMemberTypes();
- InnerClassInfo[] otherMemberTypes = (InnerClassInfo[]) newClassFile.getMemberTypes();
- int currentMemberTypeLength = currentMemberTypes == null ? 0 : currentMemberTypes.length;
- int otherMemberTypeLength = otherMemberTypes == null ? 0 : otherMemberTypes.length;
- if (currentMemberTypeLength != otherMemberTypeLength) {
- return true;
- }
- if (currentMemberTypeLength != 0) {
- for (int i = 0; i < currentMemberTypeLength; i++) {
- if (!CharOperation.equals(currentMemberTypes[i].getName(), otherMemberTypes[i].getName())
- || currentMemberTypes[i].getModifiers() != otherMemberTypes[i].getModifiers()) {
- return true;
- }
- }
- }
- return false;
- } catch (ClassFormatException e) {
- return true;
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
index b0bc498ae8..1ff4e1ff77 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
@@ -114,12 +114,12 @@ public static String printTypeModifiers(int modifiers) {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
java.io.PrintWriter print = new java.io.PrintWriter(out);
- if ((modifiers & AccPublic) != 0) print.print("public "); //$NON-NLS-1$
- if ((modifiers & AccPrivate) != 0) print.print("private "); //$NON-NLS-1$
- if ((modifiers & AccFinal) != 0) print.print("final "); //$NON-NLS-1$
- if ((modifiers & AccSuper) != 0) print.print("super "); //$NON-NLS-1$
- if ((modifiers & AccInterface) != 0) print.print("interface "); //$NON-NLS-1$
- if ((modifiers & AccAbstract) != 0) print.print("abstract "); //$NON-NLS-1$
+ if ((modifiers & AccPublic) != 0) print.print("public "/*nonNLS*/);
+ if ((modifiers & AccPrivate) != 0) print.print("private "/*nonNLS*/);
+ if ((modifiers & AccFinal) != 0) print.print("final "/*nonNLS*/);
+ if ((modifiers & AccSuper) != 0) print.print("super "/*nonNLS*/);
+ if ((modifiers & AccInterface) != 0) print.print("interface "/*nonNLS*/);
+ if ((modifiers & AccAbstract) != 0) print.print("abstract "/*nonNLS*/);
print.flush();
return out.toString();
}
@@ -270,7 +270,7 @@ public static void verifyMethodNameAndSignature(char[] name, char[] signature) t
// if name begins with the < character it must be clinit or init
if (name[0] == '<') {
- if (new String(name).equals("<clinit>") || new String(name).equals("<init>")) { //$NON-NLS-2$ //$NON-NLS-1$
+ if (new String(name).equals("<clinit>"/*nonNLS*/) || new String(name).equals("<init>"/*nonNLS*/)) {
int signatureLength = signature.length;
if (!((signatureLength > 2)
&& (signature[0] == '(')
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
index 5f4676f148..0c371b578c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
@@ -11,7 +11,7 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.util.*;
-public class FieldInfo extends ClassFileStruct implements AttributeNamesConstants, IBinaryField, Comparable {
+public class FieldInfo extends ClassFileStruct implements AttributeNamesConstants, IBinaryField {
private Constant constant;
private boolean isDeprecated;
private int[] constantPoolOffsets;
@@ -38,8 +38,8 @@ public FieldInfo (byte classFileBytes[], int offsets[], int offset) throws Class
}
/**
* Return the constant of the field.
- * Return org.eclipse.jdt.internal.compiler.impl.Constant.NotAConstant if there is none.
- * @return org.eclipse.jdt.internal.compiler.impl.Constant
+ * Return org.eclipse.jdt.internal.compiler.Constant.NotAConstant if there is none.
+ * @return org.eclipse.jdt.internal.compiler.Constant
*/
public Constant getConstant() {
if (constant == null) {
@@ -261,29 +261,22 @@ public String toString() {
StringBuffer buffer = new StringBuffer(this.getClass().getName());
int modifiers = getModifiers();
return buffer
- .append("{") //$NON-NLS-1$
+ .append("{"/*nonNLS*/)
.append(
- ((modifiers & AccDeprecated) != 0 ? "deprecated " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0001) == 1 ? "public " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0002) == 0x0002 ? "private " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0004) == 0x0004 ? "protected " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0008) == 0x000008 ? "static " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0010) == 0x0010 ? "final " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0040) == 0x0040 ? "volatile " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0080) == 0x0080 ? "transient " : "")) //$NON-NLS-1$ //$NON-NLS-2$
+ ((modifiers & AccDeprecated) != 0 ? "deprecated "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0001) == 1 ? "public "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0002) == 0x0002 ? "private "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0004) == 0x0004 ? "protected "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0008) == 0x000008 ? "static "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0010) == 0x0010 ? "final "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0040) == 0x0040 ? "volatile "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0080) == 0x0080 ? "transient "/*nonNLS*/ : ""/*nonNLS*/))
.append(getTypeName())
- .append(" ") //$NON-NLS-1$
+ .append(" "/*nonNLS*/)
.append(getName())
- .append(" ") //$NON-NLS-1$
+ .append(" "/*nonNLS*/)
.append(getConstant())
- .append("}") //$NON-NLS-1$
+ .append("}"/*nonNLS*/)
.toString();
}
-
-public int compareTo(Object o) {
- if (!(o instanceof FieldInfo)) {
- throw new ClassCastException();
- }
- return new String(this.getName()).compareTo(new String(((FieldInfo) o).getName()));
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
index ea42789448..3cc4f942a1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
@@ -109,11 +109,11 @@ public String toString() {
if (getName() != null) {
buffer.append(getName());
}
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
if (getEnclosingTypeName() != null) {
buffer.append(getEnclosingTypeName());
}
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
if (getSourceName() != null) {
buffer.append(getSourceName());
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index 9e806b029e..06146a5e8a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -10,7 +10,7 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.util.*;
-public class MethodInfo extends ClassFileStruct implements IBinaryMethod, AttributeNamesConstants, Comparable {
+public class MethodInfo extends ClassFileStruct implements IBinaryMethod, AttributeNamesConstants {
private char[][] exceptionNames;
private int[] constantPoolOffsets;
private boolean isDeprecated;
@@ -192,30 +192,19 @@ public String toString() {
int modifiers = getModifiers();
StringBuffer buffer = new StringBuffer(this.getClass().getName());
return buffer
- .append("{") //$NON-NLS-1$
+ .append("{"/*nonNLS*/)
.append(
- ((modifiers & AccDeprecated) != 0 ? "deprecated " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0001) == 1 ? "public " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0002) == 0x0002 ? "private " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0004) == 0x0004 ? "protected " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0008) == 0x000008 ? "static " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0010) == 0x0010 ? "final " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0040) == 0x0040 ? "volatile " : "") //$NON-NLS-1$ //$NON-NLS-2$
- + ((modifiers & 0x0080) == 0x0080 ? "transient " : "")) //$NON-NLS-1$ //$NON-NLS-2$
+ ((modifiers & AccDeprecated) != 0 ? "deprecated "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0001) == 1 ? "public "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0002) == 0x0002 ? "private "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0004) == 0x0004 ? "protected "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0008) == 0x000008 ? "static "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0010) == 0x0010 ? "final "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0040) == 0x0040 ? "volatile "/*nonNLS*/ : ""/*nonNLS*/)
+ + ((modifiers & 0x0080) == 0x0080 ? "transient "/*nonNLS*/ : ""/*nonNLS*/))
.append(getSelector())
.append(getMethodDescriptor())
- .append("}") //$NON-NLS-1$
+ .append("}"/*nonNLS*/)
.toString();
}
-public int compareTo(Object o) {
- if (!(o instanceof MethodInfo)) {
- throw new ClassCastException();
- }
- StringBuffer currentComparisonKey = new StringBuffer();
- currentComparisonKey.append(this.getSelector()).append(this.getMethodDescriptor());
- StringBuffer otherComparisonKey = new StringBuffer();
- MethodInfo otherMethodInfo = (MethodInfo) o;
- otherComparisonKey.append(otherMethodInfo.getSelector()).append(otherMethodInfo.getMethodDescriptor());
- return currentComparisonKey.toString().compareTo(otherComparisonKey.toString());
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
index dcd721f6d1..aa41c79630 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
@@ -166,16 +166,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if (keyTable[i] != null) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index d381484182..acb59b938f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -1369,7 +1369,7 @@ public void generateClassLiteralAccessForType(TypeBinding accessedType, FieldBin
// Wrap the code in an exception handler to convert a ClassNotFoundException into a NoClassDefError
anyExceptionHandler = new ExceptionLabel(this, TypeBinding.NullBinding /* represents ClassNotFoundException*/);
- this.ldc(accessedType == TypeBinding.NullBinding ? "java.lang.Object" : String.valueOf(accessedType.constantPoolName()).replace('/', '.')); //$NON-NLS-1$
+ this.ldc(accessedType == TypeBinding.NullBinding ? "java.lang.Object"/*nonNLS*/ : String.valueOf(accessedType.constantPoolName()).replace('/', '.'));
this.invokeClassForName();
/* We need to protect the runtime code from binary inconsistencies
@@ -1429,7 +1429,7 @@ final public int[] generateCodeAttributeForProblemMethod(String errorName, Strin
anewarrayJavaLangClass();
dup();
iconst_0();
- ldc("java.lang.String"); //$NON-NLS-1$
+ ldc("java.lang.String"/*nonNLS*/);
invokeClassForName();
aastore();
invokeConstructorGetConstructor();
@@ -1773,28 +1773,28 @@ public void generateObjectWrapperForType(TypeBinding valueType) {
char[][] wrapperTypeCompoundName = null;
switch (valueType.id) {
case T_int : // new: java.lang.Integer
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Integer".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Integer"/*nonNLS*/.toCharArray()};
break;
case T_boolean : // new: java.lang.Boolean
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Boolean".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Boolean"/*nonNLS*/.toCharArray()};
break;
case T_byte : // new: java.lang.Byte
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Byte".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Byte"/*nonNLS*/.toCharArray()};
break;
case T_char : // new: java.lang.Character
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Character".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Character"/*nonNLS*/.toCharArray()};
break;
case T_float : // new: java.lang.Float
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Float".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Float"/*nonNLS*/.toCharArray()};
break;
case T_double : // new: java.lang.Double
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Double".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Double"/*nonNLS*/.toCharArray()};
break;
case T_short : // new: java.lang.Short
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Short".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Short"/*nonNLS*/.toCharArray()};
break;
case T_long : // new: java.lang.Long
- wrapperTypeCompoundName = new char[][] {"java".toCharArray(), "lang".toCharArray(), "Long".toCharArray()}; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ wrapperTypeCompoundName = new char[][] {"java"/*nonNLS*/.toCharArray(), "lang"/*nonNLS*/.toCharArray(), "Long"/*nonNLS*/.toCharArray()};
break;
}
TypeBinding wrapperType = methodDeclaration.scope.getType(wrapperTypeCompoundName);
@@ -2885,20 +2885,6 @@ public void invokeClassForName() {
}
writeUnsignedShort(constantPool.literalIndexForJavaLangClassForName());
}
-
-public void invokeJavaLangClassDesiredAssertionStatus() {
- // invokevirtual: java.lang.Class.desiredAssertionStatus()Z;
- countLabels = 0;
- stackDepth--;
- try {
- position++;
- bCodeStream[classFileOffset++] = OPC_invokevirtual;
- } catch (IndexOutOfBoundsException e) {
- resizeByteArray(OPC_invokevirtual);
- }
- writeUnsignedShort(constantPool.literalIndexForJavaLangClassDesiredAssertionStatus());
-}
-
public void invokeConstructorGetConstructor() {
// invokevirtual: java.lang.Class.getConstructor(java.lang.Class[])Ljava.lang.reflect.Constructor;
countLabels = 0;
@@ -3082,33 +3068,6 @@ public void invokeStringBufferAppendForType(int typeID) {
else
stackDepth--;
}
-
-public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) {
- // invokespecial: java.lang.AssertionError.<init>(typeBindingID)V
- countLabels = 0;
- try {
- position++;
- bCodeStream[classFileOffset++] = OPC_invokespecial;
- } catch (IndexOutOfBoundsException e) {
- resizeByteArray(OPC_invokespecial);
- }
- writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorConstructor(typeBindingID));
- stackDepth -= 2;
-}
-
-public void invokeJavaLangAssertionErrorDefaultConstructor() {
- // invokespecial: java.lang.AssertionError.<init>()V
- countLabels = 0;
- try {
- position++;
- bCodeStream[classFileOffset++] = OPC_invokespecial;
- } catch (IndexOutOfBoundsException e) {
- resizeByteArray(OPC_invokespecial);
- }
- writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorDefaultConstructor());
- stackDepth --;
-}
-
public void invokeStringBufferDefaultConstructor() {
// invokespecial: java.lang.StringBuffer.<init>()V
countLabels = 0;
@@ -3133,7 +3092,6 @@ public void invokeStringBufferStringConstructor() {
writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferConstructor());
stackDepth -= 2;
}
-
public void invokeStringBufferToString() {
// invokevirtual: StringBuffer.toString()Ljava.lang.String;
countLabels = 0;
@@ -4483,22 +4441,6 @@ public void newJavaLangError() {
}
writeUnsignedShort(constantPool.literalIndexForJavaLangError());
}
-
-public void newJavaLangAssertionError() {
- // new: java.lang.AssertionError
- countLabels = 0;
- stackDepth++;
- if (stackDepth > stackMax)
- stackMax = stackDepth;
- try {
- position++;
- bCodeStream[classFileOffset++] = OPC_new;
- } catch (IndexOutOfBoundsException e) {
- resizeByteArray(OPC_new);
- }
- writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionError());
-}
-
public void newNoClassDefFoundError() { // new: java.lang.NoClassDefFoundError
countLabels = 0;
stackDepth++;
@@ -5362,15 +5304,15 @@ final public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] k
}
}
public String toString() {
- StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("( position:"/*nonNLS*/);
buffer.append(position);
- buffer.append(",\nstackDepth:"); //$NON-NLS-1$
+ buffer.append(",\nstackDepth:"/*nonNLS*/);
buffer.append(stackDepth);
- buffer.append(",\nmaxStack:"); //$NON-NLS-1$
+ buffer.append(",\nmaxStack:"/*nonNLS*/);
buffer.append(stackMax);
- buffer.append(",\nmaxLocals:"); //$NON-NLS-1$
+ buffer.append(",\nmaxLocals:"/*nonNLS*/);
buffer.append(maxLocals);
- buffer.append(")"); //$NON-NLS-1$
+ buffer.append(")"/*nonNLS*/);
return buffer.toString();
}
public void updateLastRecordedEndPC(int pos) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
index 3580794a50..e87240f8df 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
@@ -41,11 +41,11 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
protected ObjectCache classCache;
protected FieldNameAndTypeCache nameAndTypeCacheForFields;
protected MethodNameAndTypeCache nameAndTypeCacheForMethods;
- int[] wellKnownTypes = new int[21];
- int[] wellKnownMethods = new int[35];
+ int[] wellKnownTypes = new int[20];
+ int[] wellKnownMethods = new int[26];
int[] wellKnownFields = new int[10];
int[] wellKnownFieldNameAndTypes = new int[2];
- int[] wellKnownMethodNameAndTypes = new int[32];
+ int[] wellKnownMethodNameAndTypes = new int[24];
public byte[] poolContent;
public int currentIndex = 1;
public int currentOffset;
@@ -70,8 +70,6 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
final static int JAVA_LANG_ERROR_TYPE = 17;
final static int JAVA_LANG_EXCEPTION_TYPE = 18;
final static int JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE = 19;
- final static int JAVA_LANG_ASSERTIONERROR_TYPE = 20;
-
// predefined constant index for well known fields
final static int TYPE_BYTE_FIELD = 0;
final static int TYPE_SHORT_FIELD = 1;
@@ -110,21 +108,12 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
final static int VALUEOF_CHAR_METHOD = 23;
final static int VALUEOF_BOOLEAN_METHOD = 24;
final static int VALUEOF_DOUBLE_METHOD = 25;
- final static int ASSERTIONERROR_CONSTR_OBJECT_METHOD = 26;
- final static int ASSERTIONERROR_CONSTR_INT_METHOD = 27;
- final static int ASSERTIONERROR_CONSTR_LONG_METHOD = 28;
- final static int ASSERTIONERROR_CONSTR_FLOAT_METHOD = 29;
- final static int ASSERTIONERROR_CONSTR_DOUBLE_METHOD = 30;
- final static int ASSERTIONERROR_CONSTR_BOOLEAN_METHOD = 31;
- final static int ASSERTIONERROR_CONSTR_CHAR_METHOD = 32;
- final static int ASSERTIONERROR_DEFAULT_CONSTR_METHOD = 33;
- final static int DESIREDASSERTIONSTATUS_CLASS_METHOD = 34;
// predefined constant index for well known name and type for fields
final static int TYPE_JAVALANGCLASS_NAME_AND_TYPE = 0;
final static int OUT_SYSTEM_NAME_AND_TYPE = 1;
// predefined constant index for well known name and type for methods
final static int FORNAME_CLASS_METHOD_NAME_AND_TYPE = 0;
- final static int CONSTR_STRING_METHOD_NAME_AND_TYPE = 1;
+ final static int STRING_CONSTR_METHOD_NAME_AND_TYPE = 1;
final static int DEFAULT_CONSTR_METHOD_NAME_AND_TYPE = 2;
final static int APPEND_INT_METHOD_NAME_AND_TYPE = 3;
final static int APPEND_FLOAT_METHOD_NAME_AND_TYPE = 4;
@@ -147,15 +136,6 @@ public class ConstantPool implements ClassFileConstants, TypeIds {
final static int VALUEOF_CHAR_METHOD_NAME_AND_TYPE = 21;
final static int VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE = 22;
final static int VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE = 23;
- final static int CONSTR_INT_METHOD_NAME_AND_TYPE = 24;
- final static int CONSTR_LONG_METHOD_NAME_AND_TYPE = 25;
- final static int CONSTR_FLOAT_METHOD_NAME_AND_TYPE = 26;
- final static int CONSTR_DOUBLE_METHOD_NAME_AND_TYPE = 27;
- final static int CONSTR_OBJECT_METHOD_NAME_AND_TYPE = 28;
- final static int CONSTR_CHAR_METHOD_NAME_AND_TYPE = 29;
- final static int CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE = 30;
- final static int DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE = 31;
-
public ClassFile classFile;
/**
@@ -272,63 +252,13 @@ public int indexOfWellKnownMethodNameAndType(MethodBinding methodBinding) {
break;
case '<' :
if (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
- switch(methodBinding.parameters.length) {
- case 1:
- switch(methodBinding.parameters[0].id) {
- case T_String :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.StringConstructorSignature)) {
- return CONSTR_STRING_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_Object :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorObjectConstrSignature)) {
- return CONSTR_OBJECT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_int :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorIntConstrSignature)) {
- return CONSTR_INT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_char :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorCharConstrSignature)) {
- return CONSTR_CHAR_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_boolean :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorBooleanConstrSignature)) {
- return CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_float :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorFloatConstrSignature)) {
- return CONSTR_FLOAT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_double :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorDoubleConstrSignature)) {
- return CONSTR_DOUBLE_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_long :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorLongConstrSignature)) {
- return CONSTR_LONG_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- }
- case 0:
- if (methodBinding.signature().length == 3) {
- return DEFAULT_CONSTR_METHOD_NAME_AND_TYPE;
- }
- }
+ if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.StringConstructorSignature)) {
+ // This method binding is (java.lang.String)V
+ return STRING_CONSTR_METHOD_NAME_AND_TYPE;
+ } else
+ if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.DefaultConstructorSignature)) {
+ return DEFAULT_CONSTR_METHOD_NAME_AND_TYPE;
+ }
}
break;
case 'a' :
@@ -427,11 +357,10 @@ public int indexOfWellKnownMethods(MethodBinding methodBinding) {
if ((firstChar == 'f') && (methodBinding.isStatic()) && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (methodBinding.returnType.id == T_JavaLangClass) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ForName))) {
// This method binding is forName(java.lang.String)
return FORNAME_CLASS_METHOD;
- } else if ((firstChar == 'g') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangReflectConstructor) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetConstructor) && CharOperation.equals(methodBinding.parameters[0].constantPoolName(), QualifiedNamesConstants.ArrayJavaLangClassConstantPoolName)) {
+ } else
+ if ((firstChar == 'g') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangReflectConstructor) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetConstructor) && CharOperation.equals(methodBinding.parameters[0].constantPoolName(), QualifiedNamesConstants.ArrayJavaLangClassConstantPoolName)) {
return GETCONSTRUCTOR_CLASS_METHOD;
- } else if ((firstChar == 'd') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_boolean) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.DesiredAssertionStatus)) {
- return DESIREDASSERTIONSTATUS_CLASS_METHOD;
- }
+ }
break;
case T_JavaLangNoClassDefError :
if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
@@ -533,32 +462,6 @@ public int indexOfWellKnownMethods(MethodBinding methodBinding) {
if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) && (methodBinding.parameters[0].id == T_String)) {
return JAVALANGERROR_CONSTR_METHOD;
}
- case T_JavaLangAssertionError :
- if ((firstChar == '<') && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
- switch (methodBinding.parameters.length) {
- case 0:
- return ASSERTIONERROR_DEFAULT_CONSTR_METHOD;
- case 1:
- switch(methodBinding.parameters[0].id) {
- case T_boolean :
- return ASSERTIONERROR_CONSTR_BOOLEAN_METHOD;
- case T_char :
- return ASSERTIONERROR_CONSTR_CHAR_METHOD;
- case T_double :
- return ASSERTIONERROR_CONSTR_DOUBLE_METHOD;
- case T_int :
- case T_byte :
- case T_short :
- return ASSERTIONERROR_CONSTR_INT_METHOD;
- case T_float :
- return ASSERTIONERROR_CONSTR_FLOAT_METHOD;
- case T_long :
- return ASSERTIONERROR_CONSTR_LONG_METHOD;
- default:
- return ASSERTIONERROR_CONSTR_OBJECT_METHOD;
- }
- }
- }
}
return -1;
}
@@ -593,7 +496,6 @@ public int indexOfWellKnownTypes(TypeBinding typeBinding) {
case T_JavaLangError : return JAVA_LANG_ERROR_TYPE;
case T_JavaLangException : return JAVA_LANG_EXCEPTION_TYPE;
case T_JavaLangReflectConstructor : return JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE;
- case T_JavaLangAssertionError : return JAVA_LANG_ASSERTIONERROR_TYPE;
}
return -1;
}
@@ -1346,42 +1248,6 @@ public int literalIndexForJavaLangClassGetConstructor() {
return index;
}
/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClassDesiredAssertionStatus() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangClass();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatus);
- int typeIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatusSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
* This method returns the index into the constantPool corresponding to the type descriptor.
*
* @param TypeBinding aTypeBinding
@@ -1492,10 +1358,10 @@ public int literalIndexForJavaLangErrorConstructor() {
// Looking into the method ref table
if ((index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD]) == 0) {
classIndex = literalIndexForJavaLangError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
+ if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
int nameIndex = literalIndex(QualifiedNamesConstants.Init);
int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
+ nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
writeU1(NameAndTypeTag);
writeU2(nameIndex);
writeU2(typeIndex);
@@ -1710,254 +1576,6 @@ public int literalIndexForJavaLangNoClassDefFoundError() {
}
return index;
}
-
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @param TypeBinding aTypeBinding
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionError() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangAssertionErrorConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @param TypeBinding aTypeBinding
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionErrorConstructor(int typeBindingID) {
- int index = 0;
- int nameAndTypeIndex = 0;
- int classIndex = 0;
- switch (typeBindingID) {
- case T_int :
- case T_byte :
- case T_short :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorIntConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_long :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorLongConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_float :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorFloatConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_double :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorDoubleConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_char :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorCharConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_boolean :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorBooleanConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_Object :
- case T_String :
- case T_null :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorObjectConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- }
- return index;
-}
-
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionErrorDefaultConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-
-
/**
* This method returns the index into the constantPool corresponding to the
* method descriptor. It can be either an interface method reference constant
@@ -1972,10 +1590,10 @@ public int literalIndexForJavaLangNoClassDefFoundErrorStringConstructor() {
// Looking into the method ref table
if ((index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD]) == 0) {
classIndex = literalIndexForJavaLangNoClassDefFoundError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
+ if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
int nameIndex = literalIndex(QualifiedNamesConstants.Init);
int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
+ nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
writeU1(NameAndTypeTag);
writeU2(nameIndex);
writeU2(typeIndex);
@@ -2388,10 +2006,10 @@ public int literalIndexForJavaLangStringBufferConstructor() {
// Looking into the method ref table
if ((index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD]) == 0) {
classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
+ if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
int nameIndex = literalIndex(QualifiedNamesConstants.Init);
int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
+ nameAndTypeIndex = wellKnownMethodNameAndTypes[STRING_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
writeU1(NameAndTypeTag);
writeU2(nameIndex);
writeU2(typeIndex);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
index bb798cdef8..7711e17b19 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
@@ -120,16 +120,16 @@ public int put(double key, int value) {
public String toString() {
int max = elementSize;
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if ((keyTable[i] != 0) || ((keyTable[i] == 0) &&(valueTable[i] != 0))) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
index 10d146e4e3..4ea1f89a1c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
@@ -143,16 +143,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if (keyTable[i] != null) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
index e81926404d..3480a6c7fa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
@@ -120,16 +120,16 @@ public int put(float key, int value) {
public String toString() {
int max = elementSize;
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if ((keyTable[i] != 0) || ((keyTable[i] == 0) && (valueTable[i] != 0))) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
index e74f996af8..d49b8b3413 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
@@ -138,16 +138,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if ((keyTable[i] != 0) || ((keyTable[i] == 0) && (valueTable[i] != 0))) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
index 1fd1b8c158..a621896173 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
@@ -151,11 +151,6 @@ public void place() { // Currently lacking wide support.
LocalVariableBinding local = locals[i];
if ((local != null) && (local.initializationCount > 0)) {
if (local.initializationPCs[((local.initializationCount - 1) << 1) + 1] == oldPosition) {
- // we want to prevent interval of size 0 to have a negative size.
- // see PR 1GIRQLA: ITPJCORE:ALL - ClassFormatError for local variable attribute
- if (local.initializationPCs[((local.initializationCount - 1) << 1)] == oldPosition) {
- local.initializationPCs[((local.initializationCount - 1) << 1)] = position;
- }
local.initializationPCs[((local.initializationCount - 1) << 1) + 1] = position;
}
}
@@ -195,14 +190,14 @@ public void place() { // Currently lacking wide support.
* Print out the receiver
*/
public String toString() {
- StringBuffer buffer = new StringBuffer("(position="); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("(position="/*nonNLS*/);
buffer.append(position);
- buffer.append(", forwards = ["); //$NON-NLS-1$
+ buffer.append(", forwards = ["/*nonNLS*/);
for (int i = 0; i < forwardReferenceCount - 1; i++)
- buffer.append(forwardReferences[i] + ", "); //$NON-NLS-1$
+ buffer.append(forwardReferences[i] + ", "/*nonNLS*/);
if (forwardReferenceCount >= 1)
buffer.append(forwardReferences[forwardReferenceCount-1]);
- buffer.append("] )"); //$NON-NLS-1$
+ buffer.append("] )"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
index e4f519e3c5..a59397fbb5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
@@ -138,16 +138,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if ((keyTable[i] != 0) || ((keyTable[i] == 0) && (valueTable[i] != 0))) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
index 9a8ca43934..2d50853c64 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
@@ -144,16 +144,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if (keyTable[i] != null) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
index 64363a6313..63cb51f249 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
@@ -135,16 +135,16 @@ public int size() {
public String toString() {
int max = size();
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
for (int i = 0; i < max; ++i) {
if (keyTable[i] != null) {
- buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
+ buf.append(keyTable[i]).append("->"/*nonNLS*/).append(valueTable[i]);
}
if (i < max) {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
index 6d46de4539..edefbdd641 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
@@ -6,26 +6,26 @@ package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.problem.*;
public interface QualifiedNamesConstants {
- char[] JavaLangObjectConstantPoolName = "java/lang/Object".toCharArray(); //$NON-NLS-1$
- char[] JavaLangStringConstantPoolName = "java/lang/String".toCharArray(); //$NON-NLS-1$
- char[] JavaLangStringBufferConstantPoolName = "java/lang/StringBuffer".toCharArray(); //$NON-NLS-1$
- char[] JavaLangClassConstantPoolName = "java/lang/Class".toCharArray(); //$NON-NLS-1$
- char[] JavaLangThrowableConstantPoolName = "java/lang/Throwable".toCharArray(); //$NON-NLS-1$
- char[] JavaLangClassNotFoundExceptionConstantPoolName = "java/lang/ClassNotFoundException".toCharArray(); //$NON-NLS-1$
- char[] JavaLangNoClassDefFoundErrorConstantPoolName = "java/lang/NoClassDefFoundError".toCharArray(); //$NON-NLS-1$
- char[] JavaLangIntegerConstantPoolName = "java/lang/Integer".toCharArray(); //$NON-NLS-1$
- char[] JavaLangFloatConstantPoolName = "java/lang/Float".toCharArray(); //$NON-NLS-1$
- char[] JavaLangDoubleConstantPoolName = "java/lang/Double".toCharArray(); //$NON-NLS-1$
- char[] JavaLangLongConstantPoolName = "java/lang/Long".toCharArray(); //$NON-NLS-1$
- char[] JavaLangShortConstantPoolName = "java/lang/Short".toCharArray(); //$NON-NLS-1$
- char[] JavaLangByteConstantPoolName = "java/lang/Byte".toCharArray(); //$NON-NLS-1$
- char[] JavaLangCharacterConstantPoolName = "java/lang/Character".toCharArray(); //$NON-NLS-1$
- char[] JavaLangVoidConstantPoolName = "java/lang/Void".toCharArray(); //$NON-NLS-1$
- char[] JavaLangBooleanConstantPoolName = "java/lang/Boolean".toCharArray(); //$NON-NLS-1$
- char[] JavaLangSystemConstantPoolName = "java/lang/System".toCharArray(); //$NON-NLS-1$
- char[] JavaLangErrorConstantPoolName = "java/lang/Error".toCharArray(); //$NON-NLS-1$
- char[] JavaLangExceptionConstantPoolName = "java/lang/Exception".toCharArray(); //$NON-NLS-1$
- char[] JavaLangReflectConstructor = "java/lang/reflect/Constructor".toCharArray(); //$NON-NLS-1$
+ char[] JavaLangObjectConstantPoolName = "java/lang/Object"/*nonNLS*/.toCharArray();
+ char[] JavaLangStringConstantPoolName = "java/lang/String"/*nonNLS*/.toCharArray();
+ char[] JavaLangStringBufferConstantPoolName = "java/lang/StringBuffer"/*nonNLS*/.toCharArray();
+ char[] JavaLangClassConstantPoolName = "java/lang/Class"/*nonNLS*/.toCharArray();
+ char[] JavaLangThrowableConstantPoolName = "java/lang/Throwable"/*nonNLS*/.toCharArray();
+ char[] JavaLangClassNotFoundExceptionConstantPoolName = "java/lang/ClassNotFoundException"/*nonNLS*/.toCharArray();
+ char[] JavaLangNoClassDefFoundErrorConstantPoolName = "java/lang/NoClassDefFoundError"/*nonNLS*/.toCharArray();
+ char[] JavaLangIntegerConstantPoolName = "java/lang/Integer"/*nonNLS*/.toCharArray();
+ char[] JavaLangFloatConstantPoolName = "java/lang/Float"/*nonNLS*/.toCharArray();
+ char[] JavaLangDoubleConstantPoolName = "java/lang/Double"/*nonNLS*/.toCharArray();
+ char[] JavaLangLongConstantPoolName = "java/lang/Long"/*nonNLS*/.toCharArray();
+ char[] JavaLangShortConstantPoolName = "java/lang/Short"/*nonNLS*/.toCharArray();
+ char[] JavaLangByteConstantPoolName = "java/lang/Byte"/*nonNLS*/.toCharArray();
+ char[] JavaLangCharacterConstantPoolName = "java/lang/Character"/*nonNLS*/.toCharArray();
+ char[] JavaLangVoidConstantPoolName = "java/lang/Void"/*nonNLS*/.toCharArray();
+ char[] JavaLangBooleanConstantPoolName = "java/lang/Boolean"/*nonNLS*/.toCharArray();
+ char[] JavaLangSystemConstantPoolName = "java/lang/System"/*nonNLS*/.toCharArray();
+ char[] JavaLangErrorConstantPoolName = "java/lang/Error"/*nonNLS*/.toCharArray();
+ char[] JavaLangExceptionConstantPoolName = "java/lang/Exception"/*nonNLS*/.toCharArray();
+ char[] JavaLangReflectConstructor = "java/lang/reflect/Constructor"/*nonNLS*/.toCharArray();
char[] Append = new char[] {'a', 'p', 'p', 'e', 'n', 'd'};
char[] ToString = new char[] {'t', 'o', 'S', 't', 'r', 'i', 'n', 'g'};
char[] Init = new char[] {'<', 'i', 'n', 'i', 't', '>'};
@@ -33,52 +33,41 @@ public interface QualifiedNamesConstants {
char[] ValueOf = new char[] {'v', 'a', 'l', 'u', 'e', 'O', 'f'};
char[] ForName = new char[] {'f', 'o', 'r', 'N', 'a', 'm', 'e'};
char[] GetMessage = new char[] {'g', 'e', 't', 'M', 'e', 's', 's', 'a', 'g', 'e'};
- char[] NewInstance = "newInstance".toCharArray(); //$NON-NLS-1$
- char[] GetConstructor = "getConstructor".toCharArray(); //$NON-NLS-1$
+ char[] NewInstance = "newInstance"/*nonNLS*/.toCharArray();
+ char[] GetConstructor = "getConstructor"/*nonNLS*/.toCharArray();
char[] Exit = new char[] {'e', 'x', 'i', 't'};
- char[] Intern = "intern".toCharArray(); //$NON-NLS-1$
+ char[] Intern = "intern"/*nonNLS*/.toCharArray();
char[] Out = new char[] {'o', 'u', 't'};
char[] TYPE = new char[] {'T', 'Y', 'P', 'E'};
char[] This = new char[] {'t', 'h', 'i', 's'};
char[] JavaLangClassSignature = new char[] {'L', 'j', 'a', 'v', 'a', '/', 'l', 'a', 'n', 'g', '/', 'C', 'l', 'a', 's', 's', ';'};
- char[] ForNameSignature = "(Ljava/lang/String;)Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
- char[] GetMessageSignature = "()Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] GetConstructorSignature = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;".toCharArray(); //$NON-NLS-1$
- char[] StringConstructorSignature = "(Ljava/lang/String;)V".toCharArray(); //$NON-NLS-1$
- char[] NewInstanceSignature = "([Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ char[] ForNameSignature = "(Ljava/lang/String;)Ljava/lang/Class;"/*nonNLS*/.toCharArray();
+ char[] GetMessageSignature = "()Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] GetConstructorSignature = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;"/*nonNLS*/.toCharArray();
+ char[] StringConstructorSignature = "(Ljava/lang/String;)V"/*nonNLS*/.toCharArray();
+ char[] NewInstanceSignature = "([Ljava/lang/Object;)Ljava/lang/Object;"/*nonNLS*/.toCharArray();
char[] DefaultConstructorSignature = {'(', ')', 'V'};
char[] ClinitSignature = DefaultConstructorSignature;
char[] ToStringSignature = GetMessageSignature;
char[] InternSignature = GetMessageSignature;
- char[] AppendIntSignature = "(I)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendLongSignature = "(J)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendFloatSignature = "(F)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendDoubleSignature = "(D)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendCharSignature = "(C)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendBooleanSignature = "(Z)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendObjectSignature = "(Ljava/lang/Object;)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] AppendStringSignature = "(Ljava/lang/String;)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfObjectSignature = "(Ljava/lang/Object;)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfIntSignature = "(I)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfLongSignature = "(J)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfCharSignature = "(C)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfBooleanSignature = "(Z)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfDoubleSignature = "(D)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] ValueOfFloatSignature = "(F)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
- char[] JavaIoPrintStreamSignature = "Ljava/io/PrintStream;".toCharArray(); //$NON-NLS-1$
+ char[] AppendIntSignature = "(I)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendLongSignature = "(J)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendFloatSignature = "(F)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendDoubleSignature = "(D)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendCharSignature = "(C)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendBooleanSignature = "(Z)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendObjectSignature = "(Ljava/lang/Object;)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] AppendStringSignature = "(Ljava/lang/String;)Ljava/lang/StringBuffer;"/*nonNLS*/.toCharArray();
+ char[] ValueOfObjectSignature = "(Ljava/lang/Object;)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfIntSignature = "(I)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfLongSignature = "(J)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfCharSignature = "(C)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfBooleanSignature = "(Z)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfDoubleSignature = "(D)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] ValueOfFloatSignature = "(F)Ljava/lang/String;"/*nonNLS*/.toCharArray();
+ char[] JavaIoPrintStreamSignature = "Ljava/io/PrintStream;"/*nonNLS*/.toCharArray();
char[] ExitIntSignature = new char[] {'(', 'I', ')', 'V'};
- char[] ArrayJavaLangObjectConstantPoolName = "[Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
- char[] ArrayJavaLangClassConstantPoolName = "[Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
- char[] JavaLangAssertionErrorConstantPoolName = "java/lang/AssertionError".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorIntConstrSignature = "(I)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorLongConstrSignature = "(J)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorFloatConstrSignature = "(F)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorDoubleConstrSignature = "(D)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorCharConstrSignature = "(C)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorBooleanConstrSignature = "(Z)V".toCharArray(); //$NON-NLS-1$
- char[] AssertionErrorObjectConstrSignature = "(Ljava/lang/Object;)V".toCharArray(); //$NON-NLS-1$
- char[] DesiredAssertionStatus = "desiredAssertionStatus".toCharArray(); //$NON-NLS-1$
- char[] DesiredAssertionStatusSignature = "()Z".toCharArray(); //$NON-NLS-1$
- char[] ShortConstrSignature = "(S)V".toCharArray(); //$NON-NLS-1$
- char[] ByteConstrSignature = "(B)V".toCharArray(); //$NON-NLS-1$
+ char[] ArrayJavaLangObjectConstantPoolName = "[Ljava/lang/Object;"/*nonNLS*/.toCharArray();
+ char[] ArrayJavaLangClassConstantPoolName = "[Ljava/lang/Class;"/*nonNLS*/.toCharArray();
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
index 6b0bee412c..1b201af9d0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
@@ -68,11 +68,4 @@ char[] getName();
char[] getSuperclassName();
-/**
- * Answer the source file attribute, or null if none.
- *
- * For example, "String.java"
- */
-
-char[] sourceFileName();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
index cffdb47fae..ecfee241e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
@@ -6,69 +6,62 @@ package org.eclipse.jdt.internal.compiler.env;
import org.eclipse.jdt.internal.compiler.*;
public class NameEnvironmentAnswer {
-
// only one of the three can be set
IBinaryType binaryType;
ICompilationUnit compilationUnit;
- ISourceType[] sourceTypes;
-
- public NameEnvironmentAnswer(IBinaryType binaryType) {
- this.binaryType = binaryType;
- }
-
- public NameEnvironmentAnswer(ICompilationUnit compilationUnit) {
- this.compilationUnit = compilationUnit;
- }
-
- public NameEnvironmentAnswer(ISourceType[] sourceTypes) {
- this.sourceTypes = sourceTypes;
- }
+ ISourceType sourceType;
+public NameEnvironmentAnswer(IBinaryType binaryType) {
+ this.binaryType = binaryType;
+}
+public NameEnvironmentAnswer(ICompilationUnit compilationUnit) {
+ this.compilationUnit = compilationUnit;
+}
+public NameEnvironmentAnswer(ISourceType sourceType) {
+ this.sourceType = sourceType;
+}
+/**
+ * Answer the resolved binary form for the type or null if the
+ * receiver represents a compilation unit or source type.
+ */
- /**
- * Answer the resolved binary form for the type or null if the
- * receiver represents a compilation unit or source type.
- */
- public IBinaryType getBinaryType() {
- return binaryType;
- }
+public IBinaryType getBinaryType() {
+ return binaryType;
+}
+/**
+ * Answer the compilation unit or null if the
+ * receiver represents a binary or source type.
+ */
- /**
- * Answer the compilation unit or null if the
- * receiver represents a binary or source type.
- */
- public ICompilationUnit getCompilationUnit() {
- return compilationUnit;
- }
+public ICompilationUnit getCompilationUnit() {
+ return compilationUnit;
+}
+/**
+ * Answer the unresolved source form for the type or null if the
+ * receiver represents a compilation unit or binary type.
+ */
- /**
- * Answer the unresolved source forms for the type or null if the
- * receiver represents a compilation unit or binary type.
- *
- * Multiple source forms can be answered in case the originating compilation unit did contain
- * several type at once. Then the first type is guaranteed to be the requested type.
- */
- public ISourceType[] getSourceTypes() {
- return sourceTypes;
- }
+public ISourceType getSourceType() {
+ return sourceType;
+}
+/**
+ * Answer whether the receiver contains the resolved binary form of the type.
+ */
- /**
- * Answer whether the receiver contains the resolved binary form of the type.
- */
- public boolean isBinaryType() {
- return binaryType != null;
- }
+public boolean isBinaryType() {
+ return binaryType != null;
+}
+/**
+ * Answer whether the receiver contains the compilation unit which defines the type.
+ */
- /**
- * Answer whether the receiver contains the compilation unit which defines the type.
- */
- public boolean isCompilationUnit() {
- return compilationUnit != null;
- }
+public boolean isCompilationUnit() {
+ return compilationUnit != null;
+}
+/**
+ * Answer whether the receiver contains the unresolved source form of the type.
+ */
- /**
- * Answer whether the receiver contains the unresolved source form of the type.
- */
- public boolean isSourceType() {
- return sourceTypes != null;
- }
-} \ No newline at end of file
+public boolean isSourceType() {
+ return sourceType != null;
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
index a799dc7169..307d43a2d6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
@@ -114,7 +114,7 @@ public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
return unconditionalInits().mergedWith(otherInits);
}
public String toString() {
- return "FlowInfo<true: " + initsWhenTrue.toString() + ", false: " + initsWhenFalse.toString() + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
+ return "FlowInfo<true: "/*nonNLS*/ + initsWhenTrue.toString() + ", false: "/*nonNLS*/ + initsWhenFalse.toString() + ">"/*nonNLS*/;
}
public UnconditionalFlowInfo unconditionalInits() {
return initsWhenTrue.unconditionalInits().copy()
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
index 5445b6e710..426698c29c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
@@ -91,7 +91,7 @@ public void complainIfUnusedExceptionHandlers(AstNode[] exceptionHandlers, Block
tryStatement.preserveExceptionHandler = isNeeded;
}
public String individualToString() {
- StringBuffer buffer = new StringBuffer("Exception flow context"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("Exception flow context"/*nonNLS*/);
int length = handledExceptions.length;
for (int i = 0; i < length; i++) {
int cacheIndex = i / BitCacheSize;
@@ -99,12 +99,12 @@ public String individualToString() {
buffer.append('[').append(handledExceptions[i].readableName());
if ((isReached[cacheIndex] & bitMask) != 0) {
if ((isNeeded[cacheIndex] & bitMask) == 0) {
- buffer.append("-masked"); //$NON-NLS-1$
+ buffer.append("-masked"/*nonNLS*/);
} else {
- buffer.append("-reached"); //$NON-NLS-1$
+ buffer.append("-reached"/*nonNLS*/);
}
} else {
- buffer.append("-not reached"); //$NON-NLS-1$
+ buffer.append("-not reached"/*nonNLS*/);
}
buffer.append('-').append(initsOnExceptions[i].toString()).append(']');
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
index 632bc3e279..329ccbf5a7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
@@ -326,7 +326,7 @@ public FlowContext getTargetContextForDefaultContinue() {
return null;
}
public String individualToString(){
- return "Flow context"; //$NON-NLS-1$
+ return "Flow context"/*nonNLS*/;
}
public FlowInfo initsOnBreak() {
return FlowInfo.DeadEnd;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
index 15dd6fec3a..74ef42cdec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
@@ -71,7 +71,7 @@ abstract public FlowInfo markAsFakeReachable(boolean isFakeReachable);
abstract public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits);
public String toString(){
if (this == DeadEnd){
- return "FlowInfo.DeadEnd"; //$NON-NLS-1$
+ return "FlowInfo.DeadEnd"/*nonNLS*/;
}
return super.toString();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
index 7a20c5609f..0a6542874b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
@@ -38,7 +38,7 @@ void checkLabelValidity(BlockScope scope) {
}
}
public String individualToString(){
- return "Label flow context [label:"+String.valueOf(labelName)+"]"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "Label flow context [label:"/*nonNLS*/+String.valueOf(labelName)+"]"/*nonNLS*/;
}
public char[] labelName() {
return labelName;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
index 77032ef588..93acbaf5c0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
@@ -56,7 +56,7 @@ public Label continueLabel() {
return continueLabel;
}
public String individualToString(){
- return "Looping flow context"; //$NON-NLS-1$
+ return "Looping flow context"/*nonNLS*/;
}
public boolean isContinuable() {
return true;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
index 9d44fbdf04..33a77b5fbd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
@@ -28,7 +28,7 @@ public Label breakLabel() {
return breakLabel;
}
public String individualToString(){
- return "Switch flow context"; //$NON-NLS-1$
+ return "Switch flow context"/*nonNLS*/;
}
public boolean isBreakable() {
return true;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
index 67cb8da95b..77b1654423 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
@@ -420,9 +420,9 @@ static int numberOfEnclosingFields(ReferenceBinding type){
}
public String toString(){
if (this == DeadEnd){
- return "FlowInfo.DeadEnd"; //$NON-NLS-1$
+ return "FlowInfo.DeadEnd"/*nonNLS*/;
}
- return "FlowInfo<def: "+ definiteInits +", pot: " + potentialInits + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
+ return "FlowInfo<def: "/*nonNLS*/+ definiteInits +", pot: "/*nonNLS*/ + potentialInits + ">"/*nonNLS*/;
}
public UnconditionalFlowInfo unconditionalInits() {
// also see conditional inits, where it requests them to merge
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
index 55832c14fa..7f9a4216cc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
@@ -23,13 +23,13 @@ public String stringValue() {
String s = new Boolean(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(boolean)" + value ; } //$NON-NLS-1$
+ return "(boolean)"/*nonNLS*/ + value ; }
public int typeID() {
return T_boolean;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
index 114af4d7f8..5d88da8890 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
@@ -36,13 +36,13 @@ public String stringValue() {
String s = new Integer(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(byte)" + value ; } //$NON-NLS-1$
+ return "(byte)"/*nonNLS*/ + value ; }
public int typeID() {
return T_byte;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
index f1015a5862..5b402138bd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
@@ -39,13 +39,13 @@ public String stringValue() {
String s = new Character(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(char)" + value ; } //$NON-NLS-1$
+ return "(char)"/*nonNLS*/ + value ; }
public int typeID() {
return T_char;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index 15e735abc0..3360076733 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -11,27 +11,6 @@ import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
public class CompilerOptions implements ConfigurableProblems, ProblemIrritants, ProblemReasons, ProblemSeverities {
-
- /**
- * Option IDs
- */
- public static final String OPTION_LocalVariableAttribute = Compiler.class.getName() + ".localVariableAttribute"; //$NON-NLS-1$
- public static final String OPTION_LineNumberAttribute = Compiler.class.getName() + ".lineNumberAttribute"; //$NON-NLS-1$
- public static final String OPTION_SourceFileAttribute = Compiler.class.getName() + ".sourceFileAttribute"; //$NON-NLS-1$
- public static final String OPTION_PreserveUnusedLocal = Compiler.class.getName() + ".preserveUnusedLocal"; //$NON-NLS-1$
- public static final String OPTION_ReportUnreachableCode = Compiler.class.getName() + ".reportUnreachableCode"; //$NON-NLS-1$
- public static final String OPTION_ReportInvalidImport = Compiler.class.getName() + ".reportInvalidImport"; //$NON-NLS-1$
- public static final String OPTION_ReportMethodWithConstructorName = Compiler.class.getName() + ".reportMethodWithConstructorName"; //$NON-NLS-1$
- public static final String OPTION_ReportOverridingPackageDefaultMethod = Compiler.class.getName() + ".reportOverridingPackageDefaultMethod"; //$NON-NLS-1$
- public static final String OPTION_ReportDeprecation = Compiler.class.getName() + ".reportDeprecation"; //$NON-NLS-1$
- public static final String OPTION_ReportHiddenCatchBlock = Compiler.class.getName() + ".reportHiddenCatchBlock"; //$NON-NLS-1$
- public static final String OPTION_ReportUnusedLocal = Compiler.class.getName() + ".reportUnusedLocal"; //$NON-NLS-1$
- public static final String OPTION_ReportUnusedParameter = Compiler.class.getName() + ".reportUnusedParameter"; //$NON-NLS-1$
- public static final String OPTION_ReportSyntheticAccessEmulation = Compiler.class.getName() + ".reportSyntheticAccessEmulation"; //$NON-NLS-1$
- public static final String OPTION_ReportNonExternalizedStringLiteral = Compiler.class.getName() + ".reportNonExternalizedStringLiteral"; //$NON-NLS-1$
- public static final String OPTION_Source = Compiler.class.getName() + ".source"; //$NON-NLS-1$
- public static final String OPTION_TargetPlatform = Compiler.class.getName() + ".targetPlatform"; //$NON-NLS-1$
- public static final String OPTION_ReportAssertIdentifier = Compiler.class.getName() + ".reportAssertIdentifier"; //$NON-NLS-1$
// class file output
// these are the bits used to buld a mask to know which debug
@@ -45,10 +24,11 @@ public class CompilerOptions implements ConfigurableProblems, ProblemIrritants,
// default severity level for handlers
public int errorThreshold = UnreachableCode | ImportProblem;
- public int warningThreshold =
+ public int warningThreshold =
+ ParsingOptionalError |
MethodWithConstructorName | OverriddenPackageDefaultMethod |
UsingDeprecatedAPI | MaskedCatchBlock |
- UnusedLocalVariable | AssertUsedAsAnIdentifier |
+ UnusedLocalVariable | UnusedArgument |
TemporaryWarning;
// target JDK 1.1 or 1.2
@@ -56,9 +36,6 @@ public class CompilerOptions implements ConfigurableProblems, ProblemIrritants,
public static final int JDK1_2 = 1;
public int targetJDK = JDK1_1; // default generates for JVM1.1
- // 1.4 feature
- public boolean assertMode = false; //1.3 behavior by default
-
// print what unit is being processed
public boolean verbose = false;
// indicates if reference info is desired
@@ -69,7 +46,7 @@ public class CompilerOptions implements ConfigurableProblems, ProblemIrritants,
public boolean parseLiteralExpressionsAsConstants = true;
// exception raised for unresolved compile errors
- public String runtimeExceptionNameForCompileError = "java.lang.Error"; //$NON-NLS-1$
+ public String runtimeExceptionNameForCompileError = "java.lang.Error"/*nonNLS*/;
// toggle private access emulation for 1.2 (constr. accessor has extra arg on constructor) or 1.3 (make private constructor default access when access needed)
public boolean isPrivateConstructorAccessChangingVisibility = false; // by default, follows 1.2
@@ -83,7 +60,6 @@ public CompilerOptions(){
*/
public CompilerOptions(ConfigurableOption[] settings){
if (settings == null) return;
-
// filter options which are related to the compiler component
String componentName = Compiler.class.getName();
for (int i = 0, max = settings.length; i < max; i++){
@@ -92,191 +68,194 @@ public CompilerOptions(ConfigurableOption[] settings){
}
}
}
-
+/**
+ * Returns all the options of the compiler to be shown by the UI
+ *
+ * @param locale java.util.Locale
+ * @return org.eclipse.jdt.internal.compiler.ConfigurableOption[]
+ */
+public ConfigurableOption[] getConfigurableOptions(Locale locale) {
+ String componentName = Compiler.class.getName();
+ return new ConfigurableOption[] {
+ new ConfigurableOption(
+ componentName,
+ "debug.vars"/*nonNLS*/,
+ locale,
+ (produceDebugAttributes & Vars) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "debug.lines"/*nonNLS*/,
+ locale,
+ (produceDebugAttributes & Lines) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "debug.source"/*nonNLS*/,
+ locale,
+ (produceDebugAttributes & Source) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "debug.preserveAllLocals"/*nonNLS*/,
+ locale,
+ preserveAllLocalVariables ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalError.unReachableCode"/*nonNLS*/,
+ locale,
+ (errorThreshold & UnreachableCode) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalError.importProblem"/*nonNLS*/,
+ locale,
+ (errorThreshold & ImportProblem) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.methodWithConstructorName"/*nonNLS*/,
+ locale,
+ (warningThreshold & MethodWithConstructorName) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.overridingPackageDefaultMethod"/*nonNLS*/,
+ locale,
+ (warningThreshold & OverriddenPackageDefaultMethod) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.deprecated"/*nonNLS*/,
+ locale,
+ (warningThreshold & UsingDeprecatedAPI) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.maskedCatchBlock"/*nonNLS*/,
+ locale,
+ (warningThreshold & MaskedCatchBlock) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.unusedLocalVariable"/*nonNLS*/,
+ locale,
+ (warningThreshold & UnusedLocalVariable) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.unusedArgument"/*nonNLS*/,
+ locale,
+ (warningThreshold & UnusedArgument) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "binaryCompatibility.targetJDK"/*nonNLS*/,
+ locale,
+ targetJDK),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.accessEmulation"/*nonNLS*/,
+ locale,
+ (warningThreshold & AccessEmulation) != 0 ? 0 : 1),
+ new ConfigurableOption(
+ componentName,
+ "optionalWarning.nonExternalizedString"/*nonNLS*/,
+ locale,
+ (warningThreshold & NonExternalizedString) != 0 ? 0 : 1)
+ };
+}
public int getDebugAttributesMask() {
return this.produceDebugAttributes;
}
public int getTargetJDK() {
return this.targetJDK;
}
-public boolean getAssertMode() {
- return this.assertMode;
+public void handleAccessEmulationAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= AccessEmulation;
+ } else {
+ warningThreshold &= ~AccessEmulation;
+ }
}
-public void setAccessEmulationSeverity(int flag) {
- errorThreshold &= ~AccessEmulation;
- warningThreshold &= ~AccessEmulation;
- switch(flag){
- case Error :
- errorThreshold |= AccessEmulation;
- break;
- case Warning :
- warningThreshold |= AccessEmulation;
- break;
+public void handleDeprecationUseAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= UsingDeprecatedAPI;
+ } else {
+ warningThreshold &= ~UsingDeprecatedAPI;
}
}
-public void setDeprecationUseSeverity(int flag) {
- errorThreshold &= ~UsingDeprecatedAPI;
- warningThreshold &= ~UsingDeprecatedAPI;
- switch(flag){
- case Error :
- errorThreshold |= UsingDeprecatedAPI;
- break;
- case Warning :
- warningThreshold |= UsingDeprecatedAPI;
- break;
+public void handleImportProblemAsError(boolean flag) {
+ if (flag) {
+ errorThreshold |= ImportProblem;
+ warningThreshold &= ~ImportProblem;
+ } else {
+ errorThreshold &= ~ImportProblem;
+ warningThreshold |= ImportProblem;
}
}
-public void setImportProblemSeverity(int flag) {
- errorThreshold &= ~ImportProblem;
- warningThreshold &= ~ImportProblem;
- switch(flag){
- case Error :
- errorThreshold |= ImportProblem;
- break;
- case Warning :
- warningThreshold |= ImportProblem;
- break;
+public void handleMaskedCatchBlockAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= MaskedCatchBlock;
+ } else {
+ warningThreshold &= ~MaskedCatchBlock;
}
}
-public void setMaskedCatchBlockSeverity(int flag) {
- errorThreshold &= ~MaskedCatchBlock;
- warningThreshold &= ~MaskedCatchBlock;
- switch(flag){
- case Error :
- errorThreshold |= MaskedCatchBlock;
- break;
- case Warning :
- warningThreshold |= MaskedCatchBlock;
- break;
+public void handleMethodWithConstructorNameAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= MethodWithConstructorName;
+ } else {
+ warningThreshold &= ~MethodWithConstructorName;
}
}
-public void setMethodWithConstructorNameSeverity(int flag) {
- errorThreshold &= ~MethodWithConstructorName;
- warningThreshold &= ~MethodWithConstructorName;
- switch(flag){
- case Error :
- errorThreshold |= MethodWithConstructorName;
- break;
- case Warning :
- warningThreshold |= MethodWithConstructorName;
- break;
+public void handleObsoleteLiteralAsError(boolean flag) {
+ if (flag) {
+ errorThreshold |= ParsingOptionalError;
+ warningThreshold &= ~ParsingOptionalError;
+ } else {
+ errorThreshold &= ~ParsingOptionalError;
+ warningThreshold |= ParsingOptionalError;
}
}
-
-public void setOverriddenPackageDefaultMethodSeverity(int flag) {
- errorThreshold &= ~OverriddenPackageDefaultMethod;
- warningThreshold &= ~OverriddenPackageDefaultMethod;
- switch(flag){
- case Error :
- errorThreshold |= OverriddenPackageDefaultMethod;
- break;
- case Warning :
- warningThreshold |= OverriddenPackageDefaultMethod;
- break;
+public void handleOverriddenPackageDefaultMethodAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= OverriddenPackageDefaultMethod;
+ } else {
+ warningThreshold &= ~OverriddenPackageDefaultMethod;
}
}
-public void setUnreachableCodeSeverity(int flag) {
- errorThreshold &= ~UnreachableCode;
- warningThreshold &= ~UnreachableCode;
- switch(flag){
- case Error :
- errorThreshold |= UnreachableCode;
- break;
- case Warning :
- warningThreshold |= UnreachableCode;
- break;
+public void handleUnreachableCodeAsError(boolean flag) {
+ if (flag) {
+ errorThreshold |= UnreachableCode;
+ warningThreshold &= ~UnreachableCode;
+ } else {
+ errorThreshold &= ~UnreachableCode;
+ warningThreshold |= UnreachableCode;
}
}
-public void setUnusedArgumentSeverity(int flag) {
- errorThreshold &= ~UnusedArgument;
- warningThreshold &= ~UnusedArgument;
- switch(flag){
- case Error :
- errorThreshold |= UnusedArgument;
- break;
- case Warning :
- warningThreshold |= UnusedArgument;
- break;
+public void handleUnusedArgumentAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= UnusedArgument;
+ } else {
+ warningThreshold &= ~UnusedArgument;
}
}
-public void setUnusedLocalVariableSeverity(int flag) {
- errorThreshold &= ~UnusedLocalVariable;
- warningThreshold &= ~UnusedLocalVariable;
- switch(flag){
- case Error :
- errorThreshold |= UnusedLocalVariable;
- break;
- case Warning :
- warningThreshold |= UnusedLocalVariable;
- break;
+public void handleUnusedLocalVariableAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= UnusedLocalVariable;
+ } else {
+ warningThreshold &= ~UnusedLocalVariable;
}
}
-public void setNonExternalizedStringLiteralSeverity(int flag) {
- errorThreshold &= ~NonExternalizedString;
- warningThreshold &= ~NonExternalizedString;
- switch(flag){
- case Error :
- errorThreshold |= NonExternalizedString;
- break;
- case Warning :
- warningThreshold |= NonExternalizedString;
- break;
- }
+public boolean isAccessEmulationHandledAsWarning() {
+ return (warningThreshold & AccessEmulation) != 0;
}
-public void setAssertIdentifierSeverity(int flag) {
- errorThreshold &= ~AssertUsedAsAnIdentifier;
- warningThreshold &= ~AssertUsedAsAnIdentifier;
- switch(flag){
- case Error :
- errorThreshold |= AssertUsedAsAnIdentifier;
- break;
- case Warning :
- warningThreshold |= AssertUsedAsAnIdentifier;
- break;
- }
+public boolean isDeprecationUseHandledAsWarning() {
+ return (warningThreshold & UsingDeprecatedAPI) != 0;
}
-public int getAccessEmulationSeverity() {
- if((warningThreshold & AccessEmulation) != 0)
- return Warning;
- if((errorThreshold & AccessEmulation) != 0)
- return Error;
- return Ignore;
-}
-public int getDeprecationUseSeverity() {
- if((warningThreshold & UsingDeprecatedAPI) != 0)
- return Warning;
- if((errorThreshold & UsingDeprecatedAPI) != 0)
- return Error;
- return Ignore;
-}
-public int getImportProblemSeverity() {
- if((warningThreshold & ImportProblem) != 0)
- return Warning;
- if((errorThreshold & ImportProblem) != 0)
- return Error;
- return Ignore;
-}
-public int getMaskedCatchBlockSeverity() {
- if((warningThreshold & MaskedCatchBlock) != 0)
- return Warning;
- if((errorThreshold & MaskedCatchBlock) != 0)
- return Error;
- return Ignore;
-}
-public int getMethodWithConstructorNameSeverity() {
- if((warningThreshold & MethodWithConstructorName) != 0)
- return Warning;
- if((errorThreshold & MethodWithConstructorName) != 0)
- return Error;
- return Ignore;
+public boolean isImportProblemHandledAsError() {
+ return (errorThreshold & ImportProblem) != 0;
}
-
-public int getOverriddenPackageDefaultMethodSeverity() {
- if((warningThreshold & OverriddenPackageDefaultMethod) != 0)
- return Warning;
- if((errorThreshold & OverriddenPackageDefaultMethod) != 0)
- return Error;
- return Ignore;
+public boolean isMaskedCatchBlockHandledAsWarning() {
+ return (warningThreshold & MaskedCatchBlock) != 0;
+}
+public boolean isMethodWithConstructorNameHandledAsWarning() {
+ return (warningThreshold & MethodWithConstructorName) != 0;
+}
+public boolean isObsoleteLiteralAsHandledError() {
+ return (errorThreshold & ParsingOptionalError) != 0;
+}
+public boolean isOverriddenPackageDefaultMethodHandledAsWarning() {
+ return (warningThreshold & OverriddenPackageDefaultMethod) != 0;
}
public boolean isPreservingAllLocalVariables() {
return this.preserveAllLocalVariables ;
@@ -284,40 +263,14 @@ public boolean isPreservingAllLocalVariables() {
public boolean isPrivateConstructorAccessChangingVisibility() {
return isPrivateConstructorAccessChangingVisibility;
}
-public int getUnreachableCodeHandledAsError() {
- if((warningThreshold & UnreachableCode) != 0)
- return Warning;
- if((errorThreshold & UnreachableCode) != 0)
- return Error;
- return Ignore;
-}
-public int getUnusedArgumentSeverity() {
- if((warningThreshold & UnusedArgument) != 0)
- return Warning;
- if((errorThreshold & UnusedArgument) != 0)
- return Error;
- return Ignore;
-}
-public int getUnusedLocalVariableSeverity() {
- if((warningThreshold & UnusedLocalVariable) != 0)
- return Warning;
- if((errorThreshold & UnusedLocalVariable) != 0)
- return Error;
- return Ignore;
-}
-public int getNonExternalizedStringLiteralSeverity() {
- if((warningThreshold & NonExternalizedString) != 0)
- return Warning;
- if((errorThreshold & NonExternalizedString) != 0)
- return Error;
- return Ignore;
-}
-public int getAssertIdentifierSeverity() {
- if((warningThreshold & NonExternalizedString) != 0)
- return Warning;
- if((errorThreshold & NonExternalizedString) != 0)
- return Error;
- return Ignore;
+public boolean isUnreachableCodeHandledAsError() {
+ return (errorThreshold & UnreachableCode) != 0;
+}
+public boolean isUnusedArgumentHandledAsWarning() {
+ return (warningThreshold & UnusedArgument) != 0;
+}
+public boolean isUnusedLocalVariableHandledAsWarning() {
+ return (warningThreshold & UnusedLocalVariable) != 0;
}
public void preserveAllLocalVariables(boolean flag) {
this.preserveAllLocalVariables = flag;
@@ -335,311 +288,226 @@ public void setErrorThreshold(int errorMask) {
this.errorThreshold = errorMask;
}
/**
- * Change the value of the option corresponding to the option ID
+ * Change the value of the option corresponding to the option number
+ *
+ * @param optionNumber <CODE>int</CODE>
+ * @param setting.getCurrentValueIndex() <CODE>int</CODE>
*/
void setOption(ConfigurableOption setting) {
- String componentName = Compiler.class.getName();
-
- String optionID = setting.getID();
- if(optionID.equals(OPTION_LocalVariableAttribute)){
- if (setting.getValueIndex() == 0) {
- // set the debug flag with Vars.
- produceDebugAttributes |= Vars;
- } else {
- produceDebugAttributes &= ~Vars;
- }
- } else if(optionID.equals(OPTION_LineNumberAttribute)) {
- if (setting.getValueIndex() == 0) {
- // set the debug flag with Lines
- produceDebugAttributes |= Lines;
- } else {
- produceDebugAttributes &= ~Lines;
- }
- }else if(optionID.equals(OPTION_SourceFileAttribute)) {
- if (setting.getValueIndex() == 0) {
- // set the debug flag with Source.
- produceDebugAttributes |= Source;
- } else {
- produceDebugAttributes &= ~Source;
- }
- }else if(optionID.equals(OPTION_PreserveUnusedLocal)){
- preserveAllLocalVariables(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_ReportUnreachableCode)){
- switch(setting.getValueIndex()){
- case 0 :
- setUnreachableCodeSeverity(Error);
- break;
- case 1 :
- setUnreachableCodeSeverity(Warning);
- break;
- case 2 :
- setUnreachableCodeSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportInvalidImport)){
- switch(setting.getValueIndex()){
- case 0 :
- setImportProblemSeverity(Error);
- break;
- case 1 :
- setImportProblemSeverity(Warning);
- break;
- case 2 :
- setImportProblemSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_TargetPlatform)){
- setTargetJDK(setting.getValueIndex() == 0 ? JDK1_1 : JDK1_2);
- }else if(optionID.equals(OPTION_ReportMethodWithConstructorName)){
- switch(setting.getValueIndex()){
- case 0 :
- setMethodWithConstructorNameSeverity(Error);
- break;
- case 1 :
- setMethodWithConstructorNameSeverity(Warning);
- break;
- case 2 :
- setMethodWithConstructorNameSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportOverridingPackageDefaultMethod)){
- switch(setting.getValueIndex()){
- case 0 :
- setOverriddenPackageDefaultMethodSeverity(Error);
- break;
- case 1 :
- setOverriddenPackageDefaultMethodSeverity(Warning);
- break;
- case 2 :
- setOverriddenPackageDefaultMethodSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportDeprecation)){
- switch(setting.getValueIndex()){
- case 0 :
- setDeprecationUseSeverity(Error);
- break;
- case 1 :
- setDeprecationUseSeverity(Warning);
- break;
- case 2 :
- setDeprecationUseSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportHiddenCatchBlock)){
- switch(setting.getValueIndex()){
- case 0 :
- setMaskedCatchBlockSeverity(Error);
- break;
- case 1 :
- setMaskedCatchBlockSeverity(Warning);
- break;
- case 2 :
- setMaskedCatchBlockSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportUnusedLocal)){
- switch(setting.getValueIndex()){
- case 0 :
- setUnusedLocalVariableSeverity(Error);
- break;
- case 1 :
- setUnusedLocalVariableSeverity(Warning);
- break;
- case 2 :
- setUnusedLocalVariableSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportUnusedParameter)){
- switch(setting.getValueIndex()){
- case 0 :
- setUnusedArgumentSeverity(Error);
- break;
- case 1 :
- setUnusedArgumentSeverity(Warning);
- break;
- case 2 :
- setUnusedArgumentSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportSyntheticAccessEmulation)){
- switch(setting.getValueIndex()){
- case 0 :
- setAccessEmulationSeverity(Error);
- break;
- case 1 :
- setAccessEmulationSeverity(Warning);
- break;
- case 2 :
- setAccessEmulationSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportNonExternalizedStringLiteral)){
- switch(setting.getValueIndex()){
- case 0 :
- setNonExternalizedStringLiteralSeverity(Error);
- break;
- case 1 :
- setNonExternalizedStringLiteralSeverity(Warning);
- break;
- case 2 :
- setNonExternalizedStringLiteralSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_ReportAssertIdentifier)){
- switch(setting.getValueIndex()){
- case 0 :
- setAssertIdentifierSeverity(Error);
- break;
- case 1 :
- setAssertIdentifierSeverity(Warning);
- break;
- case 2 :
- setAssertIdentifierSeverity(Ignore);
- break;
- }
- }else if(optionID.equals(OPTION_Source)){
- setAssertMode(setting.getValueIndex() == 1);
+ switch (setting.getID()) {
+ case 1 : // Local variable table attribute
+ if (setting.getCurrentValueIndex() == 0) {
+ // set the debug flag with Vars.
+ produceDebugAttributes |= Vars;
+ } else {
+ produceDebugAttributes &= ~Vars;
+ }
+ break;
+ case 2 : // Line number attribute
+ if (setting.getCurrentValueIndex() == 0) {
+ // set the debug flag with Lines
+ produceDebugAttributes |= Lines;
+ } else {
+ produceDebugAttributes &= ~Lines;
+ }
+ break;
+ case 3 : // source file attribute
+ if (setting.getCurrentValueIndex() == 0) {
+ // set the debug flag with Source.
+ produceDebugAttributes |= Source;
+ } else {
+ produceDebugAttributes &= ~Source;
+ }
+ break;
+ case 4 : // preserveAllLocals flag
+ preserveAllLocalVariables(setting.getCurrentValueIndex() == 0);
+ break;
+ case 5 : // unreachable code reported as error
+ handleUnreachableCodeAsError(setting.getCurrentValueIndex() == 0);
+ break;
+ case 6 : // invalid import
+ handleImportProblemAsError(setting.getCurrentValueIndex() == 0);
+ break;
+ case 7 : // methods with constructor name
+ handleMethodWithConstructorNameAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 8 : // overridden package default method
+ handleOverriddenPackageDefaultMethodAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 9 : // use of deprecated API
+ handleDeprecationUseAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 10 : // catch block hidden by another one
+ handleMaskedCatchBlockAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 11 : // local variable not used
+ handleUnusedLocalVariableAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 12 : // argument not used
+ handleUnusedArgumentAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 13 : // temporary warning
+ if (setting.getCurrentValueIndex() == 0) {
+ warningThreshold |= TemporaryWarning;
+ }
+ break;
+ case 14 : // target JDK
+ setTargetJDK(setting.getCurrentValueIndex() == 0 ? JDK1_1 : JDK1_2);
+ break;
+ case 15: // synthetic access emulation
+ handleAccessEmulationAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
+ case 16: // non externalized string literal
+ handleNonExternalizedStringLiteralAsWarning(setting.getCurrentValueIndex() == 0);
+ break;
}
}
-
public void setTargetJDK(int vmID) {
this.targetJDK = vmID;
}
public void setVerboseMode(boolean flag) {
this.verbose = flag;
}
-public void setAssertMode(boolean assertMode) {
- this.assertMode = assertMode;
-}
public void setWarningThreshold(int warningMask) {
this.warningThreshold = warningMask;
}
public String toString() {
- StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("CompilerOptions:"/*nonNLS*/);
if ((produceDebugAttributes & Vars) != 0){
- buf.append("\n-local variables debug attributes: ON"); //$NON-NLS-1$
+ buf.append("\n-local variables debug attributes: ON"/*nonNLS*/);
} else {
- buf.append("\n-local variables debug attributes: OFF"); //$NON-NLS-1$
+ buf.append("\n-local variables debug attributes: OFF"/*nonNLS*/);
}
if ((produceDebugAttributes & Lines) != 0){
- buf.append("\n-line number debug attributes: ON"); //$NON-NLS-1$
+ buf.append("\n-line number debug attributes: ON"/*nonNLS*/);
} else {
- buf.append("\n-line number debug attributes: OFF"); //$NON-NLS-1$
+ buf.append("\n-line number debug attributes: OFF"/*nonNLS*/);
}
if ((produceDebugAttributes & Source) != 0){
- buf.append("\n-source debug attributes: ON"); //$NON-NLS-1$
+ buf.append("\n-source debug attributes: ON"/*nonNLS*/);
} else {
- buf.append("\n-source debug attributes: OFF"); //$NON-NLS-1$
+ buf.append("\n-source debug attributes: OFF"/*nonNLS*/);
}
if (preserveAllLocalVariables){
- buf.append("\n-preserve all local variables: ON"); //$NON-NLS-1$
+ buf.append("\n-preserve all local variables: ON"/*nonNLS*/);
} else {
- buf.append("\n-preserve all local variables: OFF"); //$NON-NLS-1$
+ buf.append("\n-preserve all local variables: OFF"/*nonNLS*/);
}
if ((errorThreshold & UnreachableCode) != 0){
- buf.append("\n-unreachable code: ERROR"); //$NON-NLS-1$
+ buf.append("\n-unreachable code: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & UnreachableCode) != 0){
- buf.append("\n-unreachable code: WARNING"); //$NON-NLS-1$
+ buf.append("\n-unreachable code: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-unreachable code: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-unreachable code: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & ImportProblem) != 0){
- buf.append("\n-import problem: ERROR"); //$NON-NLS-1$
+ buf.append("\n-import problem: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & ImportProblem) != 0){
- buf.append("\n-import problem: WARNING"); //$NON-NLS-1$
+ buf.append("\n-import problem: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-import problem: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-import problem: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & MethodWithConstructorName) != 0){
- buf.append("\n-method with constructor name: ERROR"); //$NON-NLS-1$
+ buf.append("\n-method with constructor name: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & MethodWithConstructorName) != 0){
- buf.append("\n-method with constructor name: WARNING"); //$NON-NLS-1$
+ buf.append("\n-method with constructor name: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-method with constructor name: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-method with constructor name: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & OverriddenPackageDefaultMethod) != 0){
- buf.append("\n-overridden package default method: ERROR"); //$NON-NLS-1$
+ buf.append("\n-overridden package default method: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & OverriddenPackageDefaultMethod) != 0){
- buf.append("\n-overridden package default method: WARNING"); //$NON-NLS-1$
+ buf.append("\n-overridden package default method: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-overridden package default method: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-overridden package default method: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & UsingDeprecatedAPI) != 0){
- buf.append("\n-deprecation: ERROR"); //$NON-NLS-1$
+ buf.append("\n-deprecation: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & UsingDeprecatedAPI) != 0){
- buf.append("\n-deprecation: WARNING"); //$NON-NLS-1$
+ buf.append("\n-deprecation: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-deprecation: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-deprecation: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & MaskedCatchBlock) != 0){
- buf.append("\n-masked catch block: ERROR"); //$NON-NLS-1$
+ buf.append("\n-masked catch block: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & MaskedCatchBlock) != 0){
- buf.append("\n-masked catch block: WARNING"); //$NON-NLS-1$
+ buf.append("\n-masked catch block: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-masked catch block: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-masked catch block: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & UnusedLocalVariable) != 0){
- buf.append("\n-unused local variable: ERROR"); //$NON-NLS-1$
+ buf.append("\n-unused local variable: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & UnusedLocalVariable) != 0){
- buf.append("\n-unused local variable: WARNING"); //$NON-NLS-1$
+ buf.append("\n-unused local variable: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-unused local variable: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-unused local variable: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & UnusedArgument) != 0){
- buf.append("\n-unused parameter: ERROR"); //$NON-NLS-1$
+ buf.append("\n-unused parameter: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & UnusedArgument) != 0){
- buf.append("\n-unused parameter: WARNING"); //$NON-NLS-1$
+ buf.append("\n-unused parameter: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-unused parameter: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-unused parameter: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & AccessEmulation) != 0){
- buf.append("\n-synthetic access emulation: ERROR"); //$NON-NLS-1$
+ buf.append("\n-synthetic access emulation: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & AccessEmulation) != 0){
- buf.append("\n-synthetic access emulation: WARNING"); //$NON-NLS-1$
+ buf.append("\n-synthetic access emulation: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-synthetic access emulation: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-synthetic access emulation: IGNORE"/*nonNLS*/);
}
}
if ((errorThreshold & NonExternalizedString) != 0){
- buf.append("\n-non externalized string: ERROR"); //$NON-NLS-1$
+ buf.append("\n-non externalized string: ERROR"/*nonNLS*/);
} else {
if ((warningThreshold & NonExternalizedString) != 0){
- buf.append("\n-non externalized string: WARNING"); //$NON-NLS-1$
+ buf.append("\n-non externalized string: WARNING"/*nonNLS*/);
} else {
- buf.append("\n-non externalized string: IGNORE"); //$NON-NLS-1$
+ buf.append("\n-non externalized string: IGNORE"/*nonNLS*/);
}
}
switch(targetJDK){
case JDK1_1 :
- buf.append("\n-target JDK: 1.1"); //$NON-NLS-1$
+ buf.append("\n-target JDK: 1.1"/*nonNLS*/);
break;
case JDK1_2 :
- buf.append("\n-target JDK: 1.2"); //$NON-NLS-1$
+ buf.append("\n-target JDK: 1.2"/*nonNLS*/);
}
- buf.append("\n-verbose : " + (verbose ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- buf.append("\n-produce reference info : " + (produceReferenceInfo ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- buf.append("\n-parse literal expressions as constants : " + (parseLiteralExpressionsAsConstants ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- buf.append("\n-runtime exception name for compile error : " + runtimeExceptionNameForCompileError); //$NON-NLS-1$
+ buf.append("\n-verbose : "/*nonNLS*/ + (verbose ? "ON"/*nonNLS*/ : "OFF"/*nonNLS*/));
+ buf.append("\n-produce reference info : "/*nonNLS*/ + (produceReferenceInfo ? "ON"/*nonNLS*/ : "OFF"/*nonNLS*/));
+ buf.append("\n-parse literal expressions as constants : "/*nonNLS*/ + (parseLiteralExpressionsAsConstants ? "ON"/*nonNLS*/ : "OFF"/*nonNLS*/));
+ buf.append("\n-runtime exception name for compile error : "/*nonNLS*/ + runtimeExceptionNameForCompileError);
return buf.toString();
}
+
+public void handleNonExternalizedStringLiteralAsWarning(boolean flag) {
+ if (flag) {
+ warningThreshold |= NonExternalizedString;
+ } else {
+ warningThreshold &= ~NonExternalizedString;
+ }
+}
+
+public boolean isNonExternalizedStringLiteralHandledAsWarning() {
+ return (warningThreshold & NonExternalizedString) != 0;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ConfigurableProblems.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ConfigurableProblems.java
index 033843d507..4482fd98ca 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ConfigurableProblems.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ConfigurableProblems.java
@@ -9,6 +9,7 @@ import org.eclipse.jdt.internal.compiler.*;
public interface ConfigurableProblems {
final int UnreachableCode = 0x100;
+ final int ParsingOptionalError = 0x200;
final int ImportProblem = 0x400;
final int MethodWithConstructorName = 0x1000;
final int OverriddenPackageDefaultMethod = 0x2000;
@@ -19,5 +20,4 @@ public interface ConfigurableProblems {
final int TemporaryWarning = 0x40000;
final int AccessEmulation = 0x80000;
final int NonExternalizedString = 0x100000;
- final int AssertUsedAsAnIdentifier = 0x200000;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
index 8f05951b88..92b55dde8a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
@@ -16,10 +16,10 @@ public abstract class Constant implements TypeIds, OperatorIds {
public static final IntConstant Two = new IntConstant(2);
public static final IntConstant One = new IntConstant(1);
public boolean booleanValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"boolean")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"boolean"/*nonNLS*/));
}
public byte byteValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"byte")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"byte"/*nonNLS*/));
}
public final Constant castTo(int conversionToTargetType){
//the cast is an int of the form
@@ -218,7 +218,7 @@ public final Constant castTo(int conversionToTargetType){
return NotAConstant ;
}
public char charValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"char")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"char"/*nonNLS*/));
}
public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
//this method assumes that the TC has been done .
@@ -1416,10 +1416,10 @@ public static final Constant computeConstantOperationXOR(Constant left, int left
return NotAConstant ;} // should not get here
public double doubleValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"double")); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"double"/*nonNLS*/));
}
public float floatValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"float")); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"float"/*nonNLS*/));
}
public static Constant fromValue(byte value) {
return new ByteConstant(value);
@@ -1450,36 +1450,36 @@ public static Constant fromValue(boolean value) {
return new BooleanConstant(value);
}
public int intValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"int")); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"int"/*nonNLS*/));
}
public long longValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"long")); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto"/*nonNLS*/,typeName(),"long"/*nonNLS*/));
}
public short shortValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"short")); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo"/*nonNLS*/,typeName(),"short"/*nonNLS*/));
}
/** Deprecated
*/
public String stringValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"String")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo"/*nonNLS*/,typeName(),"String"/*nonNLS*/));
}
public String toString(){
- if (this == NotAConstant) return "(Constant) NotAConstant" ; //$NON-NLS-1$
+ if (this == NotAConstant) return "(Constant) NotAConstant"/*nonNLS*/ ;
return super.toString(); }
public abstract int typeID();
public String typeName() {
switch (typeID()) {
- case T_int : return "int"; //$NON-NLS-1$
- case T_byte : return "byte"; //$NON-NLS-1$
- case T_short : return "short"; //$NON-NLS-1$
- case T_char : return "char"; //$NON-NLS-1$
- case T_float : return "float"; //$NON-NLS-1$
- case T_double : return "double"; //$NON-NLS-1$
- case T_boolean : return "boolean"; //$NON-NLS-1$
- case T_String : return "java.lang.String"; //$NON-NLS-1$
- case T_null : return "null"; //$NON-NLS-1$
- default: return "unknown"; //$NON-NLS-1$
+ case T_int : return "int"/*nonNLS*/;
+ case T_byte : return "byte"/*nonNLS*/;
+ case T_short : return "short"/*nonNLS*/;
+ case T_char : return "char"/*nonNLS*/;
+ case T_float : return "float"/*nonNLS*/;
+ case T_double : return "double"/*nonNLS*/;
+ case T_boolean : return "boolean"/*nonNLS*/;
+ case T_String : return "java.lang.String"/*nonNLS*/;
+ case T_null : return "null"/*nonNLS*/;
+ default: return "unknown"/*nonNLS*/;
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
index 03794b2f23..522474ca4f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
@@ -36,14 +36,14 @@ public String stringValue() {
String s = new Double(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- if (this == NotAConstant) return "(Constant) NotAConstant" ; //$NON-NLS-1$
- return "(double)" + value ; } //$NON-NLS-1$
+ if (this == NotAConstant) return "(Constant) NotAConstant"/*nonNLS*/ ;
+ return "(double)"/*nonNLS*/ + value ; }
public int typeID() {
return T_double;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
index 8e411cfb10..483ef5d43b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
@@ -36,13 +36,13 @@ public String stringValue() {
String s = new Float(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(float)" + value ; } //$NON-NLS-1$
+ return "(float)"/*nonNLS*/ + value ; }
public int typeID() {
return T_float;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
index 939f0b7c59..f4270ac62a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
@@ -1,30 +1,27 @@
package org.eclipse.jdt.internal.compiler.impl;
-
+
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-
+
import org.eclipse.jdt.internal.compiler.env.*;
-
+
public interface ITypeRequestor {
-
- /**
- * Accept the resolved binary form for the requested type.
- */
- void accept(IBinaryType binaryType, PackageBinding packageBinding);
+/**
+ * Accept the resolved binary form for the requested type.
+ */
- /**
- * Accept the requested type's compilation unit.
- */
- void accept(ICompilationUnit unit);
+void accept(IBinaryType binaryType, PackageBinding packageBinding);
+/**
+ * Accept the requested type's compilation unit.
+ */
+
+void accept(ICompilationUnit unit);
+/**
+ * Accept the unresolved source form for the requested type.
+ */
- /**
- * Accept the unresolved source forms for the requested type.
- * Note that the multiple source forms can be answered, in case the target compilation unit
- * contains multiple types. The first one is then guaranteed to be the one corresponding to the
- * requested type.
- */
- void accept(ISourceType[] sourceType, PackageBinding packageBinding);
-} \ No newline at end of file
+void accept(ISourceType sourceType, PackageBinding packageBinding);
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
index d000a1d290..490196ce34 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
@@ -36,13 +36,13 @@ public String stringValue() {
String s = new Integer(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(int)" + value ; } //$NON-NLS-1$
+ return "(int)"/*nonNLS*/ + value ; }
public int typeID() {
return T_int;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
index d6b4161ed9..911b81f816 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
@@ -36,13 +36,13 @@ public String stringValue() {
String s = new Long(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(long)" + value ; } //$NON-NLS-1$
+ return "(long)"/*nonNLS*/ + value ; }
public int typeID() {
return T_long;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java
index 102415972b..6e24bf588d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java
@@ -17,7 +17,7 @@ public String stringValue() {
}
public String toString(){
- return "(null)" + null ; } //$NON-NLS-1$
+ return "(null)"/*nonNLS*/ + null ; }
public int typeID() {
return T_null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
index d1bebfa78d..fd87ca9181 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
@@ -36,13 +36,13 @@ public String stringValue() {
String s = new Integer(value).toString() ;
if (s == null)
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
else
return s;
}
public String toString(){
- return "(short)" + value ; } //$NON-NLS-1$
+ return "(short)"/*nonNLS*/ + value ; }
public int typeID() {
return T_short;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
index 2e757d33db..fe197d4000 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
@@ -33,7 +33,7 @@ public String stringValue() {
}
public String toString(){
- return "(String)\"" + value +"\""; } //$NON-NLS-2$ //$NON-NLS-1$
+ return "(String)\""/*nonNLS*/ + value +"\""/*nonNLS*/; }
public int typeID() {
return T_String;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/options.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/options.properties
new file mode 100644
index 0000000000..c166fc2fcb
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/options.properties
@@ -0,0 +1,84 @@
+debug.vars.number=1
+debug.vars.category=Debug Information
+debug.vars.name=Local variable attribute
+debug.vars.possibleValues=2|Generate|Do not generate
+debug.vars.description=When generated, this attribute will enable local variable names to be displayed in debugger, only in place where variables are definitely assigned (.class file is then bigger)
+
+debug.lines.number=2
+debug.lines.category=Debug Information
+debug.lines.name=Line number attribute
+debug.lines.possibleValues=2|Generate|Do not generate
+debug.lines.description=When generated, this attribute will enable source code highlighting in debugger (.class file is then bigger).
+
+debug.source.number=3
+debug.source.category=Debug Information
+debug.source.name=Source file attribute
+debug.source.possibleValues=2|Generate|Do not generate
+debug.source.description=When generated, this attribute will enable the debugger to present the corresponding source code.
+
+debug.preserveAllLocals.number=4
+debug.preserveAllLocals.category=Code Generation
+debug.preserveAllLocals.name=Preserve unused locals
+debug.preserveAllLocals.possibleValues=2|Preserve|Optimize out
+debug.preserveAllLocals.description=Unless requested to preserve unused local variables (i.e. never read), the compiler will optimize them out, potentially altering debugging
+
+optionalError.unReachableCode.number=5
+optionalError.unReachableCode.category=Optional Errors
+optionalError.unReachableCode.name=Unreachable code
+optionalError.unReachableCode.possibleValues=2|Raise error|Warn
+optionalError.unReachableCode.description=Unreachable code can either be reported as an error or a warning
+
+optionalError.importProblem.number=6
+optionalError.importProblem.category=Optional Errors
+optionalError.importProblem.name=Invalid import
+optionalError.importProblem.possibleValues=2|Raise error|Warn
+optionalError.importProblem.description=An import statement that cannot be resolved might either be reported either as an error or as a warning
+
+optionalWarning.methodWithConstructorName.number=7
+optionalWarning.methodWithConstructorName.category=Optional Warnings
+optionalWarning.methodWithConstructorName.name=Method with constructor name
+optionalWarning.methodWithConstructorName.possibleValues=2|Warn|Ignore
+optionalWarning.methodWithConstructorName.description=Naming a method with a constructor name is generally considered poor style programming. When enabling this option, the compiler will signal such scenarii.
+
+optionalWarning.overridingPackageDefaultMethod.number=8
+optionalWarning.overridingPackageDefaultMethod.category=Optional Warnings
+optionalWarning.overridingPackageDefaultMethod.name=Overriding a package default method
+optionalWarning.overridingPackageDefaultMethod.possibleValues=2|Warn|Ignore
+optionalWarning.overridingPackageDefaultMethod.description=A package default method is not visible in a different package, and thus cannot be overriden. When enabling this option, the compiler will signal such scenarii.
+
+optionalWarning.deprecated.number=9
+optionalWarning.deprecated.category=Optional Warnings
+optionalWarning.deprecated.name=Deprecation
+optionalWarning.deprecated.possibleValues=2|Warn|Ignore
+optionalWarning.deprecated.description=When enabled, the compiler will signal use of deprecated API.
+
+optionalWarning.maskedCatchBlock.number=10
+optionalWarning.maskedCatchBlock.category=Optional Warnings
+optionalWarning.maskedCatchBlock.name=Hidden catch block
+optionalWarning.maskedCatchBlock.possibleValues=2|Warn|Ignore
+optionalWarning.maskedCatchBlock.description=Locally to a try statement, some catch blocks may hide others (e.g. try {throw new java.io.CharConversionException();} catch (java.io.CharConversionException e) {} catch (java.io.IOException e) {}). When enabling this option, the compiler will issue a warning for hidden catch blocks corresponding to checked exceptions
+
+optionalWarning.unusedLocalVariable.number=11
+optionalWarning.unusedLocalVariable.category=Optional Warnings
+optionalWarning.unusedLocalVariable.name=Unused local variable
+optionalWarning.unusedLocalVariable.possibleValues=2|Warn|Ignore
+optionalWarning.unusedLocalVariable.description=When enabled, the compiler will issue a warning for unused local variables (i.e. variables never read from)
+
+optionalWarning.unusedArgument.number=12
+optionalWarning.unusedArgument.category=Optional Warnings
+optionalWarning.unusedArgument.name=Unused parameter
+optionalWarning.unusedArgument.possibleValues=2|Warn|Ignore
+optionalWarning.unusedArgument.description=When enabled, the compiler will issue a warning for unused method parameters (i.e. parameters never read from)
+
+binaryCompatibility.targetJDK.number=14
+binaryCompatibility.targetJDK.category=Binary Compatibility
+binaryCompatibility.targetJDK.name=Target platform
+binaryCompatibility.targetJDK.possibleValues=2|1.1|1.2
+binaryCompatibility.targetJDK.description=Generate .class files either backward compatible with JVM 1.1 or only executable on JVM 1.2 and later
+
+optionalWarning.accessEmulation.number=15
+optionalWarning.accessEmulation.category=Optional Warnings
+optionalWarning.accessEmulation.name=Synthetic Access Emulation
+optionalWarning.accessEmulation.possibleValues=2|Warn|Ignore
+optionalWarning.accessEmulation.description=When enabled, the compiler will issue a warning whenever it emulates access to a non-accessible member of an enclosing type
+
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
index 98050d25a3..15e789c6fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
@@ -39,7 +39,7 @@ public char[] constantPoolName() /* [Ljava/lang/Object; */ {
String debugName() {
StringBuffer brackets = new StringBuffer(dimensions * 2);
for (int i = dimensions; --i >= 0;)
- brackets.append("[]"); //$NON-NLS-1$
+ brackets.append("[]"/*nonNLS*/);
return leafComponentType.debugName() + brackets.toString();
}
/* Answer an array whose dimension size is one less than the receiver.
@@ -128,6 +128,6 @@ public char[] sourceName() {
return CharOperation.concat(leafComponentType.sourceName(), brackets);
}
public String toString() {
- return leafComponentType != null ? debugName() : "NULL TYPE ARRAY"; //$NON-NLS-1$
+ return leafComponentType != null ? debugName() : "NULL TYPE ARRAY"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
index 0f1de7d44f..d6648528db 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
@@ -146,6 +146,6 @@ public char[] sourceName() {
return simpleName;
}
public String toString() {
- return new String(constantPoolName) + " (id=" + id + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return new String(constantPoolName) + " (id="/*nonNLS*/ + id + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
index 7c43f2cfec..45caffe89b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
@@ -6,14 +6,14 @@ package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.*;
public interface BaseTypes {
- final BaseTypeBinding IntBinding = new BaseTypeBinding(TypeIds.T_int, "int".toCharArray(), new char[] {'I'}); //$NON-NLS-1$
- final BaseTypeBinding ByteBinding = new BaseTypeBinding(TypeIds.T_byte, "byte".toCharArray(), new char[] {'B'}); //$NON-NLS-1$
- final BaseTypeBinding ShortBinding = new BaseTypeBinding(TypeIds.T_short, "short".toCharArray(), new char[] {'S'}); //$NON-NLS-1$
- final BaseTypeBinding CharBinding = new BaseTypeBinding(TypeIds.T_char, "char".toCharArray(), new char[] {'C'}); //$NON-NLS-1$
- final BaseTypeBinding LongBinding = new BaseTypeBinding(TypeIds.T_long, "long".toCharArray(), new char[] {'J'}); //$NON-NLS-1$
- final BaseTypeBinding FloatBinding = new BaseTypeBinding(TypeIds.T_float, "float".toCharArray(), new char[] {'F'}); //$NON-NLS-1$
- final BaseTypeBinding DoubleBinding = new BaseTypeBinding(TypeIds.T_double, "double".toCharArray(), new char[] {'D'}); //$NON-NLS-1$
- final BaseTypeBinding BooleanBinding = new BaseTypeBinding(TypeIds.T_boolean, "boolean".toCharArray(), new char[] {'Z'}); //$NON-NLS-1$
- final BaseTypeBinding NullBinding = new BaseTypeBinding(TypeIds.T_null, "null".toCharArray(), new char[] {'N'}); //N stands for null even if it is never internally used //$NON-NLS-1$
- final BaseTypeBinding VoidBinding = new BaseTypeBinding(TypeIds.T_void, "void".toCharArray(), new char[] {'V'}); //$NON-NLS-1$
+ final BaseTypeBinding IntBinding = new BaseTypeBinding(TypeIds.T_int, "int"/*nonNLS*/.toCharArray(), new char[] {'I'});
+ final BaseTypeBinding ByteBinding = new BaseTypeBinding(TypeIds.T_byte, "byte"/*nonNLS*/.toCharArray(), new char[] {'B'});
+ final BaseTypeBinding ShortBinding = new BaseTypeBinding(TypeIds.T_short, "short"/*nonNLS*/.toCharArray(), new char[] {'S'});
+ final BaseTypeBinding CharBinding = new BaseTypeBinding(TypeIds.T_char, "char"/*nonNLS*/.toCharArray(), new char[] {'C'});
+ final BaseTypeBinding LongBinding = new BaseTypeBinding(TypeIds.T_long, "long"/*nonNLS*/.toCharArray(), new char[] {'J'});
+ final BaseTypeBinding FloatBinding = new BaseTypeBinding(TypeIds.T_float, "float"/*nonNLS*/.toCharArray(), new char[] {'F'});
+ final BaseTypeBinding DoubleBinding = new BaseTypeBinding(TypeIds.T_double, "double"/*nonNLS*/.toCharArray(), new char[] {'D'});
+ final BaseTypeBinding BooleanBinding = new BaseTypeBinding(TypeIds.T_boolean, "boolean"/*nonNLS*/.toCharArray(), new char[] {'Z'});
+ final BaseTypeBinding NullBinding = new BaseTypeBinding(TypeIds.T_null, "null"/*nonNLS*/.toCharArray(), new char[] {'N'}); //N stands for null even if it is never internally used
+ final BaseTypeBinding VoidBinding = new BaseTypeBinding(TypeIds.T_void, "void"/*nonNLS*/.toCharArray(), new char[] {'V'});
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 25a88b758d..683a61763c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -376,71 +376,71 @@ public ReferenceBinding[] superInterfaces() {
return superInterfaces;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
- if (isDeprecated()) s += "deprecated "; //$NON-NLS-1$
- if (isPublic()) s += "public "; //$NON-NLS-1$
- if (isProtected()) s += "protected "; //$NON-NLS-1$
- if (isPrivate()) s += "private "; //$NON-NLS-1$
- if (isAbstract() && isClass()) s += "abstract "; //$NON-NLS-1$
- if (isStatic() && isNestedType()) s += "static "; //$NON-NLS-1$
- if (isFinal()) s += "final "; //$NON-NLS-1$
+ if (isDeprecated()) s += "deprecated "/*nonNLS*/;
+ if (isPublic()) s += "public "/*nonNLS*/;
+ if (isProtected()) s += "protected "/*nonNLS*/;
+ if (isPrivate()) s += "private "/*nonNLS*/;
+ if (isAbstract() && isClass()) s += "abstract "/*nonNLS*/;
+ if (isStatic() && isNestedType()) s += "static "/*nonNLS*/;
+ if (isFinal()) s += "final "/*nonNLS*/;
- s += isInterface() ? "interface " : "class "; //$NON-NLS-1$ //$NON-NLS-2$
- s += (compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"; //$NON-NLS-1$
+ s += isInterface() ? "interface "/*nonNLS*/ : "class "/*nonNLS*/;
+ s += (compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"/*nonNLS*/;
- s += "\n\textends "; //$NON-NLS-1$
- s += (superclass != null) ? superclass.debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += "\n\textends "/*nonNLS*/;
+ s += (superclass != null) ? superclass.debugName() : "NULL TYPE"/*nonNLS*/;
if (superInterfaces != null) {
if (superInterfaces != NoSuperInterfaces) {
- s += "\n\timplements : "; //$NON-NLS-1$
+ s += "\n\timplements : "/*nonNLS*/;
for (int i = 0, length = superInterfaces.length; i < length; i++) {
if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += (superInterfaces[i] != null) ? superInterfaces[i].debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
+ s += (superInterfaces[i] != null) ? superInterfaces[i].debugName() : "NULL TYPE"/*nonNLS*/;
}
}
} else {
- s += "NULL SUPERINTERFACES"; //$NON-NLS-1$
+ s += "NULL SUPERINTERFACES"/*nonNLS*/;
}
if (enclosingType != null) {
- s += "\n\tenclosing type : "; //$NON-NLS-1$
+ s += "\n\tenclosing type : "/*nonNLS*/;
s += enclosingType.debugName();
}
if (fields != null) {
if (fields != NoFields) {
- s += "\n/* fields */"; //$NON-NLS-1$
+ s += "\n/* fields */"/*nonNLS*/;
for (int i = 0, length = fields.length; i < length; i++)
- s += (fields[i] != null) ? "\n" + fields[i].toString() : "\nNULL FIELD"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (fields[i] != null) ? "\n"/*nonNLS*/ + fields[i].toString() : "\nNULL FIELD"/*nonNLS*/;
}
} else {
- s += "NULL FIELDS"; //$NON-NLS-1$
+ s += "NULL FIELDS"/*nonNLS*/;
}
if (methods != null) {
if (methods != NoMethods) {
- s += "\n/* methods */"; //$NON-NLS-1$
+ s += "\n/* methods */"/*nonNLS*/;
for (int i = 0, length = methods.length; i < length; i++)
- s += (methods[i] != null) ? "\n" + methods[i].toString() : "\nNULL METHOD"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (methods[i] != null) ? "\n"/*nonNLS*/ + methods[i].toString() : "\nNULL METHOD"/*nonNLS*/;
}
} else {
- s += "NULL METHODS"; //$NON-NLS-1$
+ s += "NULL METHODS"/*nonNLS*/;
}
if (memberTypes != null) {
if (memberTypes != NoMemberTypes) {
- s += "\n/* members */"; //$NON-NLS-1$
+ s += "\n/* members */"/*nonNLS*/;
for (int i = 0, length = memberTypes.length; i < length; i++)
- s += (memberTypes[i] != null) ? "\n" + memberTypes[i].toString() : "\nNULL TYPE"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (memberTypes[i] != null) ? "\n"/*nonNLS*/ + memberTypes[i].toString() : "\nNULL TYPE"/*nonNLS*/;
}
} else {
- s += "NULL MEMBER TYPES"; //$NON-NLS-1$
+ s += "NULL MEMBER TYPES"/*nonNLS*/;
}
- s += "\n\n\n"; //$NON-NLS-1$
+ s += "\n\n\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
index 02e4351bd1..a4e14bc176 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
@@ -139,16 +139,16 @@ public final boolean allowBlankFinalFieldAssignment(FieldBinding binding) {
|| ((AbstractMethodDeclaration) methodScope.referenceContext).isInitializationMethod(); // inside constructor or clinit
}
String basicToString(int tab) {
- String newLine = "\n"; //$NON-NLS-1$
+ String newLine = "\n"/*nonNLS*/;
for (int i = tab; --i >= 0;)
- newLine += "\t"; //$NON-NLS-1$
+ newLine += "\t"/*nonNLS*/;
- String s = newLine + "--- Block Scope ---"; //$NON-NLS-1$
- newLine += "\t"; //$NON-NLS-1$
- s += newLine + "locals:"; //$NON-NLS-1$
+ String s = newLine + "--- Block Scope ---"/*nonNLS*/;
+ newLine += "\t"/*nonNLS*/;
+ s += newLine + "locals:"/*nonNLS*/;
for (int i = 0; i < localIndex; i++)
- s += newLine + "\t" + locals[i].toString(); //$NON-NLS-1$
- s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$
+ s += newLine + "\t"/*nonNLS*/ + locals[i].toString();
+ s += newLine + "startIndex = "/*nonNLS*/ + startIndex;
return s;
}
private void checkAndSetModifiersForVariable(LocalVariableBinding varBinding) {
@@ -1175,7 +1175,7 @@ public String toString(int tab) {
String s = basicToString(tab);
for (int i = 0; i < scopeIndex; i++)
if (subscopes[i] instanceof BlockScope)
- s += ((BlockScope) subscopes[i]).toString(tab + 1) + "\n"; //$NON-NLS-1$
+ s += ((BlockScope) subscopes[i]).toString(tab + 1) + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 46d5372399..02a39d28e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -11,676 +11,606 @@ import org.eclipse.jdt.internal.compiler.util.*;
public class ClassScope extends Scope {
public TypeDeclaration referenceContext;
-
- public ClassScope(Scope parent, TypeDeclaration context) {
- super(CLASS_SCOPE, parent);
- this.referenceContext = context;
+public ClassScope(Scope parent, TypeDeclaration context) {
+ super(CLASS_SCOPE, parent);
+ this.referenceContext = context;
+}
+void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) {
+ buildLocalType(enclosingType, enclosingType.fPackage);
+
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if (supertype.isInterface()) {
+ sourceType.superclass = getJavaLangObject();
+ sourceType.superInterfaces = new ReferenceBinding[] {supertype};
+ } else {
+ sourceType.superclass = supertype;
+ sourceType.superInterfaces = TypeBinding.NoSuperInterfaces;
}
-
- void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) {
- buildLocalType(enclosingType, enclosingType.fPackage);
-
- SourceTypeBinding sourceType = referenceContext.binding;
- if (supertype.isInterface()) {
- sourceType.superclass = getJavaLangObject();
- sourceType.superInterfaces = new ReferenceBinding[] { supertype };
- } else {
- sourceType.superclass = supertype;
- sourceType.superInterfaces = TypeBinding.NoSuperInterfaces;
- }
- connectMemberTypes();
- buildFieldsAndMethods();
- sourceType.verifyMethods(environment().methodVerifier());
+ connectMemberTypes();
+ buildFieldsAndMethods();
+ sourceType.verifyMethods(environment().methodVerifier());
+}
+private void buildFields() {
+ if (referenceContext.fields == null) {
+ referenceContext.binding.fields = NoFields;
+ return;
}
-
- private void buildFields() {
- if (referenceContext.fields == null) {
- referenceContext.binding.fields = NoFields;
- return;
- }
- // count the number of fields vs. initializers
- FieldDeclaration[] fields = referenceContext.fields;
- int size = fields.length;
- int count = 0;
- for (int i = 0; i < size; i++)
- if (fields[i].isField())
- count++;
-
- // iterate the field declarations to create the bindings, lose all duplicates
- FieldBinding[] fieldBindings = new FieldBinding[count];
- HashtableOfObject knownFieldNames = new HashtableOfObject(count);
- boolean duplicate = false;
- count = 0;
- for (int i = 0; i < size; i++) {
- FieldDeclaration field = fields[i];
- if (!field.isField()) {
- if (referenceContext.binding.isInterface())
- problemReporter().interfaceCannotHaveInitializers(referenceContext.binding, field);
- } else {
- FieldBinding fieldBinding = new FieldBinding(field, null, referenceContext.binding);
- // field's type will be resolved when needed for top level types
- checkAndSetModifiersForField(fieldBinding, field);
-
- if (knownFieldNames.containsKey(field.name)) {
- duplicate = true;
- FieldBinding previousBinding = (FieldBinding) knownFieldNames.get(field.name);
- if (previousBinding != null) {
- for (int f = 0; f < i; f++) {
- FieldDeclaration previousField = fields[f];
- if (previousField.binding == previousBinding) {
- problemReporter().duplicateFieldInType(referenceContext.binding, previousField);
- previousField.binding = null;
- break;
- }
+
+ // count the number of fields vs. initializers
+ FieldDeclaration[] fields = referenceContext.fields;
+ int size = fields.length;
+ int count = 0;
+ for (int i = 0; i < size; i++)
+ if (fields[i].isField())
+ count++;
+
+ // iterate the field declarations to create the bindings, lose all duplicates
+ FieldBinding[] fieldBindings = new FieldBinding[count];
+ HashtableOfObject knownFieldNames = new HashtableOfObject(count);
+ boolean duplicate = false;
+ count = 0;
+ for (int i = 0; i < size; i++) {
+ FieldDeclaration field = fields[i];
+ if (!field.isField()) {
+ if (referenceContext.binding.isInterface())
+ problemReporter().interfaceCannotHaveInitializers(referenceContext.binding, field);
+ } else {
+ FieldBinding fieldBinding = new FieldBinding(field, null, referenceContext.binding); // field's type will be resolved when needed for top level types
+ checkAndSetModifiersForField(fieldBinding, field);
+
+ if (knownFieldNames.containsKey(field.name)) {
+ duplicate = true;
+ FieldBinding previousBinding = (FieldBinding) knownFieldNames.get(field.name);
+ if (previousBinding != null) {
+ for (int f = 0; f < i; f++) {
+ FieldDeclaration previousField = fields[f];
+ if (previousField.binding == previousBinding) {
+ problemReporter().duplicateFieldInType(referenceContext.binding, previousField);
+ previousField.binding = null;
+ break;
}
}
- knownFieldNames.put(field.name, null); // ensure that the duplicate field is found & removed
- problemReporter().duplicateFieldInType(referenceContext.binding, field);
- field.binding = null;
- } else {
- knownFieldNames.put(field.name, fieldBinding);
- // remember that we have seen a field with this name
- if (fieldBinding != null)
- fieldBindings[count++] = fieldBinding;
}
+ knownFieldNames.put(field.name, null); // ensure that the duplicate field is found & removed
+ problemReporter().duplicateFieldInType(referenceContext.binding, field);
+ field.binding = null;
+ } else {
+ knownFieldNames.put(field.name, fieldBinding); // remember that we have seen a field with this name
+ if (fieldBinding != null)
+ fieldBindings[count++] = fieldBinding;
}
}
- // remove duplicate fields
- if (duplicate) {
- FieldBinding[] newFieldBindings = new FieldBinding[knownFieldNames.size() - 1];
- // we know we'll be removing at least 1 duplicate name
- size = count;
- count = 0;
- for (int i = 0; i < size; i++) {
- FieldBinding fieldBinding = fieldBindings[i];
- if (knownFieldNames.get(fieldBinding.name) != null)
- newFieldBindings[count++] = fieldBinding;
- }
- fieldBindings = newFieldBindings;
- }
-
- if (count != fieldBindings.length)
- System.arraycopy(fieldBindings, 0, fieldBindings = new FieldBinding[count], 0, count);
- for (int i = 0; i < count; i++)
- fieldBindings[i].id = i;
- referenceContext.binding.fields = fieldBindings;
- if (referenceContext.binding.isLocalType())
- referenceContext.binding.fields();
- // fault the types for the local type's fields now since we need them
}
-
- void buildFieldsAndMethods() {
- buildFields();
- buildMethods();
-
- SourceTypeBinding sourceType = referenceContext.binding;
- if (sourceType.isMemberType() && !sourceType.isLocalType())
- ((MemberTypeBinding) sourceType).checkSyntheticArgsAndFields();
-
- ReferenceBinding[] memberTypes = sourceType.memberTypes;
- for (int i = 0, length = memberTypes.length; i < length; i++)
- ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods();
+
+ // remove duplicate fields
+ if (duplicate) {
+ FieldBinding[] newFieldBindings = new FieldBinding[knownFieldNames.size() - 1]; // we know we'll be removing at least 1 duplicate name
+ size = count;
+ count = 0;
+ for (int i = 0; i < size; i++) {
+ FieldBinding fieldBinding = fieldBindings[i];
+ if (knownFieldNames.get(fieldBinding.name) != null)
+ newFieldBindings[count++] = fieldBinding;
+ }
+ fieldBindings = newFieldBindings;
}
-
- private LocalTypeBinding buildLocalType(
- SourceTypeBinding enclosingType,
- PackageBinding packageBinding) {
- referenceContext.scope = this;
- referenceContext.staticInitializerScope = new MethodScope(this, referenceContext, true);
- referenceContext.initializerScope = new MethodScope(this, referenceContext, false);
-
- // build the binding or the local type
- LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType);
- referenceContext.binding = localType;
- checkAndSetModifiers();
-
- // Look at member types
- ReferenceBinding[] memberTypeBindings = NoMemberTypes;
- if (referenceContext.memberTypes != null) {
- int size = referenceContext.memberTypes.length;
- memberTypeBindings = new ReferenceBinding[size];
- int count = 0;
- nextMember : for (int i = 0; i < size; i++) {
- TypeDeclaration memberContext = referenceContext.memberTypes[i];
- if (memberContext.isInterface()) {
- problemReporter().nestedClassCannotDeclareInterface(memberContext);
+
+ if (count != fieldBindings.length)
+ System.arraycopy(fieldBindings, 0, fieldBindings = new FieldBinding[count], 0, count);
+ for (int i = 0; i < count; i++)
+ fieldBindings[i].id = i;
+ referenceContext.binding.fields = fieldBindings;
+ if (referenceContext.binding.isLocalType())
+ referenceContext.binding.fields(); // fault the types for the local type's fields now since we need them
+}
+void buildFieldsAndMethods() {
+ buildFields();
+ buildMethods();
+
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if (sourceType.isMemberType() && !sourceType.isLocalType())
+ ((MemberTypeBinding) sourceType).checkSyntheticArgsAndFields();
+
+ ReferenceBinding[] memberTypes = sourceType.memberTypes;
+ for (int i = 0, length = memberTypes.length; i < length; i++)
+ ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods();
+}
+private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, PackageBinding packageBinding) {
+ referenceContext.scope = this;
+ referenceContext.staticInitializerScope = new MethodScope(this, referenceContext, true);
+ referenceContext.initializerScope = new MethodScope(this, referenceContext, false);
+
+ // build the binding or the local type
+ LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType);
+ referenceContext.binding = localType;
+ checkAndSetModifiers();
+
+ // Look at member types
+ ReferenceBinding[] memberTypeBindings = NoMemberTypes;
+ if (referenceContext.memberTypes != null) {
+ int size = referenceContext.memberTypes.length;
+ memberTypeBindings = new ReferenceBinding[size];
+ int count = 0;
+ nextMember: for (int i = 0; i < size; i++) {
+ TypeDeclaration memberContext = referenceContext.memberTypes[i];
+ if (memberContext.isInterface()) {
+ problemReporter().nestedClassCannotDeclareInterface(memberContext);
+ continue nextMember;
+ }
+ ReferenceBinding type = localType;
+ // check that the member does not conflict with an enclosing type
+ do {
+ if (CharOperation.equals(type.sourceName, memberContext.name)) {
+ problemReporter().hidingEnclosingType(memberContext);
continue nextMember;
}
- ReferenceBinding type = localType;
- // check that the member does not conflict with an enclosing type
- do {
- if (CharOperation.equals(type.sourceName, memberContext.name)) {
- problemReporter().hidingEnclosingType(memberContext);
- continue nextMember;
- }
- type = type.enclosingType();
- } while (type != null);
- // check the member type does not conflict with another sibling member type
- for (int j = 0; j < i; j++) {
- if (CharOperation.equals(referenceContext.memberTypes[j].name, memberContext.name)) {
- problemReporter().duplicateNestedType(memberContext);
- continue nextMember;
- }
+ type = type.enclosingType();
+ } while (type != null);
+ // check the member type does not conflict with another sibling member type
+ for (int j = 0; j < i; j++) {
+ if (CharOperation.equals(referenceContext.memberTypes[j].name, memberContext.name)) {
+ problemReporter().duplicateNestedType(memberContext);
+ continue nextMember;
}
-
- ClassScope memberScope = new ClassScope(this, referenceContext.memberTypes[i]);
- LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, packageBinding);
- memberBinding.setAsMemberType();
- memberTypeBindings[count++] = memberBinding;
}
- if (count != size)
- System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
+
+ ClassScope memberScope = new ClassScope(this, referenceContext.memberTypes[i]);
+ LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, packageBinding);
+ memberBinding.setAsMemberType();
+ memberTypeBindings[count++] = memberBinding;
}
- localType.memberTypes = memberTypeBindings;
- return localType;
+ if (count != size)
+ System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
}
-
- void buildLocalTypeBinding(SourceTypeBinding enclosingType) {
- buildLocalType(enclosingType, enclosingType.fPackage);
- connectTypeHierarchy();
- buildFieldsAndMethods();
- referenceContext.binding.verifyMethods(environment().methodVerifier());
+ localType.memberTypes = memberTypeBindings;
+ return localType;
+}
+void buildLocalTypeBinding(SourceTypeBinding enclosingType) {
+ buildLocalType(enclosingType, enclosingType.fPackage);
+ connectTypeHierarchy();
+ buildFieldsAndMethods();
+ referenceContext.binding.verifyMethods(environment().methodVerifier());
+}
+private void buildMethods() {
+ if (referenceContext.methods == null) {
+ referenceContext.binding.methods = NoMethods;
+ return;
}
-
- private void buildMethods() {
- if (referenceContext.methods == null) {
- referenceContext.binding.methods = NoMethods;
- return;
- }
-
- // iterate the method declarations to create the bindings
- AbstractMethodDeclaration[] methods = referenceContext.methods;
- int size = methods.length;
- int clinitIndex = -1;
- for (int i = 0; i < size; i++) {
- if (methods[i] instanceof Clinit) {
- clinitIndex = i;
- break;
- }
- }
- MethodBinding[] methodBindings = new MethodBinding[clinitIndex == -1 ? size : size - 1];
- int count = 0;
- for (int i = 0; i < size; i++) {
- if (i != clinitIndex) {
- MethodScope scope = new MethodScope(this, methods[i], false);
- MethodBinding methodBinding = scope.createMethod(methods[i]);
- if (methodBinding != null) // is null if binding could not be created
- methodBindings[count++] = methodBinding;
- }
+ // iterate the method declarations to create the bindings
+ AbstractMethodDeclaration[] methods = referenceContext.methods;
+ int size = methods.length;
+ int clinitIndex = -1;
+ for (int i = 0; i < size; i++) {
+ if (methods[i] instanceof Clinit) {
+ clinitIndex = i;
+ break;
}
- if (count != methodBindings.length)
- System.arraycopy(methodBindings, 0, methodBindings = new MethodBinding[count], 0, count);
-
- referenceContext.binding.methods = methodBindings;
- referenceContext.binding.modifiers |= AccUnresolved; // until methods() is sent
- if (referenceContext.binding.isLocalType())
- referenceContext.binding.methods();
- // fault the types for the local type's methods now since we need them
}
- SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding packageBinding) {
- // provide the typeDeclaration with needed scopes
- referenceContext.scope = this;
- referenceContext.staticInitializerScope = new MethodScope(this, referenceContext, true);
- referenceContext.initializerScope = new MethodScope(this, referenceContext, false);
-
- if (enclosingType == null) {
- char[][] className = CharOperation.arrayConcat(packageBinding.compoundName, referenceContext.name);
- referenceContext.binding = new SourceTypeBinding(className, packageBinding, this);
- } else {
- char[][] className = CharOperation.deepCopy(enclosingType.compoundName);
- className[className.length - 1] =
- CharOperation.concat(className[className.length - 1], referenceContext.name, '$');
- referenceContext.binding = new MemberTypeBinding(className, this, enclosingType);
+ MethodBinding[] methodBindings = new MethodBinding[clinitIndex == -1 ? size : size - 1];
+
+ int count = 0;
+ for (int i = 0; i < size; i++) {
+ if (i != clinitIndex) {
+ MethodScope scope = new MethodScope(this, methods[i], false);
+ MethodBinding methodBinding = scope.createMethod(methods[i]);
+ if (methodBinding != null) // is null if binding could not be created
+ methodBindings[count++] = methodBinding;
}
+ }
+ if (count != methodBindings.length)
+ System.arraycopy(methodBindings, 0, methodBindings = new MethodBinding[count], 0, count);
+
+ referenceContext.binding.methods = methodBindings;
+ referenceContext.binding.modifiers |= AccUnresolved; // until methods() is sent
+ if (referenceContext.binding.isLocalType())
+ referenceContext.binding.methods(); // fault the types for the local type's methods now since we need them
+}
+SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding packageBinding) {
+ // provide the typeDeclaration with needed scopes
+ referenceContext.scope = this;
+ referenceContext.staticInitializerScope = new MethodScope(this, referenceContext, true);
+ referenceContext.initializerScope = new MethodScope(this, referenceContext, false);
+
+ if (enclosingType == null) {
+ char[][] className = CharOperation.arrayConcat(packageBinding.compoundName, referenceContext.name);
+ referenceContext.binding = new SourceTypeBinding(className, packageBinding, this);
+ } else {
+ char[][] className = CharOperation.deepCopy(enclosingType.compoundName);
+ className[className.length - 1] = CharOperation.concat(className[className.length - 1], referenceContext.name, '$');
+ referenceContext.binding = new MemberTypeBinding(className, this, enclosingType);
+ }
+
+ SourceTypeBinding sourceType = referenceContext.binding;
+ sourceType.fPackage.addType(sourceType);
+ checkAndSetModifiers();
- SourceTypeBinding sourceType = referenceContext.binding;
- sourceType.fPackage.addType(sourceType);
- checkAndSetModifiers();
-
- // Look at member types
- ReferenceBinding[] memberTypeBindings = NoMemberTypes;
- if (referenceContext.memberTypes != null) {
- int size = referenceContext.memberTypes.length;
- memberTypeBindings = new ReferenceBinding[size];
- int count = 0;
- nextMember : for (int i = 0; i < size; i++) {
- TypeDeclaration memberContext = referenceContext.memberTypes[i];
- if (memberContext.isInterface()
- && sourceType.isNestedType()
- && sourceType.isClass()
- && !sourceType.isStatic()) {
- problemReporter().nestedClassCannotDeclareInterface(memberContext);
+ // Look at member types
+ ReferenceBinding[] memberTypeBindings = NoMemberTypes;
+ if (referenceContext.memberTypes != null) {
+ int size = referenceContext.memberTypes.length;
+ memberTypeBindings = new ReferenceBinding[size];
+ int count = 0;
+ nextMember: for (int i = 0; i < size; i++) {
+ TypeDeclaration memberContext = referenceContext.memberTypes[i];
+ if (memberContext.isInterface() && sourceType.isNestedType() && sourceType.isClass() && !sourceType.isStatic()) {
+ problemReporter().nestedClassCannotDeclareInterface(memberContext);
+ continue nextMember;
+ }
+ ReferenceBinding type = sourceType;
+ // check that the member does not conflict with an enclosing type
+ do {
+ if (CharOperation.equals(type.sourceName, memberContext.name)) {
+ problemReporter().hidingEnclosingType(memberContext);
continue nextMember;
}
- ReferenceBinding type = sourceType;
- // check that the member does not conflict with an enclosing type
- do {
- if (CharOperation.equals(type.sourceName, memberContext.name)) {
- problemReporter().hidingEnclosingType(memberContext);
- continue nextMember;
- }
- type = type.enclosingType();
- } while (type != null);
- // check that the member type does not conflict with another sibling member type
- for (int j = 0; j < i; j++) {
- if (CharOperation.equals(referenceContext.memberTypes[j].name, memberContext.name)) {
- problemReporter().duplicateNestedType(memberContext);
- continue nextMember;
- }
+ type = type.enclosingType();
+ } while (type != null);
+ // check that the member type does not conflict with another sibling member type
+ for (int j = 0; j < i; j++) {
+ if (CharOperation.equals(referenceContext.memberTypes[j].name, memberContext.name)) {
+ problemReporter().duplicateNestedType(memberContext);
+ continue nextMember;
}
-
- ClassScope memberScope = new ClassScope(this, memberContext);
- memberTypeBindings[count++] = memberScope.buildType(sourceType, packageBinding);
}
- if (count != size)
- System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
+
+ ClassScope memberScope = new ClassScope(this, memberContext);
+ memberTypeBindings[count++] = memberScope.buildType(sourceType, packageBinding);
}
- sourceType.memberTypes = memberTypeBindings;
- return sourceType;
+ if (count != size)
+ System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
}
-
- private void checkAndSetModifiers() {
- SourceTypeBinding sourceType = referenceContext.binding;
- int modifiers = sourceType.modifiers;
- if ((modifiers & AccAlternateModifierProblem) != 0)
- problemReporter().duplicateModifierForType(sourceType);
-
- if (sourceType.isMemberType()) {
- // checks for member types before local types to catch local members
- if (sourceType.enclosingType().isStrictfp())
+ sourceType.memberTypes = memberTypeBindings;
+ return sourceType;
+}
+private void checkAndSetModifiers() {
+ SourceTypeBinding sourceType = referenceContext.binding;
+ int modifiers = sourceType.modifiers;
+ if ((modifiers & AccAlternateModifierProblem) != 0)
+ problemReporter().duplicateModifierForType(sourceType);
+
+ if (sourceType.isMemberType()) { // checks for member types before local types to catch local members
+ if (sourceType.enclosingType().isStrictfp())
+ modifiers |= AccStrictfp;
+ if (sourceType.enclosingType().isDeprecated())
+ modifiers |= AccDeprecatedImplicitly;
+ if (sourceType.enclosingType().isInterface())
+ modifiers |= AccPublic;
+ } else if (sourceType.isLocalType()) {
+ if (sourceType.isAnonymousType())
+ modifiers |= AccFinal;
+ ReferenceContext refContext = methodScope().referenceContext;
+ if (refContext instanceof TypeDeclaration) {
+ ReferenceBinding type = ((TypeDeclaration) refContext).binding;
+ if (type.isStrictfp())
modifiers |= AccStrictfp;
- if (sourceType.enclosingType().isDeprecated())
+ if (type.isDeprecated())
modifiers |= AccDeprecatedImplicitly;
- if (sourceType.enclosingType().isInterface())
- modifiers |= AccPublic;
- } else if (sourceType.isLocalType()) {
- if (sourceType.isAnonymousType())
- modifiers |= AccFinal;
- ReferenceContext refContext = methodScope().referenceContext;
- if (refContext instanceof TypeDeclaration) {
- ReferenceBinding type = ((TypeDeclaration) refContext).binding;
- if (type.isStrictfp())
- modifiers |= AccStrictfp;
- if (type.isDeprecated())
- modifiers |= AccDeprecatedImplicitly;
- } else {
- MethodBinding method = ((AbstractMethodDeclaration) refContext).binding;
- if (method.isStrictfp())
- modifiers |= AccStrictfp;
- if (method.isDeprecated())
- modifiers |= AccDeprecatedImplicitly;
- }
- }
- // after this point, tests on the 16 bits reserved.
- int realModifiers = modifiers & AccJustFlag;
-
- if ((realModifiers & AccInterface) != 0) {
- // detect abnormal cases for interfaces
- if (sourceType.isMemberType()) {
- int unexpectedModifiers =
- ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccInterface | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForMemberInterface(sourceType);
- /*
- } else if (sourceType.isLocalType()) { //interfaces cannot be defined inside a method
- int unexpectedModifiers = ~(AccAbstract | AccInterface | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForLocalInterface(sourceType);
- */
- } else {
- int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForInterface(sourceType);
- }
- modifiers |= AccAbstract;
} else {
- // detect abnormal cases for types
- if (sourceType.isMemberType()) { // includes member types defined inside local types
- int unexpectedModifiers =
- ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccFinal | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForMemberClass(sourceType);
- } else if (sourceType.isLocalType()) {
- int unexpectedModifiers = ~(AccAbstract | AccFinal | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForLocalClass(sourceType);
- } else {
- int unexpectedModifiers = ~(AccPublic | AccAbstract | AccFinal | AccStrictfp);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForClass(sourceType);
- }
-
- // check that Final and Abstract are not set together
- if ((realModifiers & (AccFinal | AccAbstract)) == (AccFinal | AccAbstract))
- problemReporter().illegalModifierCombinationFinalAbstractForClass(sourceType);
+ MethodBinding method = ((AbstractMethodDeclaration) refContext).binding;
+ if (method.isStrictfp())
+ modifiers |= AccStrictfp;
+ if (method.isDeprecated())
+ modifiers |= AccDeprecatedImplicitly;
}
+ }
+
+ // after this point, tests on the 16 bits reserved.
+ int realModifiers = modifiers & AccJustFlag;
+ if ((realModifiers & AccInterface) != 0) {
+ // detect abnormal cases for interfaces
if (sourceType.isMemberType()) {
- // test visibility modifiers inconsistency, isolate the accessors bits
- if (sourceType.enclosingType().isInterface()) {
- if ((realModifiers & (AccProtected | AccPrivate)) != 0) {
- problemReporter().illegalVisibilityModifierForInterfaceMemberType(sourceType);
+ int unexpectedModifiers = ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccInterface | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForMemberInterface(sourceType);
+ /*
+ } else if (sourceType.isLocalType()) { //interfaces cannot be defined inside a method
+ int unexpectedModifiers = ~(AccAbstract | AccInterface | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForLocalInterface(sourceType);
+ */
+ } else {
+ int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForInterface(sourceType);
+ }
+ modifiers |= AccAbstract;
+ } else {
+ // detect abnormal cases for types
+ if (sourceType.isMemberType()) { // includes member types defined inside local types
+ int unexpectedModifiers = ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccFinal | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForMemberClass(sourceType);
+ } else if (sourceType.isLocalType()) {
+ int unexpectedModifiers = ~(AccAbstract | AccFinal | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForLocalClass(sourceType);
+ } else {
+ int unexpectedModifiers = ~(AccPublic | AccAbstract | AccFinal | AccStrictfp);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForClass(sourceType);
+ }
+
+ // check that Final and Abstract are not set together
+ if ((realModifiers & (AccFinal | AccAbstract)) == (AccFinal | AccAbstract))
+ problemReporter().illegalModifierCombinationFinalAbstractForClass(sourceType);
+ }
- // need to keep the less restrictive
- if ((realModifiers & AccProtected) != 0)
+ if (sourceType.isMemberType()) {
+ // test visibility modifiers inconsistency, isolate the accessors bits
+ if (sourceType.enclosingType().isInterface()) {
+ if ((realModifiers & (AccProtected | AccPrivate)) != 0) {
+ problemReporter().illegalVisibilityModifierForInterfaceMemberType(sourceType);
+
+ // need to keep the less restrictive
+ if ((realModifiers & AccProtected) != 0)
+ modifiers ^= AccProtected;
+ if ((realModifiers & AccPrivate) != 0)
+ modifiers ^= AccPrivate;
+ }
+ } else {
+ int accessorBits = realModifiers & (AccPublic | AccProtected | AccPrivate);
+ if ((accessorBits & (accessorBits - 1)) > 1) {
+ problemReporter().illegalVisibilityModifierCombinationForMemberType(sourceType);
+
+ // need to keep the less restrictive
+ if ((accessorBits & AccPublic) != 0) {
+ if ((accessorBits & AccProtected) != 0)
modifiers ^= AccProtected;
- if ((realModifiers & AccPrivate) != 0)
+ if ((accessorBits & AccPrivate) != 0)
modifiers ^= AccPrivate;
}
- } else {
- int accessorBits = realModifiers & (AccPublic | AccProtected | AccPrivate);
- if ((accessorBits & (accessorBits - 1)) > 1) {
- problemReporter().illegalVisibilityModifierCombinationForMemberType(sourceType);
-
- // need to keep the less restrictive
- if ((accessorBits & AccPublic) != 0) {
- if ((accessorBits & AccProtected) != 0)
- modifiers ^= AccProtected;
- if ((accessorBits & AccPrivate) != 0)
- modifiers ^= AccPrivate;
- }
- if ((accessorBits & AccProtected) != 0)
- if ((accessorBits & AccPrivate) != 0)
- modifiers ^= AccPrivate;
- }
+ if ((accessorBits & AccProtected) != 0)
+ if ((accessorBits & AccPrivate) != 0)
+ modifiers ^= AccPrivate;
}
+ }
- // static modifier test
- if ((realModifiers & AccStatic) == 0) {
- if (sourceType.enclosingType().isInterface())
- modifiers |= AccStatic;
- } else {
- if (!sourceType.enclosingType().isStatic())
- // error the enclosing type of a static field must be static or a top-level type
- problemReporter().illegalStaticModifierForMemberType(sourceType);
- }
+ // static modifier test
+ if ((realModifiers & AccStatic) == 0) {
+ if (sourceType.enclosingType().isInterface())
+ modifiers |= AccStatic;
+ } else {
+ if (!sourceType.enclosingType().isStatic())
+ // error the enclosing type of a static field must be static or a top-level type
+ problemReporter().illegalStaticModifierForMemberType(sourceType);
}
+ }
- sourceType.modifiers = modifiers;
+ sourceType.modifiers = modifiers;
+}
+/* This method checks the modifiers of a field.
+*
+* 9.3 & 8.3
+* Need to integrate the check for the final modifiers for nested types
+*
+* Note : A scope is accessible by : fieldBinding.declaringClass.scope
+*/
+
+private void checkAndSetModifiersForField(FieldBinding fieldBinding, FieldDeclaration fieldDecl) {
+ int modifiers = fieldBinding.modifiers;
+ if ((modifiers & AccAlternateModifierProblem) != 0)
+ problemReporter().duplicateModifierForField(fieldBinding.declaringClass, fieldDecl);
+
+ if (fieldBinding.declaringClass.isInterface()) {
+ int expectedValue = AccPublic | AccStatic | AccFinal;
+ // set the modifiers
+ modifiers |= expectedValue;
+
+ // and then check that they are the only ones
+ if ((modifiers & AccJustFlag) != expectedValue)
+ problemReporter().illegalModifierForInterfaceField(fieldBinding.declaringClass, fieldDecl);
+ fieldBinding.modifiers = modifiers;
+ return;
}
-
- /* This method checks the modifiers of a field.
- *
- * 9.3 & 8.3
- * Need to integrate the check for the final modifiers for nested types
- *
- * Note : A scope is accessible by : fieldBinding.declaringClass.scope
- */
- private void checkAndSetModifiersForField(FieldBinding fieldBinding, FieldDeclaration fieldDecl) {
- int modifiers = fieldBinding.modifiers;
- if ((modifiers & AccAlternateModifierProblem) != 0)
- problemReporter().duplicateModifierForField(fieldBinding.declaringClass, fieldDecl);
-
- if (fieldBinding.declaringClass.isInterface()) {
- int expectedValue = AccPublic | AccStatic | AccFinal;
- // set the modifiers
- modifiers |= expectedValue;
-
- // and then check that they are the only ones
- if ((modifiers & AccJustFlag) != expectedValue)
- problemReporter().illegalModifierForInterfaceField(fieldBinding.declaringClass, fieldDecl);
- fieldBinding.modifiers = modifiers;
- return;
- }
- // after this point, tests on the 16 bits reserved.
- int realModifiers = modifiers & AccJustFlag;
- int unexpectedModifiers =
- ~(AccPublic | AccPrivate | AccProtected | AccFinal | AccStatic | AccTransient | AccVolatile);
- if ((realModifiers & unexpectedModifiers) != 0)
- problemReporter().illegalModifierForField(fieldBinding.declaringClass, fieldDecl);
-
- int accessorBits = realModifiers & (AccPublic | AccProtected | AccPrivate);
- if ((accessorBits & (accessorBits - 1)) > 1) {
- problemReporter().illegalVisibilityModifierCombinationForField(
- fieldBinding.declaringClass,
- fieldDecl);
-
- // need to keep the less restrictive
- if ((accessorBits & AccPublic) != 0) {
- if ((accessorBits & AccProtected) != 0)
- modifiers ^= AccProtected;
- if ((accessorBits & AccPrivate) != 0)
- modifiers ^= AccPrivate;
- }
- if ((accessorBits & AccProtected) != 0)
- if ((accessorBits & AccPrivate) != 0)
- modifiers ^= AccPrivate;
- }
+ // after this point, tests on the 16 bits reserved.
+ int realModifiers = modifiers & AccJustFlag;
+ int unexpectedModifiers = ~(AccPublic | AccPrivate | AccProtected | AccFinal | AccStatic | AccTransient | AccVolatile);
+ if ((realModifiers & unexpectedModifiers) != 0)
+ problemReporter().illegalModifierForField(fieldBinding.declaringClass, fieldDecl);
- if ((realModifiers & (AccFinal | AccVolatile)) == (AccFinal | AccVolatile))
- problemReporter().illegalModifierCombinationFinalVolatileForField(
- fieldBinding.declaringClass,
- fieldDecl);
+ int accessorBits = realModifiers & (AccPublic | AccProtected | AccPrivate);
+ if ((accessorBits & (accessorBits - 1)) > 1) {
+ problemReporter().illegalVisibilityModifierCombinationForField(fieldBinding.declaringClass, fieldDecl);
- fieldBinding.modifiers = modifiers;
+ // need to keep the less restrictive
+ if ((accessorBits & AccPublic) != 0) {
+ if ((accessorBits & AccProtected) != 0)
+ modifiers ^= AccProtected;
+ if ((accessorBits & AccPrivate) != 0)
+ modifiers ^= AccPrivate;
+ }
+ if ((accessorBits & AccProtected) != 0)
+ if ((accessorBits & AccPrivate) != 0)
+ modifiers ^= AccPrivate;
}
-
- private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
- // search up the hierarchy of the sourceType to see if any superType defines a member type
- // when no member types are defined, tag the sourceType & each superType with the HasNoMemberTypes bit
- ReferenceBinding currentType = sourceType;
- ReferenceBinding[][] interfacesToVisit = null;
- int lastPosition = -1;
- do {
- if ((currentType.tagBits & HasNoMemberTypes) != 0)
- break; // already know it has no inherited member types, can stop looking up
- if (currentType.memberTypes() != NoMemberTypes)
- return; // has member types
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (interfacesToVisit == null)
- interfacesToVisit = new ReferenceBinding[5][];
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
- } while ((currentType = currentType.superclass()) != null);
- boolean hasMembers = false;
- if (interfacesToVisit != null) {
- done : for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- ReferenceBinding anInterface = interfaces[j];
- if ((anInterface.tagBits & InterfaceVisited) == 0) { // if interface as not already been visited
- anInterface.tagBits |= InterfaceVisited;
- if ((anInterface.tagBits & HasNoMemberTypes) != 0)
- continue; // already know it has no inherited member types
- if (anInterface.memberTypes() != NoMemberTypes) {
- hasMembers = true;
- break done;
- }
+ if ((realModifiers & (AccFinal | AccVolatile)) == (AccFinal | AccVolatile))
+ problemReporter().illegalModifierCombinationFinalVolatileForField(fieldBinding.declaringClass, fieldDecl);
+
+ fieldBinding.modifiers = modifiers;
+}
+private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
+ // search up the hierarchy of the sourceType to see if any superType defines a member type
+ // when no member types are defined, tag the sourceType & each superType with the HasNoMemberTypes bit
+ ReferenceBinding currentType = sourceType;
+ ReferenceBinding[][] interfacesToVisit = null;
+ int lastPosition = -1;
+ do {
+ if ((currentType.tagBits & HasNoMemberTypes) != 0) break; // already know it has no inherited member types, can stop looking up
+ if (currentType.memberTypes() != NoMemberTypes) return; // has member types
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (interfacesToVisit == null)
+ interfacesToVisit = new ReferenceBinding[5][];
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
+ }
+ } while ((currentType = currentType.superclass()) != null);
+
+ boolean hasMembers = false;
+ if (interfacesToVisit != null) {
+ done : for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding anInterface = interfaces[j];
+ if ((anInterface.tagBits & InterfaceVisited) == 0) { // if interface as not already been visited
+ anInterface.tagBits |= InterfaceVisited;
+ if ((anInterface.tagBits & HasNoMemberTypes) != 0) continue; // already know it has no inherited member types
+ if (anInterface.memberTypes() != NoMemberTypes) {
+ hasMembers = true;
+ break done;
+ }
- ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+ ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
+ }
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- interfaces[j].tagBits &= ~InterfaceVisited;
- if (!hasMembers)
- interfaces[j].tagBits |= HasNoMemberTypes;
- }
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ interfaces[j].tagBits &= ~InterfaceVisited;
+ if (!hasMembers)
+ interfaces[j].tagBits |= HasNoMemberTypes;
}
}
+ }
- if (!hasMembers) {
- currentType = sourceType;
- do {
- currentType.tagBits |= HasNoMemberTypes;
- } while ((currentType = currentType.superclass()) != null);
- }
+ if (!hasMembers) {
+ currentType = sourceType;
+ do {
+ currentType.tagBits |= HasNoMemberTypes;
+ } while ((currentType = currentType.superclass()) != null);
}
-
- private void connectMemberTypes() {
- SourceTypeBinding sourceType = referenceContext.binding;
- if (sourceType.memberTypes != NoMemberTypes)
- for (int i = 0, size = sourceType.memberTypes.length; i < size; i++)
- ((SourceTypeBinding) sourceType.memberTypes[i]).scope.connectTypeHierarchy();
+}
+private void connectMemberTypes() {
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if (sourceType.memberTypes != NoMemberTypes)
+ for (int i = 0, size = sourceType.memberTypes.length; i < size; i++)
+ ((SourceTypeBinding) sourceType.memberTypes[i]).scope.connectTypeHierarchy();
+}
+/*
+ Our current belief based on available JCK tests is:
+ inherited member types are visible as a potential superclass.
+ inherited interfaces are not visible when defining a superinterface.
+
+ Error recovery story:
+ ensure the superclass is set to java.lang.Object if a problem is detected
+ resolving the superclass.
+
+ Answer false if an error was reported against the sourceType.
+*/
+
+private boolean connectSuperclass() {
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if (referenceContext.superclass == null) {
+ if (isJavaLangObject(sourceType)) return true;
+ sourceType.superclass = getJavaLangObject();
+ compilationUnitScope().addTypeReference(sourceType.superclass);
+ return !detectCycle(sourceType, sourceType.superclass, null); // ensure Object is initialized if it comes from a source file
}
- /*
- Our current belief based on available JCK tests is:
- inherited member types are visible as a potential superclass.
- inherited interfaces are not visible when defining a superinterface.
-
- Error recovery story:
- ensure the superclass is set to java.lang.Object if a problem is detected
- resolving the superclass.
-
- Answer false if an error was reported against the sourceType.
- */
- private boolean connectSuperclass() {
- SourceTypeBinding sourceType = referenceContext.binding;
- if (referenceContext.superclass == null) {
- if (isJavaLangObject(sourceType))
- return true;
- sourceType.superclass = getJavaLangObject();
- compilationUnitScope().addTypeReference(sourceType.superclass);
- return !detectCycle(sourceType, sourceType.superclass, null);
- // ensure Object is initialized if it comes from a source file
- }
- ReferenceBinding superclass = findSupertype(referenceContext.superclass);
- if (superclass != null) { // is null if a cycle was detected cycle
- if (!superclass.isValidBinding()) {
- problemReporter().invalidSuperclass(sourceType, referenceContext.superclass, superclass);
- } else if (superclass.isInterface()) {
- problemReporter().superclassMustBeAClass(sourceType, referenceContext.superclass, superclass);
- } else if (superclass.isFinal()) {
- problemReporter().classExtendFinalClass(sourceType, referenceContext.superclass, superclass);
- } else if (isJavaLangObject(sourceType)) {
- // can only happen if Object extends another type... will never happen unless we're testing for it.
- sourceType.tagBits |= HierarchyHasProblems;
- sourceType.superclass = null;
- return true;
- } else {
- // only want to reach here when no errors are reported
- referenceContext.superclass.binding = superclass;
- sourceType.superclass = superclass;
- return true;
- }
- }
- sourceType.tagBits |= HierarchyHasProblems;
- if (!isJavaLangObject(sourceType)) {
- sourceType.superclass = getJavaLangObject();
- if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0)
- detectCycle(sourceType, sourceType.superclass, null);
- // ensure Object is initialized if it comes from a source file
+
+ ReferenceBinding superclass = findSupertype(referenceContext.superclass);
+ if (superclass != null) { // is null if a cycle was detected cycle
+ if (!superclass.isValidBinding()) {
+ problemReporter().invalidSuperclass(sourceType, referenceContext.superclass, superclass);
+ } else if (superclass.isInterface()) {
+ problemReporter().superclassMustBeAClass(sourceType, referenceContext.superclass, superclass);
+ } else if (superclass.isFinal()) {
+ problemReporter().classExtendFinalClass(sourceType, referenceContext.superclass, superclass);
+ } else if (isJavaLangObject(sourceType)) {
+ // can only happen if Object extends another type... will never happen unless we're testing for it.
+ sourceType.tagBits |= HierarchyHasProblems;
+ sourceType.superclass = null;
+ return true;
+ } else {
+ // only want to reach here when no errors are reported
+ referenceContext.superclass.binding = superclass;
+ sourceType.superclass = superclass;
+ return true;
}
- return false; // reported some error against the source type
}
- /*
- Our current belief based on available JCK 1.3 tests is:
- inherited member types are visible as a potential superclass.
- inherited interfaces are visible when defining a superinterface.
-
- Error recovery story:
- ensure the superinterfaces contain only valid visible interfaces.
-
- Answer false if an error was reported against the sourceType.
- */
- private boolean connectSuperInterfaces() {
- SourceTypeBinding sourceType = referenceContext.binding;
- sourceType.superInterfaces = NoSuperInterfaces;
- if (referenceContext.superInterfaces == null)
- return true;
+ sourceType.tagBits |= HierarchyHasProblems;
+ if (!isJavaLangObject(sourceType)) {
+ sourceType.superclass = getJavaLangObject();
+ if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0)
+ detectCycle(sourceType, sourceType.superclass, null); // ensure Object is initialized if it comes from a source file
+ }
+ return false; // reported some error against the source type
+}
+/*
+ Our current belief based on available JCK 1.3 tests is:
+ inherited member types are visible as a potential superclass.
+ inherited interfaces are visible when defining a superinterface.
+
+ Error recovery story:
+ ensure the superinterfaces contain only valid visible interfaces.
+
+ Answer false if an error was reported against the sourceType.
+*/
+
+private boolean connectSuperInterfaces() {
+ SourceTypeBinding sourceType = referenceContext.binding;
+ sourceType.superInterfaces = NoSuperInterfaces;
+ if (referenceContext.superInterfaces == null)
+ return true;
+
+ boolean noProblems = true;
+ int length = referenceContext.superInterfaces.length;
+ ReferenceBinding[] interfaceBindings = new ReferenceBinding[length];
+ int count = 0;
+ nextInterface : for (int i = 0; i < length; i++) {
+ ReferenceBinding superInterface = findSupertype(referenceContext.superInterfaces[i]);
+ if (superInterface == null) { // detected cycle
+ noProblems = false;
+ continue nextInterface;
+ }
+ if (!superInterface.isValidBinding()) {
+ problemReporter().invalidSuperinterface(sourceType, referenceContext.superInterfaces[i], superInterface);
+ sourceType.tagBits |= HierarchyHasProblems;
+ noProblems = false;
+ continue nextInterface;
+ }
- boolean noProblems = true;
- int length = referenceContext.superInterfaces.length;
- ReferenceBinding[] interfaceBindings = new ReferenceBinding[length];
- int count = 0;
- nextInterface : for (int i = 0; i < length; i++) {
- ReferenceBinding superInterface = findSupertype(referenceContext.superInterfaces[i]);
- if (superInterface == null) { // detected cycle
- noProblems = false;
- continue nextInterface;
- }
- if (!superInterface.isValidBinding()) {
- problemReporter().invalidSuperinterface(
- sourceType,
- referenceContext.superInterfaces[i],
- superInterface);
- sourceType.tagBits |= HierarchyHasProblems;
- noProblems = false;
+ // Check for a duplicate interface once the name is resolved, otherwise we may be confused (ie : a.b.I and c.d.I)
+ for (int k = 0; k < count; k++) {
+ if (interfaceBindings[k] == superInterface) {
+ // should this be treated as a warning?
+ problemReporter().duplicateSuperinterface(sourceType, referenceContext, superInterface);
continue nextInterface;
}
- // Check for a duplicate interface once the name is resolved, otherwise we may be confused (ie : a.b.I and c.d.I)
- for (int k = 0; k < count; k++) {
- if (interfaceBindings[k] == superInterface) {
- // should this be treated as a warning?
- problemReporter().duplicateSuperinterface(sourceType, referenceContext, superInterface);
- continue nextInterface;
- }
- }
- if (superInterface.isClass()) {
- problemReporter().superinterfaceMustBeAnInterface(sourceType, referenceContext, superInterface);
- sourceType.tagBits |= HierarchyHasProblems;
- noProblems = false;
- continue nextInterface;
- }
- referenceContext.superInterfaces[i].binding = superInterface;
- // only want to reach here when no errors are reported
- interfaceBindings[count++] = superInterface;
- }
- // hold onto all correctly resolved superinterfaces
- if (count > 0) {
- if (count != length)
- System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[count], 0, count);
- sourceType.superInterfaces = interfaceBindings;
}
- return noProblems;
- }
-
- void connectTypeHierarchy() {
- SourceTypeBinding sourceType = referenceContext.binding;
- if ((sourceType.tagBits & BeginHierarchyCheck) == 0) {
- boolean noProblems = true;
- sourceType.tagBits |= BeginHierarchyCheck;
- if (sourceType.isClass())
- noProblems &= connectSuperclass();
- noProblems &= connectSuperInterfaces();
- sourceType.tagBits |= EndHierarchyCheck;
- if (noProblems && sourceType.isHierarchyInconsistent())
- problemReporter().hierarchyHasProblems(sourceType);
+ if (superInterface.isClass()) {
+ problemReporter().superinterfaceMustBeAnInterface(sourceType, referenceContext, superInterface);
+ sourceType.tagBits |= HierarchyHasProblems;
+ noProblems = false;
+ continue nextInterface;
}
- connectMemberTypes();
- checkForInheritedMemberTypes(sourceType);
+ referenceContext.superInterfaces[i].binding = superInterface; // only want to reach here when no errors are reported
+ interfaceBindings[count++] = superInterface;
}
-
- private void connectTypeHierarchyWithoutMembers() {
- // must ensure the imports are resolved
- if (parent instanceof CompilationUnitScope) {
- if (((CompilationUnitScope) parent).imports == null)
- ((CompilationUnitScope) parent).checkAndSetImports();
- } else if (parent instanceof ClassScope) {
- // ensure that the enclosing type has already been checked
- ((ClassScope) parent).connectTypeHierarchyWithoutMembers();
- }
-
- // double check that the hierarchy search has not already begun...
- SourceTypeBinding sourceType = referenceContext.binding;
- if ((sourceType.tagBits & BeginHierarchyCheck) != 0)
- return;
+ // hold onto all correctly resolved superinterfaces
+ if (count > 0) {
+ if (count != length)
+ System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[count], 0, count);
+ sourceType.superInterfaces = interfaceBindings;
+ }
+ return noProblems;
+}
+void connectTypeHierarchy() {
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if ((sourceType.tagBits & BeginHierarchyCheck) == 0) {
boolean noProblems = true;
sourceType.tagBits |= BeginHierarchyCheck;
if (sourceType.isClass())
@@ -690,174 +620,190 @@ public class ClassScope extends Scope {
if (noProblems && sourceType.isHierarchyInconsistent())
problemReporter().hierarchyHasProblems(sourceType);
}
-
- // Answer whether a cycle was found between the sourceType & the superType
- private boolean detectCycle(
- SourceTypeBinding sourceType,
- ReferenceBinding superType,
- TypeReference reference) {
- if (sourceType == superType) {
- problemReporter().hierarchyCircularity(sourceType, superType, reference);
- sourceType.tagBits |= HierarchyHasProblems;
- return true;
+ connectMemberTypes();
+ checkForInheritedMemberTypes(sourceType);
+}
+private void connectTypeHierarchyWithoutMembers() {
+ // must ensure the imports are resolved
+ if (parent instanceof CompilationUnitScope) {
+ if (((CompilationUnitScope) parent).imports == null)
+ ((CompilationUnitScope) parent).checkAndSetImports();
+ } else if (parent instanceof ClassScope) {
+ // ensure that the enclosing type has already been checked
+ ((ClassScope) parent).connectTypeHierarchyWithoutMembers();
+ }
+
+ // double check that the hierarchy search has not already begun...
+ SourceTypeBinding sourceType = referenceContext.binding;
+ if ((sourceType.tagBits & BeginHierarchyCheck) != 0) return;
+
+ boolean noProblems = true;
+ sourceType.tagBits |= BeginHierarchyCheck;
+ if (sourceType.isClass())
+ noProblems &= connectSuperclass();
+ noProblems &= connectSuperInterfaces();
+ sourceType.tagBits |= EndHierarchyCheck;
+ if (noProblems && sourceType.isHierarchyInconsistent())
+ problemReporter().hierarchyHasProblems(sourceType);
+}
+// Answer whether a cycle was found between the sourceType & the superType
+
+private boolean detectCycle(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
+ if (sourceType == superType) {
+ problemReporter().hierarchyCircularity(sourceType, superType, reference);
+ sourceType.tagBits |= HierarchyHasProblems;
+ return true;
+ }
+
+ if (superType.isBinaryBinding()) {
+ // force its superclass & superinterfaces to be found... 2 possibilities exist - the source type is included in the hierarchy of:
+ // - a binary type... this case MUST be caught & reported here
+ // - another source type... this case is reported against the other source type
+ boolean hasCycle = false;
+ if (superType.superclass() != null) {
+ if (sourceType == superType.superclass()) {
+ problemReporter().hierarchyCircularity(sourceType, superType, reference);
+ sourceType.tagBits |= HierarchyHasProblems;
+ superType.tagBits |= HierarchyHasProblems;
+ return true;
+ }
+ hasCycle |= detectCycle(sourceType, superType.superclass(), reference);
+ if ((superType.superclass().tagBits & HierarchyHasProblems) != 0) {
+ sourceType.tagBits |= HierarchyHasProblems;
+ superType.tagBits |= HierarchyHasProblems; // propagate down the hierarchy
+ }
}
- if (superType.isBinaryBinding()) {
- // force its superclass & superinterfaces to be found... 2 possibilities exist - the source type is included in the hierarchy of:
- // - a binary type... this case MUST be caught & reported here
- // - another source type... this case is reported against the other source type
- boolean hasCycle = false;
- if (superType.superclass() != null) {
- if (sourceType == superType.superclass()) {
+ ReferenceBinding[] itsInterfaces = superType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ for (int i = 0, length = itsInterfaces.length; i < length; i++) {
+ ReferenceBinding anInterface = itsInterfaces[i];
+ if (sourceType == anInterface) {
problemReporter().hierarchyCircularity(sourceType, superType, reference);
sourceType.tagBits |= HierarchyHasProblems;
superType.tagBits |= HierarchyHasProblems;
return true;
}
- hasCycle |= detectCycle(sourceType, superType.superclass(), reference);
- if ((superType.superclass().tagBits & HierarchyHasProblems) != 0) {
+ hasCycle |= detectCycle(sourceType, anInterface, reference);
+ if ((anInterface.tagBits & HierarchyHasProblems) != 0) {
sourceType.tagBits |= HierarchyHasProblems;
- superType.tagBits |= HierarchyHasProblems; // propagate down the hierarchy
- }
- }
-
- ReferenceBinding[] itsInterfaces = superType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- for (int i = 0, length = itsInterfaces.length; i < length; i++) {
- ReferenceBinding anInterface = itsInterfaces[i];
- if (sourceType == anInterface) {
- problemReporter().hierarchyCircularity(sourceType, superType, reference);
- sourceType.tagBits |= HierarchyHasProblems;
- superType.tagBits |= HierarchyHasProblems;
- return true;
- }
- hasCycle |= detectCycle(sourceType, anInterface, reference);
- if ((anInterface.tagBits & HierarchyHasProblems) != 0) {
- sourceType.tagBits |= HierarchyHasProblems;
- superType.tagBits |= HierarchyHasProblems;
- }
+ superType.tagBits |= HierarchyHasProblems;
}
}
- return hasCycle;
}
+ return hasCycle;
+ }
- if ((superType.tagBits & EndHierarchyCheck) == 0
- && (superType.tagBits & BeginHierarchyCheck) != 0) {
- problemReporter().hierarchyCircularity(sourceType, superType, reference);
- sourceType.tagBits |= HierarchyHasProblems;
- superType.tagBits |= HierarchyHasProblems;
- return true;
- }
- if ((superType.tagBits & BeginHierarchyCheck) == 0)
- // ensure if this is a source superclass that it has already been checked
- ((SourceTypeBinding) superType).scope.connectTypeHierarchyWithoutMembers();
- if ((superType.tagBits & HierarchyHasProblems) != 0)
- sourceType.tagBits |= HierarchyHasProblems;
- return false;
+ if ((superType.tagBits & EndHierarchyCheck) == 0 && (superType.tagBits & BeginHierarchyCheck) != 0) {
+ problemReporter().hierarchyCircularity(sourceType, superType, reference);
+ sourceType.tagBits |= HierarchyHasProblems;
+ superType.tagBits |= HierarchyHasProblems;
+ return true;
}
-
- private ReferenceBinding findSupertype(TypeReference typeReference) {
- typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
- char[][] compoundName = typeReference.getTypeName();
- SourceTypeBinding sourceType = referenceContext.binding;
- int size = compoundName.length;
- int n = 1;
- ReferenceBinding superType;
-
- // resolve the first name of the compoundName
- if (CharOperation.equals(compoundName[0], sourceType.sourceName)) {
- superType = sourceType;
- // match against the sourceType even though nested members cannot be supertypes
- } else {
- Binding typeOrPackage = parent.getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
- if (typeOrPackage == null || !typeOrPackage.isValidBinding()) {
- compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(compoundName[0], NotFound));
- // record package ref
+ if ((superType.tagBits & BeginHierarchyCheck) == 0)
+ // ensure if this is a source superclass that it has already been checked
+ ((SourceTypeBinding) superType).scope.connectTypeHierarchyWithoutMembers();
+ if ((superType.tagBits & HierarchyHasProblems) != 0)
+ sourceType.tagBits |= HierarchyHasProblems;
+ return false;
+}
+private ReferenceBinding findSupertype(TypeReference typeReference) {
+ typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
+ char[][] compoundName = typeReference.getTypeName();
+ SourceTypeBinding sourceType = referenceContext.binding;
+ int size = compoundName.length;
+ int n = 1;
+ ReferenceBinding superType;
+
+ // resolve the first name of the compoundName
+ if (CharOperation.equals(compoundName[0], sourceType.sourceName)) {
+ superType = sourceType; // match against the sourceType even though nested members cannot be supertypes
+ } else {
+ Binding typeOrPackage = parent.getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
+ if (typeOrPackage == null || !typeOrPackage.isValidBinding()){
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(compoundName[0], NotFound)); // record package ref
+ return new ProblemReferenceBinding(compoundName[0], typeOrPackage == null ? NotFound : typeOrPackage.problemId());
+ }
+ boolean checkVisibility = false;
+ for (; n < size; n++) {
+ if (!(typeOrPackage instanceof PackageBinding)) break;
+
+ PackageBinding packageBinding = (PackageBinding) typeOrPackage;
+ compilationUnitScope().addNamespaceReference(packageBinding);
+ typeOrPackage = packageBinding.getTypeOrPackage(compoundName[n]);
+ if (typeOrPackage == null || !typeOrPackage.isValidBinding())
return new ProblemReferenceBinding(
- compoundName[0],
+ CharOperation.subarray(compoundName, 0, n + 1),
typeOrPackage == null ? NotFound : typeOrPackage.problemId());
- }
- boolean checkVisibility = false;
- for (; n < size; n++) {
- if (!(typeOrPackage instanceof PackageBinding))
- break;
-
- PackageBinding packageBinding = (PackageBinding) typeOrPackage;
- compilationUnitScope().addNamespaceReference(packageBinding);
- typeOrPackage = packageBinding.getTypeOrPackage(compoundName[n]);
- if (typeOrPackage == null || !typeOrPackage.isValidBinding())
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, n + 1),
- typeOrPackage == null ? NotFound : typeOrPackage.problemId());
- checkVisibility = true;
- }
-
- // convert to a ReferenceBinding
- if (typeOrPackage instanceof PackageBinding) // error, the compoundName is a packageName
- return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
- superType = (ReferenceBinding) typeOrPackage;
- compilationUnitScope().addTypeReference(superType);
+ checkVisibility = true;
+ }
- if (checkVisibility
- && n == size) { // if we're finished and know the final supertype then check visibility
- if (!superType.canBeSeenBy(sourceType.fPackage))
- // its a toplevel type so just check package access
+ // convert to a ReferenceBinding
+ if (typeOrPackage instanceof PackageBinding) // error, the compoundName is a packageName
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
+ superType = (ReferenceBinding) typeOrPackage;
+ compilationUnitScope().addTypeReference(superType);
+
+ if (checkVisibility && n == size) { // if we're finished and know the final superinterface then check visibility
+ SourceTypeBinding enclosingSourceType = enclosingSourceType();
+ if (enclosingSourceType == null
+ ? !superType.canBeSeenBy(sourceType.fPackage)
+ : !superType.canBeSeenBy(sourceType, enclosingSourceType))
return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotVisible);
- }
}
- // at this point we know we have a type but we have to look for cycles
- while (true) {
- // must detect cycles & force connection up the hierarchy... also handle cycles with binary types.
- // must be guaranteed that the superType knows its entire hierarchy
- if (detectCycle(sourceType, superType, typeReference))
- return null; // cycle error was already reported
-
- if (n >= size)
- break;
-
- // retrieve the next member type
- char[] typeName = compoundName[n++];
- superType = findMemberType(typeName, superType);
- if (superType == null)
- return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
- if (!superType.isValidBinding()) {
- superType.compoundName = CharOperation.subarray(compoundName, 0, n);
- return superType;
- }
- }
- return superType;
}
- /* Answer the problem reporter to use for raising new problems.
- *
- * Note that as a side-effect, this updates the current reference context
- * (unit, type or method) in case the problem handler decides it is necessary
- * to abort.
- */
- public ProblemReporter problemReporter() {
- MethodScope outerMethodScope;
- if ((outerMethodScope = outerMostMethodScope()) == null) {
- ProblemReporter problemReporter = referenceCompilationUnit().problemReporter;
- problemReporter.referenceContext = referenceContext;
- return problemReporter;
- } else {
- return outerMethodScope.problemReporter();
+ // at this point we know we have a type but we have to look for cycles
+ while (true) {
+ // must detect cycles & force connection up the hierarchy... also handle cycles with binary types.
+ // must be guaranteed that the superType knows its entire hierarchy
+ if (detectCycle(sourceType, superType, typeReference))
+ return null; // cycle error was already reported
+
+ if (n >= size)
+ break;
+
+ // retrieve the next member type
+ char[] typeName = compoundName[n++];
+ superType = findMemberType(typeName, superType);
+ if (superType == null)
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
+ if (!superType.isValidBinding()) {
+ superType.compoundName = CharOperation.subarray(compoundName, 0, n);
+ return superType;
}
}
-
- /* Answer the reference type of this scope.
- *
- * i.e. the nearest enclosing type of this scope.
- */
- public TypeDeclaration referenceType() {
- return referenceContext;
- }
-
- public String toString() {
- if (referenceContext != null)
- return "--- Class Scope ---\n\n" //$NON-NLS-1$
- +referenceContext.binding.toString();
- else
- return "--- Class Scope ---\n\n Binding not initialized" ; //$NON-NLS-1$
+ return superType;
+}
+/* Answer the problem reporter to use for raising new problems.
+*
+* Note that as a side-effect, this updates the current reference context
+* (unit, type or method) in case the problem handler decides it is necessary
+* to abort.
+*/
+
+public ProblemReporter problemReporter() {
+ MethodScope outerMethodScope;
+ if ((outerMethodScope = outerMostMethodScope()) == null) {
+ ProblemReporter problemReporter = referenceCompilationUnit().problemReporter;
+ problemReporter.referenceContext = referenceContext;
+ return problemReporter;
+ } else {
+ return outerMethodScope.problemReporter();
}
-} \ No newline at end of file
+}
+/* Answer the reference type of this scope.
+*
+* i.e. the nearest enclosing type of this scope.
+*/
+
+public TypeDeclaration referenceType() {
+ return referenceContext;
+}
+public String toString() {
+ if (referenceContext != null)
+ return "--- Class Scope ---\n\n"/*nonNLS*/ + referenceContext.binding.toString();
+ else
+ return "--- Class Scope ---\n\n Binding not initialized"/*nonNLS*/;
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index 230c76a9ec..043fd7e82e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -427,7 +427,7 @@ public void storeDependencyInfo() {
referenceContext.compilationResult.fileDependencies = fileNames;
}
public String toString() {
- return "--- CompilationUnit Scope : " + new String(referenceContext.getFileName()); //$NON-NLS-1$
+ return "--- CompilationUnit Scope : "/*nonNLS*/ + new String(referenceContext.getFileName());
}
public void verifyMethods(MethodVerifier verifier) {
for (int i = 0, length = topLevelTypes.length; i < length; i++)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
index badea8752d..1445d91ef9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
@@ -25,11 +25,11 @@ public final int bindingType() {
}
public char[] readableName() {
if (onDemand)
- return CharOperation.concat(CharOperation.concatWith(compoundName, '.'), ".*".toCharArray()); //$NON-NLS-1$
+ return CharOperation.concat(CharOperation.concatWith(compoundName, '.'), ".*"/*nonNLS*/.toCharArray());
else
return CharOperation.concatWith(compoundName, '.');
}
public String toString() {
- return "import : " + new String(readableName()); //$NON-NLS-1$
+ return "import : "/*nonNLS*/ + new String(readableName());
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
index 4fb1dca061..d2de2d1416 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
@@ -56,9 +56,9 @@ public void constantPoolName(char[] computedConstantPoolName) /* java/lang/Objec
public char[] readableName() {
if (isAnonymousType()) {
if (superInterfaces == NoSuperInterfaces)
- return ("<"+Util.bind("binding.subclass",new String(superclass.readableName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ return ("<"/*nonNLS*/+Util.bind("binding.subclass"/*nonNLS*/,new String(superclass.readableName())) + ">"/*nonNLS*/).toCharArray();
else
- return ("<"+Util.bind("binding.implementation",new String(superInterfaces[0].readableName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ return ("<"/*nonNLS*/+Util.bind("binding.implementation"/*nonNLS*/,new String(superInterfaces[0].readableName())) + ">"/*nonNLS*/).toCharArray();
} else if (isMemberType()) {
return CharOperation.concat(enclosingType().readableName(), sourceName, '.');
} else {
@@ -78,10 +78,10 @@ public char[] sourceName() {
}
public String toString() {
if (isAnonymousType())
- return "Anonymous type : " + super.toString(); //$NON-NLS-1$
+ return "Anonymous type : "/*nonNLS*/ + super.toString();
if (isMemberType())
- return "Local member type : " + new String(sourceName()) + " " + super.toString(); //$NON-NLS-2$ //$NON-NLS-1$
- return "Local type : " + new String(sourceName()) + " " + super.toString(); //$NON-NLS-2$ //$NON-NLS-1$
+ return "Local member type : "/*nonNLS*/ + new String(sourceName()) + " "/*nonNLS*/ + super.toString();
+ return "Local type : "/*nonNLS*/ + new String(sourceName()) + " "/*nonNLS*/ + super.toString();
}
/* Trigger the dependency mechanism forcing the innerclass emulation
* to be propagated to all dependent source types.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
index 1e96370416..0b0591e9cd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
@@ -66,18 +66,18 @@ public void recordInitializationStartPC(int pc) {
public String toString() {
String s = super.toString();
if (!used)
- s += "[pos: unused]"; //$NON-NLS-1$
+ s += "[pos: unused]"/*nonNLS*/;
else
- s += "[pos: " + String.valueOf(resolvedPosition) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
- s += "[id:" + String.valueOf(id) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += "[pos: "/*nonNLS*/ + String.valueOf(resolvedPosition) + "]"/*nonNLS*/;
+ s += "[id:"/*nonNLS*/ + String.valueOf(id) + "]"/*nonNLS*/;
if (initializationCount > 0) {
- s += "[pc: "; //$NON-NLS-1$
+ s += "[pc: "/*nonNLS*/;
for (int i = 0; i < initializationCount; i++) {
if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += String.valueOf(initializationPCs[i << 1]) + "-" + ((initializationPCs[(i << 1) + 1] == -1) ? "?" : String.valueOf(initializationPCs[(i<< 1) + 1])); //$NON-NLS-2$ //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
+ s += String.valueOf(initializationPCs[i << 1]) + "-"/*nonNLS*/ + ((initializationPCs[(i << 1) + 1] == -1) ? "?"/*nonNLS*/ : String.valueOf(initializationPCs[(i<< 1) + 1]));
}
- s += "]"; //$NON-NLS-1$
+ s += "]"/*nonNLS*/;
}
return s;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index a7b8128ee7..27b863af3a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -68,7 +68,7 @@ public ReferenceBinding askForType(char[][] compoundName) {
typeRequestor.accept(answer.getCompilationUnit());
else if (answer.isSourceType())
// the type was found as a source model
- typeRequestor.accept(answer.getSourceTypes(), computePackageFrom(compoundName));
+ typeRequestor.accept(answer.getSourceType(), computePackageFrom(compoundName));
return getCachedType(compoundName);
}
@@ -94,7 +94,7 @@ ReferenceBinding askForType(PackageBinding packageBinding, char[] name) {
typeRequestor.accept(answer.getCompilationUnit());
else if (answer.isSourceType())
// the type was found as a source model
- typeRequestor.accept(answer.getSourceTypes(), packageBinding);
+ typeRequestor.accept(answer.getSourceType(), packageBinding);
return packageBinding.getType0(name);
}
@@ -505,7 +505,7 @@ TypeBinding getTypeFromSignature(char[] signature, int start, int end) {
binding = ShortBinding;
break;
default :
- throw new Error(Util.bind("error.undefinedBaseType",String.valueOf(signature[start]))); //$NON-NLS-1$
+ throw new Error(Util.bind("error.undefinedBaseType"/*nonNLS*/,String.valueOf(signature[start])));
}
} else {
binding = getTypeFromConstantPoolName(signature, start + 1, end - 1);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
index e13f6888d9..8002aba526 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
@@ -28,6 +28,6 @@ public char[] constantPoolName() /* java/lang/Object */ {
return constantPoolName = CharOperation.concat(enclosingType().constantPoolName(), sourceName, '$');
}
public String toString() {
- return "Member type : " + new String(sourceName()) + " " + super.toString(); //$NON-NLS-2$ //$NON-NLS-1$
+ return "Member type : "/*nonNLS*/ + new String(sourceName()) + " "/*nonNLS*/ + super.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
index 7dfcb9ec9a..65b5ec8f87 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
@@ -309,7 +309,7 @@ public char[] readableName() /* foo(int, Thread) */ {
if (parameters != NoParameters) {
for (int i = 0, length = parameters.length; i < length; i++) {
if (i > 0)
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
buffer.append(parameters[i].sourceName());
}
}
@@ -387,35 +387,35 @@ public final void tagForClearingPrivateModifier() {
modifiers |= AccClearPrivateModifier;
}
public String toString() {
- String s = (returnType != null) ? returnType.debugName() : "NULL TYPE"; //$NON-NLS-1$
- s += " "; //$NON-NLS-1$
- s += (selector != null) ? new String(selector) : "UNNAMED METHOD"; //$NON-NLS-1$
+ String s = (returnType != null) ? returnType.debugName() : "NULL TYPE"/*nonNLS*/;
+ s += " "/*nonNLS*/;
+ s += (selector != null) ? new String(selector) : "UNNAMED METHOD"/*nonNLS*/;
- s += "("; //$NON-NLS-1$
+ s += "("/*nonNLS*/;
if (parameters != null) {
if (parameters != NoParameters) {
for (int i = 0, length = parameters.length; i < length; i++) {
if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += (parameters[i] != null) ? parameters[i].debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
+ s += (parameters[i] != null) ? parameters[i].debugName() : "NULL TYPE"/*nonNLS*/;
}
}
} else {
- s += "NULL PARAMETERS"; //$NON-NLS-1$
+ s += "NULL PARAMETERS"/*nonNLS*/;
}
- s += ") "; //$NON-NLS-1$
+ s += ") "/*nonNLS*/;
if (thrownExceptions != null) {
if (thrownExceptions != NoExceptions) {
- s += "throws "; //$NON-NLS-1$
+ s += "throws "/*nonNLS*/;
for (int i = 0, length = thrownExceptions.length; i < length; i++) {
if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += (thrownExceptions[i] != null) ? thrownExceptions[i].debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
+ s += (thrownExceptions[i] != null) ? thrownExceptions[i].debugName() : "NULL TYPE"/*nonNLS*/;
}
}
} else {
- s += "NULL THROWN EXCEPTIONS"; //$NON-NLS-1$
+ s += "NULL THROWN EXCEPTIONS"/*nonNLS*/;
}
return s;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
index 3bd2fdadbf..9c9f9df279 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
@@ -42,18 +42,18 @@ public MethodScope(ClassScope parent, ReferenceContext context, boolean isStatic
this.startIndex = 0;
}
String basicToString(int tab) {
- String newLine = "\n"; //$NON-NLS-1$
+ String newLine = "\n"/*nonNLS*/;
for (int i = tab; --i >= 0;)
- newLine += "\t"; //$NON-NLS-1$
+ newLine += "\t"/*nonNLS*/;
- String s = newLine + "--- Method Scope ---"; //$NON-NLS-1$
- newLine += "\t"; //$NON-NLS-1$
- s += newLine + "locals:"; //$NON-NLS-1$
+ String s = newLine + "--- Method Scope ---"/*nonNLS*/;
+ newLine += "\t"/*nonNLS*/;
+ s += newLine + "locals:"/*nonNLS*/;
for (int i = 0; i < localIndex; i++)
- s += newLine + "\t" + locals[i].toString(); //$NON-NLS-1$
- s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$
- s += newLine + "isConstructorCall = " + isConstructorCall; //$NON-NLS-1$
- s += newLine + "fieldDeclarationIndex = " + fieldDeclarationIndex; //$NON-NLS-1$
+ s += newLine + "\t"/*nonNLS*/ + locals[i].toString();
+ s += newLine + "startIndex = "/*nonNLS*/ + startIndex;
+ s += newLine + "isConstructorCall = "/*nonNLS*/ + isConstructorCall;
+ s += newLine + "fieldDeclarationIndex = "/*nonNLS*/ + fieldDeclarationIndex;
return s;
}
/* Spec : 8.4.3 & 9.4
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
index 54adb2deb8..a031167eb7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
@@ -190,8 +190,8 @@ public char[] readableName() /*java.lang*/ {
}
public String toString() {
if (compoundName == NoCharChar)
- return "The Default Package"; //$NON-NLS-1$
+ return "The Default Package"/*nonNLS*/;
else
- return "package " + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$
+ return "package "/*nonNLS*/ + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"/*nonNLS*/);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 1366b74f4d..9fffaeeb7f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -252,11 +252,6 @@ public void computeId() {
id = T_JavaLangVoid;
return;
}
-
- if (CharOperation.equals(JAVA_LANG_ASSERTIONERROR, compoundName)) {
- id = T_JavaLangAssertionError;
- return;
- }
}
/* Answer the receiver's constant pool name.
*
@@ -264,11 +259,13 @@ public void computeId() {
*/
public char[] constantPoolName() /* java/lang/Object */ {
- if (constantPoolName != null) return constantPoolName;
+ if (constantPoolName != null)
+ return constantPoolName;
+
return constantPoolName = CharOperation.concatWith(compoundName, '/');
}
String debugName() {
- return (compoundName != null) ? new String(readableName()) : "UNNAMED TYPE"; //$NON-NLS-1$
+ return (compoundName != null) ? new String(readableName()) : "UNNAMED TYPE"/*nonNLS*/;
}
public final int depth() {
int depth = 0;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index 4d11ced78d..aba6c98c2b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -9,16 +9,7 @@ import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
-public abstract class Scope
- implements
- BaseTypes,
- BindingIds,
- CompilerModifiers,
- ProblemReasons,
- TagBits,
- TypeConstants,
- TypeIds {
-
+public abstract class Scope implements BaseTypes, BindingIds, CompilerModifiers, ProblemReasons, TagBits, TypeConstants, TypeIds {
public Scope parent;
public int kind;
@@ -26,1194 +17,1048 @@ public abstract class Scope
public final static int METHOD_SCOPE = 2;
public final static int CLASS_SCOPE = 3;
public final static int COMPILATION_UNIT_SCOPE = 4;
- protected Scope(int kind, Scope parent) {
- this.kind = kind;
- this.parent = parent;
- }
-
- public abstract ProblemReporter problemReporter();
-
- // Internal use only
- protected final boolean areParametersAssignable(
- TypeBinding[] parameters,
- TypeBinding[] arguments) {
- if (parameters == arguments)
- return true;
-
- int length = parameters.length;
- if (length != arguments.length)
- return false;
-
- for (int i = 0; i < length; i++)
- if (parameters[i] != arguments[i])
- if (!arguments[i].isCompatibleWith(parameters[i]))
- return false;
+protected Scope(int kind, Scope parent) {
+ this.kind = kind;
+ this.parent = parent;
+}
+// Internal use only
+
+protected final boolean areParametersAssignable(TypeBinding[] parameters, TypeBinding[] arguments) {
+ if (parameters == arguments)
return true;
- }
- /* Answer true if the left type can be assigned to right
- */
- public boolean areTypesCompatible(TypeBinding left, TypeBinding right) {
- return left.isCompatibleWith(right);
- }
-
- /* Answer an int describing the relationship between the given types.
- *
- * NotRelated
- * EqualOrMoreSpecific : left is compatible with right
- * MoreGeneric : right is compatible with left
- */
- public int compareTypes(TypeBinding left, TypeBinding right) {
- if (areTypesCompatible(left, right))
- return EqualOrMoreSpecific;
- if (areTypesCompatible(right, left))
- return MoreGeneric;
- return NotRelated;
- }
-
- /* Answer an int describing the relationship between the given type and unchecked exceptions.
- *
- * NotRelated
- * EqualOrMoreSpecific : type is known for sure to be an unchecked exception type
- * MoreGeneric : type is a supertype of an actual unchecked exception type
- */
- public int compareUncheckedException(ReferenceBinding type) {
- int comparison = compareTypes(type, getJavaLangRuntimeException());
- if (comparison != 0)
- return comparison;
+ int length = parameters.length;
+ if (length != arguments.length)
+ return false;
+
+ for (int i = 0; i < length; i++)
+ if (parameters[i] != arguments[i])
+ if (!arguments[i].isCompatibleWith(parameters[i]))
+ return false;
+ return true;
+}
+/* Answer true if the left type can be assigned to right
+*/
+
+public boolean areTypesCompatible(TypeBinding left, TypeBinding right) {
+ return left.isCompatibleWith(right);
+}
+/* Answer an int describing the relationship between the given types.
+*
+* NotRelated
+* EqualOrMoreSpecific : left is compatible with right
+* MoreGeneric : right is compatible with left
+*/
+
+public int compareTypes(TypeBinding left, TypeBinding right) {
+ if (areTypesCompatible(left, right))
+ return EqualOrMoreSpecific;
+ if (areTypesCompatible(right, left))
+ return MoreGeneric;
+ return NotRelated;
+}
+/* Answer an int describing the relationship between the given type and unchecked exceptions.
+*
+* NotRelated
+* EqualOrMoreSpecific : type is known for sure to be an unchecked exception type
+* MoreGeneric : type is a supertype of an actual unchecked exception type
+*/
+
+public int compareUncheckedException(ReferenceBinding type) {
+ int comparison = compareTypes(type, getJavaLangRuntimeException());
+ if (comparison != 0)
+ return comparison;
+ else
+ return compareTypes(type, getJavaLangError());
+}
+public final CompilationUnitScope compilationUnitScope() {
+ Scope lastScope = null;
+ Scope scope = this;
+ do {
+ lastScope = scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return (CompilationUnitScope) lastScope;
+}
+public ArrayBinding createArray(TypeBinding type, int dimension) {
+ if (type.isValidBinding())
+ return environment().createArrayType(type, dimension);
+ else
+ return new ArrayBinding(type, dimension);
+}
+/* Answer the receiver's enclosing source type.
+*/
+
+public final SourceTypeBinding enclosingSourceType() {
+ Scope scope = this;
+ do {
+ if (scope instanceof ClassScope)
+ return ((ClassScope) scope).referenceContext.binding;
+ scope = scope.parent;
+ } while (scope != null);
+ return null;
+}
+public final LookupEnvironment environment() {
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+ return ((CompilationUnitScope) unitScope).environment;
+}
+// Internal use only
+
+public ReferenceBinding findDirectMemberType(char[] typeName, ReferenceBinding enclosingType) {
+ if ((enclosingType.tagBits & HasNoMemberTypes) != 0)
+ return null; // know it has no member types (nor inherited member types)
+
+ SourceTypeBinding enclosingSourceType = enclosingSourceType();
+ compilationUnitScope().addTypeReference(enclosingType);
+ ReferenceBinding memberType = enclosingType.getMemberType(typeName);
+ if (memberType != null) {
+ compilationUnitScope().addTypeReference(memberType);
+ if (enclosingSourceType == null
+ ? memberType.canBeSeenBy(getCurrentPackage())
+ : memberType.canBeSeenBy(enclosingType, enclosingSourceType))
+ return memberType;
else
- return compareTypes(type, getJavaLangError());
- }
-
- public final CompilationUnitScope compilationUnitScope() {
- Scope lastScope = null;
- Scope scope = this;
- do {
- lastScope = scope;
- scope = scope.parent;
- } while (scope != null);
- return (CompilationUnitScope) lastScope;
+ return new ProblemReferenceBinding(typeName, NotVisible);
}
-
- public ArrayBinding createArray(TypeBinding type, int dimension) {
- if (type.isValidBinding())
- return environment().createArrayType(type, dimension);
- else
- return new ArrayBinding(type, dimension);
+ return null;
+}
+// Internal use only
+
+public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
+ compilationUnitScope().addTypeReference(receiverType);
+ compilationUnitScope().addTypeReferences(argumentTypes);
+ MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes);
+ if (exactMethod != null){
+ compilationUnitScope().addTypeReferences(exactMethod.thrownExceptions);
+ if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this))
+ return exactMethod;
}
-
- /* Answer the receiver's enclosing source type.
- */
- public final SourceTypeBinding enclosingSourceType() {
- Scope scope = this;
- do {
- if (scope instanceof ClassScope)
- return ((ClassScope) scope).referenceContext.binding;
- scope = scope.parent;
- } while (scope != null);
+ return null;
+}
+// Internal use only
+
+/* Answer the field binding that corresponds to fieldName.
+ Start the lookup at the receiverType.
+ InvocationSite implements
+ isSuperAccess(); this is used to determine if the discovered field is visible.
+ Only fields defined by the receiverType or its supertypes are answered;
+ a field of an enclosing type will not be found using this API.
+
+ If no visible field is discovered, null is answered.
+*/
+
+public FieldBinding findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
+ if (receiverType.isBaseType())
return null;
- }
- public final LookupEnvironment environment() {
- Scope scope, unitScope = this;
- while ((scope = unitScope.parent) != null)
- unitScope = scope;
- return ((CompilationUnitScope) unitScope).environment;
- }
-
- // Internal use only
- public ReferenceBinding findDirectMemberType(
- char[] typeName,
- ReferenceBinding enclosingType) {
- if ((enclosingType.tagBits & HasNoMemberTypes) != 0)
- return null; // know it has no member types (nor inherited member types)
-
- SourceTypeBinding enclosingSourceType = enclosingSourceType();
- compilationUnitScope().addTypeReference(enclosingType);
- ReferenceBinding memberType = enclosingType.getMemberType(typeName);
- if (memberType != null) {
- compilationUnitScope().addTypeReference(memberType);
- if (enclosingSourceType == null
- ? memberType.canBeSeenBy(getCurrentPackage())
- : memberType.canBeSeenBy(enclosingType, enclosingSourceType))
- return memberType;
- else
- return new ProblemReferenceBinding(typeName, NotVisible);
- }
+ if (receiverType.isArrayType()) {
+ if (CharOperation.equals(fieldName, LENGTH))
+ return ArrayBinding.LengthField;
return null;
}
- // Internal use only
- public MethodBinding findExactMethod(
- ReferenceBinding receiverType,
- char[] selector,
- TypeBinding[] argumentTypes,
- InvocationSite invocationSite) {
- compilationUnitScope().addTypeReference(receiverType);
- compilationUnitScope().addTypeReferences(argumentTypes);
- MethodBinding exactMethod =
- receiverType.getExactMethod(selector, argumentTypes);
- if (exactMethod != null) {
- compilationUnitScope().addTypeReferences(exactMethod.thrownExceptions);
- if (receiverType.isInterface()
- || exactMethod.canBeSeenBy(receiverType, invocationSite, this))
- return exactMethod;
- }
- return null;
- }
+ ReferenceBinding currentType = (ReferenceBinding) receiverType;
+ if (!currentType.canBeSeenBy(this))
+ return new ProblemFieldBinding(fieldName, NotVisible); // *** Need a new problem id - TypeNotVisible?
- // Internal use only
- /* Answer the field binding that corresponds to fieldName.
- Start the lookup at the receiverType.
- InvocationSite implements
- isSuperAccess(); this is used to determine if the discovered field is visible.
- Only fields defined by the receiverType or its supertypes are answered;
- a field of an enclosing type will not be found using this API.
-
- If no visible field is discovered, null is answered.
- */
- public FieldBinding findField(
- TypeBinding receiverType,
- char[] fieldName,
- InvocationSite invocationSite) {
- if (receiverType.isBaseType())
- return null;
- if (receiverType.isArrayType()) {
- if (CharOperation.equals(fieldName, LENGTH))
- return ArrayBinding.LengthField;
- return null;
- }
- ReferenceBinding currentType = (ReferenceBinding) receiverType;
- if (!currentType.canBeSeenBy(this))
+ compilationUnitScope().addTypeReference(currentType);
+ FieldBinding field = currentType.getField(fieldName);
+ if (field != null) {
+ if (field.canBeSeenBy(currentType, invocationSite, this))
+ return field;
+ else
return new ProblemFieldBinding(fieldName, NotVisible);
- // *** Need a new problem id - TypeNotVisible?
+ }
- compilationUnitScope().addTypeReference(currentType);
- FieldBinding field = currentType.getField(fieldName);
- if (field != null) {
- if (field.canBeSeenBy(currentType, invocationSite, this))
- return field;
- else
- return new ProblemFieldBinding(fieldName, NotVisible);
+ // collect all superinterfaces of receiverType until the field is found in a supertype
+ ReferenceBinding[][] interfacesToVisit = null;
+ int lastPosition = -1;
+ FieldBinding visibleField = null;
+ boolean keepLooking = true;
+ boolean notVisible = false; // we could hold onto the not visible field for extra error reporting
+ while (keepLooking) {
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (interfacesToVisit == null)
+ interfacesToVisit = new ReferenceBinding[5][];
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
- // collect all superinterfaces of receiverType until the field is found in a supertype
- ReferenceBinding[][] interfacesToVisit = null;
- int lastPosition = -1;
- FieldBinding visibleField = null;
- boolean keepLooking = true;
- boolean notVisible = false;
- // we could hold onto the not visible field for extra error reporting
- while (keepLooking) {
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (interfacesToVisit == null)
- interfacesToVisit = new ReferenceBinding[5][];
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
- if ((currentType = currentType.superclass()) == null)
- break;
-
- if ((field = currentType.getField(fieldName)) != null) {
- keepLooking = false;
- if (field.canBeSeenBy(receiverType, invocationSite, this)) {
- if (visibleField == null)
- visibleField = field;
- else
- return new ProblemFieldBinding(fieldName, Ambiguous);
- } else {
- notVisible = true;
- }
+ if ((currentType = currentType.superclass()) == null)
+ break;
+
+ if ((field = currentType.getField(fieldName)) != null) {
+ keepLooking = false;
+ if (field.canBeSeenBy(receiverType, invocationSite, this)) {
+ if (visibleField == null)
+ visibleField = field;
+ else
+ return new ProblemFieldBinding(fieldName, Ambiguous);
+ } else {
+ notVisible = true;
}
}
- // walk all visible interfaces to find ambiguous references
- if (interfacesToVisit != null) {
- ProblemFieldBinding ambiguous = null;
- done : for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- ReferenceBinding anInterface = interfaces[j];
- if ((anInterface.tagBits & InterfaceVisited) == 0) {
- // if interface as not already been visited
- anInterface.tagBits |= InterfaceVisited;
- if ((field = anInterface.getField(fieldName)) != null) {
- if (visibleField == null) {
- visibleField = field;
- } else {
- ambiguous = new ProblemFieldBinding(fieldName, Ambiguous);
- break done;
- }
+ }
+
+ // walk all visible interfaces to find ambiguous references
+ if (interfacesToVisit != null) {
+ ProblemFieldBinding ambiguous = null;
+ done : for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding anInterface = interfaces[j];
+ if ((anInterface.tagBits & InterfaceVisited) == 0) { // if interface as not already been visited
+ anInterface.tagBits |= InterfaceVisited;
+ if ((field = anInterface.getField(fieldName)) != null) {
+ if (visibleField == null) {
+ visibleField = field;
} else {
- ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+ ambiguous = new ProblemFieldBinding(fieldName, Ambiguous);
+ break done;
+ }
+ } else {
+ ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
}
- // bit reinitialization
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++)
- interfaces[j].tagBits &= ~InterfaceVisited;
- }
- if (ambiguous != null)
- return ambiguous;
}
- if (visibleField != null)
- return visibleField;
- if (notVisible)
- return new ProblemFieldBinding(fieldName, NotVisible);
- return null;
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ interfaces[j].tagBits &= ~InterfaceVisited;
+ }
+ if (ambiguous != null) return ambiguous;
}
- // Internal use only
- public ReferenceBinding findMemberType(
- char[] typeName,
- ReferenceBinding enclosingType) {
- if ((enclosingType.tagBits & HasNoMemberTypes) != 0)
- return null; // know it has no member types (nor inherited member types)
-
- SourceTypeBinding enclosingSourceType = enclosingSourceType();
- PackageBinding currentPackage = getCurrentPackage();
- compilationUnitScope().addTypeReference(enclosingType);
- ReferenceBinding memberType = enclosingType.getMemberType(typeName);
- if (memberType != null) {
- compilationUnitScope().addTypeReference(memberType);
- if (enclosingSourceType == null
- ? memberType.canBeSeenBy(currentPackage)
- : memberType.canBeSeenBy(enclosingType, enclosingSourceType))
+ if (visibleField != null)
+ return visibleField;
+ if (notVisible)
+ return new ProblemFieldBinding(fieldName, NotVisible);
+ return null;
+}
+// Internal use only
+
+public ReferenceBinding findMemberType(char[] typeName, ReferenceBinding enclosingType) {
+ if ((enclosingType.tagBits & HasNoMemberTypes) != 0)
+ return null; // know it has no member types (nor inherited member types)
+
+ SourceTypeBinding enclosingSourceType = enclosingSourceType();
+ PackageBinding currentPackage = getCurrentPackage();
+ compilationUnitScope().addTypeReference(enclosingType);
+ ReferenceBinding memberType = enclosingType.getMemberType(typeName);
+ if (memberType != null) {
+ compilationUnitScope().addTypeReference(memberType);
+ if (enclosingSourceType == null
+ ? memberType.canBeSeenBy(currentPackage)
+ : memberType.canBeSeenBy(enclosingType, enclosingSourceType))
return memberType;
- else
+ else
return new ProblemReferenceBinding(typeName, NotVisible);
+ }
+
+ // collect all superinterfaces of receiverType until the memberType is found in a supertype
+ ReferenceBinding currentType = enclosingType;
+ ReferenceBinding[][] interfacesToVisit = null;
+ int lastPosition = -1;
+ ReferenceBinding visibleMemberType = null;
+ boolean keepLooking = true;
+ boolean notVisible = false; // we could hold onto the not visible field for extra error reporting
+ while (keepLooking) {
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (interfacesToVisit == null)
+ interfacesToVisit = new ReferenceBinding[5][];
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
- // collect all superinterfaces of receiverType until the memberType is found in a supertype
- ReferenceBinding currentType = enclosingType;
- ReferenceBinding[][] interfacesToVisit = null;
- int lastPosition = -1;
- ReferenceBinding visibleMemberType = null;
- boolean keepLooking = true;
- boolean notVisible = false;
- // we could hold onto the not visible field for extra error reporting
- while (keepLooking) {
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (interfacesToVisit == null)
- interfacesToVisit = new ReferenceBinding[5][];
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
- if ((currentType = currentType.superclass()) == null)
- break;
+ if ((currentType = currentType.superclass()) == null)
+ break;
- compilationUnitScope().addTypeReference(currentType);
- if ((memberType = currentType.getMemberType(typeName)) != null) {
- compilationUnitScope().addTypeReference(memberType);
- keepLooking = false;
- if (enclosingSourceType == null
- ? memberType.canBeSeenBy(currentPackage)
- : memberType.canBeSeenBy(enclosingType, enclosingSourceType)) {
+ compilationUnitScope().addTypeReference(currentType);
+ if ((memberType = currentType.getMemberType(typeName)) != null) {
+ compilationUnitScope().addTypeReference(memberType);
+ keepLooking = false;
+ if (enclosingSourceType == null
+ ? memberType.canBeSeenBy(currentPackage)
+ : memberType.canBeSeenBy(enclosingType, enclosingSourceType)) {
if (visibleMemberType == null)
visibleMemberType = memberType;
else
return new ProblemReferenceBinding(typeName, Ambiguous);
- } else {
- notVisible = true;
- }
+ } else {
+ notVisible = true;
}
}
- // walk all visible interfaces to find ambiguous references
- if (interfacesToVisit != null) {
- ProblemReferenceBinding ambiguous = null;
- done : for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- ReferenceBinding anInterface = interfaces[j];
- if ((anInterface.tagBits & InterfaceVisited) == 0) {
- // if interface as not already been visited
- anInterface.tagBits |= InterfaceVisited;
- compilationUnitScope().addTypeReference(anInterface);
- if ((memberType = anInterface.getMemberType(typeName)) != null) {
- compilationUnitScope().addTypeReference(memberType);
- if (visibleMemberType == null) {
- visibleMemberType = memberType;
- } else {
- ambiguous = new ProblemReferenceBinding(typeName, Ambiguous);
- break done;
- }
+ }
+
+ // walk all visible interfaces to find ambiguous references
+ if (interfacesToVisit != null) {
+ ProblemReferenceBinding ambiguous = null;
+ done : for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding anInterface = interfaces[j];
+ if ((anInterface.tagBits & InterfaceVisited) == 0) { // if interface as not already been visited
+ anInterface.tagBits |= InterfaceVisited;
+ compilationUnitScope().addTypeReference(anInterface);
+ if ((memberType = anInterface.getMemberType(typeName)) != null) {
+ compilationUnitScope().addTypeReference(memberType);
+ if (visibleMemberType == null) {
+ visibleMemberType = memberType;
} else {
- ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
- }
+ ambiguous = new ProblemReferenceBinding(typeName, Ambiguous);
+ break done;
+ }
+ } else {
+ ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
}
- // bit reinitialization
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++)
- interfaces[j].tagBits &= ~InterfaceVisited;
- }
- if (ambiguous != null)
- return ambiguous;
}
- if (visibleMemberType != null)
- return visibleMemberType;
- if (notVisible)
- return new ProblemReferenceBinding(typeName, NotVisible);
- return null;
+
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ interfaces[j].tagBits &= ~InterfaceVisited;
+ }
+ if (ambiguous != null) return ambiguous;
}
- // Internal use only
- public MethodBinding findMethod(
- ReferenceBinding receiverType,
- char[] selector,
- TypeBinding[] argumentTypes,
- InvocationSite invocationSite) {
- ReferenceBinding currentType = receiverType;
- MethodBinding matchingMethod = null;
- ObjectVector found = null;
+ if (visibleMemberType != null)
+ return visibleMemberType;
+ if (notVisible)
+ return new ProblemReferenceBinding(typeName, NotVisible);
+ return null;
+}
+// Internal use only
+
+public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
+ ReferenceBinding currentType = receiverType;
+ MethodBinding matchingMethod = null;
+ ObjectVector found = null;
+
+ compilationUnitScope().addTypeReference(currentType);
+ compilationUnitScope().addTypeReferences(argumentTypes);
+ if (currentType.isInterface()) {
+ MethodBinding[] currentMethods = currentType.getMethods(selector);
+ int currentLength = currentMethods.length;
+ if (currentLength == 1) {
+ matchingMethod = currentMethods[0];
+ } else if (currentLength > 1) {
+ found = new ObjectVector();
+ for (int f = 0; f < currentLength; f++)
+ found.add(currentMethods[f]);
+ }
- compilationUnitScope().addTypeReference(currentType);
- compilationUnitScope().addTypeReferences(argumentTypes);
- if (currentType.isInterface()) {
- MethodBinding[] currentMethods = currentType.getMethods(selector);
- int currentLength = currentMethods.length;
- if (currentLength == 1) {
- matchingMethod = currentMethods[0];
- } else if (currentLength > 1) {
- found = new ObjectVector();
- for (int f = 0; f < currentLength; f++)
- found.add(currentMethods[f]);
- }
- ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
- int lastPosition = -1;
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
-
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++) {
- currentType = interfaces[j];
- if ((currentType.tagBits & InterfaceVisited) == 0) {
- // if interface as not already been visited
- currentType.tagBits |= InterfaceVisited;
-
- currentMethods = currentType.getMethods(selector);
- if ((currentLength = currentMethods.length) == 1
- && matchingMethod == null
- && found == null) {
- matchingMethod = currentMethods[0];
- } else if (currentLength > 0) {
- if (found == null) {
- found = new ObjectVector();
- if (matchingMethod != null)
- found.add(matchingMethod);
- }
- for (int f = 0; f < currentLength; f++)
- found.add(currentMethods[f]);
- }
- itsInterfaces = currentType.superInterfaces();
- if (itsInterfaces != NoSuperInterfaces) {
- if (++lastPosition == interfacesToVisit.length)
- System.arraycopy(
- interfacesToVisit,
- 0,
- interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
- 0,
- lastPosition);
- interfacesToVisit[lastPosition] = itsInterfaces;
+ ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
+ int lastPosition = -1;
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
+
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ currentType = interfaces[j];
+ if ((currentType.tagBits & InterfaceVisited) == 0) { // if interface as not already been visited
+ currentType.tagBits |= InterfaceVisited;
+
+ currentMethods = currentType.getMethods(selector);
+ if ((currentLength = currentMethods.length) == 1 && matchingMethod == null && found == null) {
+ matchingMethod = currentMethods[0];
+ } else if (currentLength > 0) {
+ if (found == null) {
+ found = new ObjectVector();
+ if (matchingMethod != null)
+ found.add(matchingMethod);
}
+ for (int f = 0; f < currentLength; f++)
+ found.add(currentMethods[f]);
+ }
+
+ itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
}
}
- // bit reinitialization
- for (int i = 0; i <= lastPosition; i++) {
- ReferenceBinding[] interfaces = interfacesToVisit[i];
- for (int j = 0, length = interfaces.length; j < length; j++)
- interfaces[j].tagBits &= ~InterfaceVisited;
- }
- }
- currentType =
- (matchingMethod == null && found == null) ? getJavaLangObject() : null;
- }
- while (currentType != null) {
- MethodBinding[] currentMethods = currentType.getMethods(selector);
- int currentLength = currentMethods.length;
- if (currentLength == 1 && matchingMethod == null && found == null) {
- matchingMethod = currentMethods[0];
- } else if (currentLength > 0) {
- if (found == null) {
- found = new ObjectVector();
- if (matchingMethod != null)
- found.add(matchingMethod);
- }
- for (int f = 0; f < currentLength; f++)
- found.add(currentMethods[f]);
}
- currentType = currentType.superclass();
- }
-
- if (found == null)
- return matchingMethod;
- // may be null - have not checked arg types or visibility
-
- int foundSize = found.size;
- MethodBinding[] compatible = new MethodBinding[foundSize];
- int compatibleIndex = 0;
- for (int i = 0; i < foundSize; i++) {
- MethodBinding methodBinding = (MethodBinding) found.elementAt(i);
- if (areParametersAssignable(methodBinding.parameters, argumentTypes))
- compatible[compatibleIndex++] = methodBinding;
- }
- if (compatibleIndex == 1)
- return compatible[0]; // have not checked visibility
- if (compatibleIndex == 0)
- return (MethodBinding) found.elementAt(0);
- // no good match so just use the first one found
-
- MethodBinding[] visible = new MethodBinding[compatibleIndex];
- int visibleIndex = 0;
- for (int i = 0; i < compatibleIndex; i++) {
- MethodBinding methodBinding = compatible[i];
- if (methodBinding.canBeSeenBy(receiverType, invocationSite, this))
- visible[visibleIndex++] = methodBinding;
- }
- if (visibleIndex == 1) {
- compilationUnitScope().addTypeReferences(visible[0].thrownExceptions);
- return visible[0];
- }
- if (visibleIndex == 0)
- return new ProblemMethodBinding(
- compatible[0].selector,
- argumentTypes,
- compatible[0].declaringClass,
- NotVisible);
- if (visible[0].declaringClass.isClass())
- return mostSpecificClassMethodBinding(visible, visibleIndex);
- else
- return mostSpecificInterfaceMethodBinding(visible, visibleIndex);
- }
-
- // Internal use only
- public MethodBinding findMethodForArray(
- ArrayBinding receiverType,
- char[] selector,
- TypeBinding[] argumentTypes,
- InvocationSite invocationSite) {
- ReferenceBinding object = getJavaLangObject();
- MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes);
- if (methodBinding != null) {
- // handle the method clone() specially... cannot be protected or throw exceptions
- if (argumentTypes == NoParameters && CharOperation.equals(selector, CLONE))
- return new MethodBinding(
- (methodBinding.modifiers ^ AccProtected) | AccPublic,
- CLONE,
- methodBinding.returnType,
- argumentTypes,
- null,
- object);
- if (methodBinding.canBeSeenBy(receiverType, invocationSite, this))
- return methodBinding;
- }
- // answers closest approximation, may not check argumentTypes or visibility
- methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
- if (methodBinding == null)
- return new ProblemMethodBinding(selector, argumentTypes, NotFound);
- if (methodBinding.isValidBinding()) {
- if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
- return new ProblemMethodBinding(
- methodBinding,
- selector,
- argumentTypes,
- NotFound);
- if (!methodBinding.canBeSeenBy(receiverType, invocationSite, this))
- return new ProblemMethodBinding(
- selector,
- argumentTypes,
- methodBinding.declaringClass,
- NotVisible);
- }
- return methodBinding;
- }
- // Internal use only
- public ReferenceBinding findType(
- char[] typeName,
- PackageBinding declarationPackage,
- PackageBinding invocationPackage) {
- compilationUnitScope().addNamespaceReference(declarationPackage);
- ReferenceBinding typeBinding = declarationPackage.getType(typeName);
- if (typeBinding == null)
- return null;
-
- if (typeBinding.isValidBinding()) {
- compilationUnitScope().addTypeReference(typeBinding);
- if (declarationPackage != invocationPackage
- && !typeBinding.canBeSeenBy(invocationPackage))
- return new ProblemReferenceBinding(typeName, NotVisible);
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ interfaces[j].tagBits &= ~InterfaceVisited;
+ }
}
- return typeBinding;
+ currentType = (matchingMethod == null && found == null) ? getJavaLangObject() : null;
}
- public TypeBinding getBaseType(char[] name) {
- // list should be optimized (with most often used first)
- int length = name.length;
- if (length > 2 && length < 8) {
- switch (name[0]) {
- case 'i' :
- if (length == 3 && name[1] == 'n' && name[2] == 't')
- return IntBinding;
- break;
- case 'v' :
- if (length == 4 && name[1] == 'o' && name[2] == 'i' && name[3] == 'd')
- return VoidBinding;
- break;
- case 'b' :
- if (length == 7
- && name[1] == 'o'
- && name[2] == 'o'
- && name[3] == 'l'
- && name[4] == 'e'
- && name[5] == 'a'
- && name[6] == 'n')
- return BooleanBinding;
- if (length == 4 && name[1] == 'y' && name[2] == 't' && name[3] == 'e')
- return ByteBinding;
- break;
- case 'c' :
- if (length == 4 && name[1] == 'h' && name[2] == 'a' && name[3] == 'r')
- return CharBinding;
- break;
- case 'd' :
- if (length == 6
- && name[1] == 'o'
- && name[2] == 'u'
- && name[3] == 'b'
- && name[4] == 'l'
- && name[5] == 'e')
- return DoubleBinding;
- break;
- case 'f' :
- if (length == 5
- && name[1] == 'l'
- && name[2] == 'o'
- && name[3] == 'a'
- && name[4] == 't')
- return FloatBinding;
- break;
- case 'l' :
- if (length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g')
- return LongBinding;
- break;
- case 's' :
- if (length == 5
- && name[1] == 'h'
- && name[2] == 'o'
- && name[3] == 'r'
- && name[4] == 't')
- return ShortBinding;
+ while (currentType != null) {
+ MethodBinding[] currentMethods = currentType.getMethods(selector);
+ int currentLength = currentMethods.length;
+ if (currentLength == 1 && matchingMethod == null && found == null) {
+ matchingMethod = currentMethods[0];
+ } else if (currentLength > 0) {
+ if (found == null) {
+ found = new ObjectVector();
+ if (matchingMethod != null)
+ found.add(matchingMethod);
}
+ for (int f = 0; f < currentLength; f++)
+ found.add(currentMethods[f]);
}
- return null;
+ currentType = currentType.superclass();
}
- public final PackageBinding getCurrentPackage() {
- Scope scope, unitScope = this;
- while ((scope = unitScope.parent) != null)
- unitScope = scope;
- return ((CompilationUnitScope) unitScope).fPackage;
- }
+ if (found == null)
+ return matchingMethod; // may be null - have not checked arg types or visibility
- public final ReferenceBinding getJavaIoSerializable() {
- ReferenceBinding type = environment().getType(JAVA_IO_SERIALIZABLE);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_IO, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_IO_SERIALIZABLE,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ int foundSize = found.size;
+ MethodBinding[] compatible = new MethodBinding[foundSize];
+ int compatibleIndex = 0;
+ for (int i = 0; i < foundSize; i++) {
+ MethodBinding methodBinding = (MethodBinding) found.elementAt(i);
+ if (areParametersAssignable(methodBinding.parameters, argumentTypes))
+ compatible[compatibleIndex++] = methodBinding;
}
-
- public final ReferenceBinding getJavaLangClass() {
- ReferenceBinding type = environment().getType(JAVA_LANG_CLASS);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_CLASS,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ if (compatibleIndex == 1)
+ return compatible[0]; // have not checked visibility
+ if (compatibleIndex == 0)
+ return (MethodBinding) found.elementAt(0); // no good match so just use the first one found
+
+ MethodBinding[] visible = new MethodBinding[compatibleIndex];
+ int visibleIndex = 0;
+ for (int i = 0; i < compatibleIndex; i++) {
+ MethodBinding methodBinding = compatible[i];
+ if (methodBinding.canBeSeenBy(receiverType, invocationSite, this))
+ visible[visibleIndex++] = methodBinding;
}
-
- public final ReferenceBinding getJavaLangCloneable() {
- ReferenceBinding type = environment().getType(JAVA_LANG_CLONEABLE);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_CLONEABLE,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ if (visibleIndex == 1){
+ compilationUnitScope().addTypeReferences(visible[0].thrownExceptions);
+ return visible[0];
}
-
- public final ReferenceBinding getJavaLangError() {
- ReferenceBinding type = environment().getType(JAVA_LANG_ERROR);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_ERROR,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ if (visibleIndex == 0)
+ return new ProblemMethodBinding(compatible[0].selector, argumentTypes, compatible[0].declaringClass, NotVisible);
+ if (visible[0].declaringClass.isClass())
+ return mostSpecificClassMethodBinding(visible, visibleIndex);
+ else
+ return mostSpecificInterfaceMethodBinding(visible, visibleIndex);
+}
+// Internal use only
+
+public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
+ ReferenceBinding object = getJavaLangObject();
+ MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes);
+ if (methodBinding != null) {
+ // handle the method clone() specially... cannot be protected or throw exceptions
+ if (argumentTypes == NoParameters && CharOperation.equals(selector, CLONE))
+ return new MethodBinding((methodBinding.modifiers ^ AccProtected) | AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object);
+ if (methodBinding.canBeSeenBy(receiverType, invocationSite, this))
+ return methodBinding;
}
- public final ReferenceBinding getJavaLangAssertionError() {
- ReferenceBinding type = environment().getType(JAVA_LANG_ASSERTIONERROR);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_ASSERTIONERROR,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ // answers closest approximation, may not check argumentTypes or visibility
+ methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
+ if (methodBinding == null)
+ return new ProblemMethodBinding(selector, argumentTypes, NotFound);
+ if (methodBinding.isValidBinding()) {
+ if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
+ return new ProblemMethodBinding(methodBinding, selector, argumentTypes, NotFound);
+ if (!methodBinding.canBeSeenBy(receiverType, invocationSite, this))
+ return new ProblemMethodBinding(selector, argumentTypes, methodBinding.declaringClass, NotVisible);
}
+ return methodBinding;
+}
+// Internal use only
- public final ReferenceBinding getJavaLangObject() {
- ReferenceBinding type = environment().getType(JAVA_LANG_OBJECT);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_OBJECT,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
- }
+public ReferenceBinding findType(char[] typeName, PackageBinding declarationPackage, PackageBinding invocationPackage) {
+ compilationUnitScope().addNamespaceReference(declarationPackage);
+ ReferenceBinding typeBinding = declarationPackage.getType(typeName);
+ if (typeBinding == null) return null;
- public final ReferenceBinding getJavaLangRuntimeException() {
- ReferenceBinding type = environment().getType(JAVA_LANG_RUNTIMEEXCEPTION);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- // record extra reference to pkg
- problemReporter().isClassPathCorrect(
- JAVA_LANG_RUNTIMEEXCEPTION,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ if (typeBinding.isValidBinding()) {
+ compilationUnitScope().addTypeReference(typeBinding);
+ if (declarationPackage != invocationPackage && !typeBinding.canBeSeenBy(invocationPackage))
+ return new ProblemReferenceBinding(typeName, NotVisible);
}
-
- public final ReferenceBinding getJavaLangString() {
- ReferenceBinding type = environment().getType(JAVA_LANG_STRING);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- problemReporter().isClassPathCorrect(
- JAVA_LANG_STRING,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ return typeBinding;
+}
+public TypeBinding getBaseType(char[] name) {
+ // list should be optimized (with most often used first)
+ int length = name.length;
+ if (length > 2 && length < 8) {
+ switch (name[0]) {
+ case 'i':
+ if (length == 3 &&
+ name[1] == 'n' &&
+ name[2] == 't')
+ return IntBinding;
+ break;
+ case 'v':
+ if (length == 4 &&
+ name[1] == 'o' &&
+ name[2] == 'i' &&
+ name[3] == 'd')
+ return VoidBinding;
+ break;
+
+ case 'b':
+ if (length == 7 &&
+ name[1] == 'o' &&
+ name[2] == 'o' &&
+ name[3] == 'l' &&
+ name[4] == 'e' &&
+ name[5] == 'a' &&
+ name[6] == 'n')
+ return BooleanBinding;
+ if (length == 4 &&
+ name[1] == 'y' &&
+ name[2] == 't' &&
+ name[3] == 'e')
+ return ByteBinding;
+ break;
+ case 'c':
+ if (length == 4 &&
+ name[1] == 'h' &&
+ name[2] == 'a' &&
+ name[3] == 'r')
+ return CharBinding;
+ break;
+ case 'd':
+ if (length == 6 &&
+ name[1] == 'o' &&
+ name[2] == 'u' &&
+ name[3] == 'b' &&
+ name[4] == 'l' &&
+ name[5] == 'e')
+ return DoubleBinding;
+ break;
+ case 'f':
+ if (length == 5 &&
+ name[1] == 'l' &&
+ name[2] == 'o' &&
+ name[3] == 'a' &&
+ name[4] == 't')
+ return FloatBinding;
+ break;
+ case 'l':
+ if (length == 4 &&
+ name[1] == 'o' &&
+ name[2] == 'n' &&
+ name[3] == 'g')
+ return LongBinding;
+ break;
+ case 's':
+ if (length == 5 &&
+ name[1] == 'h' &&
+ name[2] == 'o' &&
+ name[3] == 'r' &&
+ name[4] == 't')
+ return ShortBinding;
+ }
}
-
- public final ReferenceBinding getJavaLangThrowable() {
- ReferenceBinding type = environment().getType(JAVA_LANG_THROWABLE);
- if (type != null)
- return type;
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(JAVA_LANG, NotFound));
- problemReporter().isClassPathCorrect(
- JAVA_LANG_THROWABLE,
- referenceCompilationUnit());
- return null; // will not get here since the above error aborts the compilation
+ return null;
+}
+public final PackageBinding getCurrentPackage() {
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+ return ((CompilationUnitScope) unitScope).fPackage;
+}
+public final ReferenceBinding getJavaIoSerializable() {
+ ReferenceBinding type = environment().getType(JAVA_IO_SERIALIZABLE);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_IO, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_IO_SERIALIZABLE, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangClass() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_CLASS);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_LANG, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_LANG_CLASS, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangCloneable() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_CLONEABLE);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_LANG, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_LANG_CLONEABLE, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangError() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_ERROR);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_LANG, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_LANG_ERROR, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangObject() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_OBJECT);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_LANG, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangRuntimeException() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_RUNTIMEEXCEPTION);
+ if (type != null)
+ return type;
+
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(JAVA_LANG, NotFound)); // record extra reference to pkg
+ problemReporter().isClassPathCorrect(JAVA_LANG_RUNTIMEEXCEPTION, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangString() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_STRING);
+ if (type != null)
+ return type;
+
+ problemReporter().isClassPathCorrect(JAVA_LANG_STRING, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+public final ReferenceBinding getJavaLangThrowable() {
+ ReferenceBinding type = environment().getType(JAVA_LANG_THROWABLE);
+ if (type != null)
+ return type;
+
+ problemReporter().isClassPathCorrect(JAVA_LANG_THROWABLE, referenceCompilationUnit());
+ return null; // will not get here since the above error aborts the compilation
+}
+/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
+*/
+
+public final ReferenceBinding getMemberType(char[] typeName, ReferenceBinding enclosingType) {
+ ReferenceBinding memberType = findMemberType(typeName, enclosingType);
+ if (memberType == null)
+ return new ProblemReferenceBinding(typeName, NotFound);
+ else
+ return memberType;
+}
+/* Answer the type binding corresponding to the compoundName.
+*
+* NOTE: If a problem binding is returned, senders should extract the compound name
+* from the binding & not assume the problem applies to the entire compoundName.
+*/
+
+public final TypeBinding getType(char[][] compoundName) {
+ int typeNameLength = compoundName.length;
+ if (typeNameLength == 1) {
+ // Would like to remove this test and require senders to specially handle base types
+ TypeBinding binding = getBaseType(compoundName[0]);
+ if (binding != null)
+ return binding;
}
- /* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
- */
- public final ReferenceBinding getMemberType(
- char[] typeName,
- ReferenceBinding enclosingType) {
- ReferenceBinding memberType = findMemberType(typeName, enclosingType);
- if (memberType == null)
- return new ProblemReferenceBinding(typeName, NotFound);
- else
- return memberType;
+ Binding binding = getTypeOrPackage(compoundName[0], typeNameLength == 1 ? TYPE : TYPE | PACKAGE);
+ if (binding == null)
+ return new ProblemReferenceBinding(compoundName[0], NotFound);
+ if (!binding.isValidBinding()){
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(compoundName[0], NotFound)); // record extra reference to pkg
+ return (ReferenceBinding) binding;
}
+ int currentIndex = 1;
+ boolean checkVisibility = false;
+ if (binding instanceof PackageBinding) {
+ PackageBinding packageBinding = (PackageBinding) binding;
+ compilationUnitScope().addNamespaceReference(packageBinding);
- /* Answer the type binding corresponding to the compoundName.
- *
- * NOTE: If a problem binding is returned, senders should extract the compound name
- * from the binding & not assume the problem applies to the entire compoundName.
- */
- public final TypeBinding getType(char[][] compoundName) {
- int typeNameLength = compoundName.length;
- if (typeNameLength == 1) {
- // Would like to remove this test and require senders to specially handle base types
- TypeBinding binding = getBaseType(compoundName[0]);
- if (binding != null)
- return binding;
- }
- Binding binding =
- getTypeOrPackage(compoundName[0], typeNameLength == 1 ? TYPE : TYPE | PACKAGE);
- if (binding == null)
- return new ProblemReferenceBinding(compoundName[0], NotFound);
- if (!binding.isValidBinding()) {
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(compoundName[0], NotFound));
- // record extra reference to pkg
- return (ReferenceBinding) binding;
- }
- int currentIndex = 1;
- boolean checkVisibility = false;
- if (binding instanceof PackageBinding) {
- PackageBinding packageBinding = (PackageBinding) binding;
+ while (currentIndex < typeNameLength) {
+ binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]); // does not check visibility
+ if (binding == null)
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), NotFound);
+ if (!binding.isValidBinding())
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), binding.problemId());
+ if (!(binding instanceof PackageBinding))
+ break;
+ packageBinding = (PackageBinding) binding;
compilationUnitScope().addNamespaceReference(packageBinding);
-
- while (currentIndex < typeNameLength) {
- binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
- // does not check visibility
- if (binding == null)
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- NotFound);
- if (!binding.isValidBinding())
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- binding.problemId());
- if (!(binding instanceof PackageBinding))
- break;
- packageBinding = (PackageBinding) binding;
- compilationUnitScope().addNamespaceReference(packageBinding);
- }
- if (binding instanceof PackageBinding)
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- NotFound);
- checkVisibility = true;
}
- // binding is now a ReferenceBinding
- ReferenceBinding typeBinding = (ReferenceBinding) binding;
- compilationUnitScope().addTypeReference(typeBinding);
- if (checkVisibility) // handles the fall through case
- if (!typeBinding.canBeSeenBy(this))
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- NotVisible);
- while (currentIndex < typeNameLength) {
- typeBinding = getMemberType(compoundName[currentIndex++], typeBinding);
- if (!typeBinding.isValidBinding())
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- typeBinding.problemId());
- }
- return typeBinding;
+ if (binding instanceof PackageBinding)
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), NotFound);
+ checkVisibility = true;
}
- /* Answer the type binding that corresponds the given name, starting the lookup in the receiver.
- * The name provided is a simple source name (e.g., "Object" , "Point", ...)
- */
- // The return type of this method could be ReferenceBinding if we did not answer base types.
- // NOTE: We could support looking for Base Types last in the search, however any code using
- // this feature would be extraordinarily slow. Therefore we don't do this
- public final TypeBinding getType(char[] name) {
- // Would like to remove this test and require senders to specially handle base types
- TypeBinding binding = getBaseType(name);
+ // binding is now a ReferenceBinding
+ ReferenceBinding typeBinding = (ReferenceBinding) binding;
+ compilationUnitScope().addTypeReference(typeBinding);
+ if (checkVisibility) // handles the fall through case
+ if (!typeBinding.canBeSeenBy(this))
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), NotVisible);
+
+ while (currentIndex < typeNameLength) {
+ typeBinding = getMemberType(compoundName[currentIndex++], typeBinding);
+ if (!typeBinding.isValidBinding())
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), typeBinding.problemId());
+ }
+ return typeBinding;
+}
+/* Answer the type binding that corresponds the given name, starting the lookup in the receiver.
+* The name provided is a simple source name (e.g., "Object" , "Point", ...)
+*/
+
+// The return type of this method could be ReferenceBinding if we did not answer base types.
+
+// NOTE: We could support looking for Base Types last in the search, however any code using
+// this feature would be extraordinarily slow. Therefore we don't do this
+
+public final TypeBinding getType(char[] name) {
+ // Would like to remove this test and require senders to specially handle base types
+ TypeBinding binding = getBaseType(name);
+ if (binding != null)
+ return binding;
+
+ return (ReferenceBinding) getTypeOrPackage(name, TYPE);
+}
+// Added for code assist... NOT Public API
+
+public final Binding getTypeOrPackage(char[][] compoundName) {
+ int nameLength = compoundName.length;
+ if (nameLength == 1) {
+ TypeBinding binding = getBaseType(compoundName[0]);
if (binding != null)
return binding;
-
- return (ReferenceBinding) getTypeOrPackage(name, TYPE);
}
- // Added for code assist... NOT Public API
- public final Binding getTypeOrPackage(char[][] compoundName) {
- int nameLength = compoundName.length;
- if (nameLength == 1) {
- TypeBinding binding = getBaseType(compoundName[0]);
- if (binding != null)
- return binding;
- }
- Binding binding = getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
- if (!binding.isValidBinding())
- return binding;
+ Binding binding = getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
+ if (!binding.isValidBinding())
+ return binding;
- int currentIndex = 1;
- boolean checkVisibility = false;
- if (binding instanceof PackageBinding) {
- PackageBinding packageBinding = (PackageBinding) binding;
-
- while (currentIndex < nameLength) {
- binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
- if (binding == null)
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- NotFound);
- if (!binding.isValidBinding())
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- binding.problemId());
- if (!(binding instanceof PackageBinding))
- break;
- packageBinding = (PackageBinding) binding;
- }
- if (binding instanceof PackageBinding)
- return binding;
- checkVisibility = true;
- }
- // binding is now a ReferenceBinding
- ReferenceBinding typeBinding = (ReferenceBinding) binding;
- if (checkVisibility) // handles the fall through case
- if (!typeBinding.canBeSeenBy(this))
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- NotVisible);
+ int currentIndex = 1;
+ boolean checkVisibility = false;
+ if (binding instanceof PackageBinding) {
+ PackageBinding packageBinding = (PackageBinding) binding;
while (currentIndex < nameLength) {
- typeBinding = getMemberType(compoundName[currentIndex++], typeBinding);
- // checks visibility
- if (!typeBinding.isValidBinding())
- return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, currentIndex),
- typeBinding.problemId());
+ binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
+ if (binding == null)
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), NotFound);
+ if (!binding.isValidBinding())
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), binding.problemId());
+ if (!(binding instanceof PackageBinding))
+ break;
+ packageBinding = (PackageBinding) binding;
}
- return typeBinding;
+
+ if (binding instanceof PackageBinding)
+ return binding;
+ checkVisibility = true;
}
- /* Internal use only
- */
- final Binding getTypeOrPackage(char[] name, int mask) {
- Scope scope = this;
- if ((mask & TYPE) == 0) {
- Scope next = scope;
- while ((next = scope.parent) != null)
- scope = next;
- } else {
- ReferenceBinding foundType = null;
- done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (scope.kind) {
- case METHOD_SCOPE :
- case BLOCK_SCOPE :
- ReferenceBinding localType = ((BlockScope) scope).findLocalType(name);
- // looks in this scope only
- if (localType != null) {
- if (foundType != null && foundType != localType)
- return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
- return localType;
- }
- break;
- case CLASS_SCOPE :
- SourceTypeBinding sourceType = ((ClassScope) scope).referenceContext.binding;
- if (CharOperation.equals(sourceType.sourceName, name)) {
- if (foundType != null && foundType != sourceType)
+ // binding is now a ReferenceBinding
+ ReferenceBinding typeBinding = (ReferenceBinding) binding;
+ if (checkVisibility) // handles the fall through case
+ if (!typeBinding.canBeSeenBy(this))
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), NotVisible);
+
+ while (currentIndex < nameLength) {
+ typeBinding = getMemberType(compoundName[currentIndex++], typeBinding); // checks visibility
+ if (!typeBinding.isValidBinding())
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), typeBinding.problemId());
+ }
+ return typeBinding;
+}
+/* Internal use only
+*/
+
+final Binding getTypeOrPackage(char[] name, int mask) {
+ Scope scope = this;
+ if ((mask & TYPE) == 0) {
+ Scope next = scope;
+ while ((next = scope.parent) != null)
+ scope = next;
+ } else {
+ ReferenceBinding foundType = null;
+ done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
+ switch(scope.kind) {
+ case METHOD_SCOPE :
+ case BLOCK_SCOPE :
+ ReferenceBinding localType = ((BlockScope) scope).findLocalType(name); // looks in this scope only
+ if (localType != null) {
+ if (foundType != null && foundType != localType)
+ return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
+ return localType;
+ }
+ break;
+ case CLASS_SCOPE :
+ SourceTypeBinding sourceType = ((ClassScope) scope).referenceContext.binding;
+ if (CharOperation.equals(sourceType.sourceName, name)) {
+ if (foundType != null && foundType != sourceType)
+ return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
+ return sourceType;
+ }
+
+ ReferenceBinding memberType = findMemberType(name, sourceType);
+ if (memberType != null) { // skip it if we did not find anything
+ if (memberType.problemId() == Ambiguous) {
+ if (foundType == null || foundType.problemId() == NotVisible)
+ // supercedes any potential InheritedNameHidesEnclosingName problem
+ return memberType;
+ else
+ // make the user qualify the type, likely wants the first inherited type
return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
- return sourceType;
}
- ReferenceBinding memberType = findMemberType(name, sourceType);
- if (memberType != null) { // skip it if we did not find anything
- if (memberType.problemId() == Ambiguous) {
- if (foundType == null || foundType.problemId() == NotVisible)
- // supercedes any potential InheritedNameHidesEnclosingName problem
+
+ if (memberType.isValidBinding()) {
+ if (sourceType == memberType.enclosingType()) { // found a valid type in the 'immediate' scope (ie. not inherited)
+ if (foundType == null)
return memberType;
- else
- // make the user qualify the type, likely wants the first inherited type
- return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
+ if (foundType.isValidBinding()) // if a valid type was found, complain when another is found in an 'immediate' enclosing type (ie. not inherited)
+ if (foundType != memberType)
+ return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
}
- if (memberType.isValidBinding()) {
- if (sourceType == memberType.enclosingType()) {
- // found a valid type in the 'immediate' scope (ie. not inherited)
- if (foundType == null)
- return memberType;
- if (foundType.isValidBinding())
- // if a valid type was found, complain when another is found in an 'immediate' enclosing type (ie. not inherited)
- if (foundType != memberType)
- return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
- }
- }
- if (foundType == null
- || (foundType.problemId() == NotVisible && memberType.problemId() != NotVisible))
- // only remember the memberType if its the first one found or the previous one was not visible & memberType is...
- foundType = memberType;
}
- break;
- case COMPILATION_UNIT_SCOPE :
- break done;
- }
- scope = scope.parent;
- }
- if (foundType != null)
- return foundType;
- }
- // at this point the scope is a compilation unit scope
- CompilationUnitScope unitScope = (CompilationUnitScope) scope;
- // ask for the imports + name
- if ((mask & TYPE) != 0) {
- // check single type imports.
- ImportBinding[] imports = unitScope.imports;
- // copy the list, since single type imports are removed if they cannot be resolved
- for (int i = 0, length = imports.length; i < length; i++) {
- ImportBinding typeImport = imports[i];
- if (!typeImport.onDemand)
- if (CharOperation
- .equals(typeImport.compoundName[typeImport.compoundName.length - 1], name))
- if (unitScope.resolveSingleTypeImport(typeImport) != null)
- return typeImport.resolvedImport; // already know its visible
- }
- // check if the name is in the current package (answer the problem binding unless its not found in which case continue to look)
- ReferenceBinding type = findType(name, unitScope.fPackage, unitScope.fPackage);
- // is always visible
- if (type != null)
- return type;
-
- // check on demand imports
- boolean foundInImport = false;
- for (int i = 0, length = unitScope.imports.length; i < length; i++) {
- if (unitScope.imports[i].onDemand) {
- Binding resolvedImport = unitScope.imports[i].resolvedImport;
- ReferenceBinding temp =
- (resolvedImport instanceof PackageBinding)
- ? findType(name, (PackageBinding) resolvedImport, unitScope.fPackage)
- : findDirectMemberType(name, (ReferenceBinding) resolvedImport);
- if (temp != null && temp.isValidBinding()) {
- if (foundInImport)
- // Answer error binding -- import on demand conflict; name found in two import on demand packages.
- return new ProblemReferenceBinding(name, Ambiguous);
- type = temp;
- foundInImport = true;
+
+ if (foundType == null || (foundType.problemId() == NotVisible && memberType.problemId() != NotVisible))
+ // only remember the memberType if its the first one found or the previous one was not visible & memberType is...
+ foundType = memberType;
}
- }
+ break;
+ case COMPILATION_UNIT_SCOPE :
+ break done;
}
- if (type != null)
- return type;
- }
- // see if the name is a package
- if ((mask & PACKAGE) != 0) {
- PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
- if (packageBinding != null)
- return packageBinding;
- }
- // Answer error binding -- could not find name
- compilationUnitScope().addNamespaceReference(
- new ProblemPackageBinding(name, NotFound));
- return new ProblemReferenceBinding(name, NotFound);
- }
-
- /* Answer whether the type is defined in the same compilation unit as the receiver
- */
- public final boolean isDefinedInSameUnit(ReferenceBinding type) {
- // find the outer most enclosing type
- ReferenceBinding enclosingType = type;
- while ((type = enclosingType.enclosingType()) != null)
- enclosingType = type;
-
- // find the compilation unit scope
- Scope scope, unitScope = this;
- while ((scope = unitScope.parent) != null)
- unitScope = scope;
-
- // test that the enclosingType is not part of the compilation unit
- SourceTypeBinding[] topLevelTypes =
- ((CompilationUnitScope) unitScope).topLevelTypes;
- for (int i = topLevelTypes.length; --i >= 0;)
- if (topLevelTypes[i] == enclosingType)
- return true;
- return false;
- }
-
- public final boolean isJavaIoSerializable(TypeBinding tb) {
- //a first -none optimized version-...:-)....
- //please modify as needed
-
- return tb == getJavaIoSerializable();
- }
-
- public final boolean isJavaLangCloneable(TypeBinding tb) {
- //a first -none optimized version-...:-)....
- //please modify as needed
-
- return tb == getJavaLangCloneable();
- }
-
- public final boolean isJavaLangObject(TypeBinding type) {
- return type.id == T_JavaLangObject;
- }
-
- public final MethodScope methodScope() {
- Scope scope = this;
- do {
- if (scope instanceof MethodScope)
- return (MethodScope) scope;
scope = scope.parent;
- } while (scope != null);
- return null;
+ }
+ if (foundType != null)
+ return foundType;
}
- // Internal use only
- /* All methods in visible are acceptable matches for the method in question...
- * The methods defined by the receiver type appear before those defined by its
- * superclass and so on. We want to find the one which matches best.
- *
- * Since the receiver type is a class, we know each method's declaring class is
- * either the receiver type or one of its superclasses. It is an error if the best match
- * is defined by a superclass, when a lesser match is defined by the receiver type
- * or a closer superclass.
- */
- protected final MethodBinding mostSpecificClassMethodBinding(
- MethodBinding[] visible,
- int visibleSize) {
- MethodBinding method = null;
- MethodBinding previous = null;
- nextVisible : for (int i = 0; i < visibleSize; i++) {
- method = visible[i];
- if (previous != null && method.declaringClass != previous.declaringClass)
- break;
- // cannot answer a method farther up the hierarchy than the first method found
- previous = method;
- for (int j = 0; j < visibleSize; j++) {
- if (i == j)
- continue;
- MethodBinding next = visible[j];
- if (!areParametersAssignable(next.parameters, method.parameters))
- continue nextVisible;
- }
- compilationUnitScope().addTypeReferences(method.thrownExceptions);
- return method;
+ // at this point the scope is a compilation unit scope
+ CompilationUnitScope unitScope = (CompilationUnitScope) scope;
+ // ask for the imports + name
+ if ((mask & TYPE) != 0) {
+ // check single type imports.
+ ImportBinding[] imports = unitScope.imports; // copy the list, since single type imports are removed if they cannot be resolved
+ for (int i = 0, length = imports.length; i < length; i++) {
+ ImportBinding typeImport = imports[i];
+ if (!typeImport.onDemand)
+ if (CharOperation.equals(typeImport.compoundName[typeImport.compoundName.length - 1], name))
+ if (unitScope.resolveSingleTypeImport(typeImport) != null)
+ return typeImport.resolvedImport; // already know its visible
}
- return new ProblemMethodBinding(
- visible[0].selector,
- visible[0].parameters,
- Ambiguous);
- }
- // Internal use only
- /* All methods in visible are acceptable matches for the method in question...
- * Since the receiver type is an interface, we ignore the possibility that 2 inherited
- * but unrelated superinterfaces may define the same method in acceptable but
- * not identical ways... we just take the best match that we find since any class which
- * implements the receiver interface MUST implement all signatures for the method...
- * in which case the best match is correct.
- *
- * NOTE: This is different than javac... in the following example, the message send of
- * bar(X) in class Y is supposed to be ambiguous. But any class which implements the
- * interface I MUST implement both signatures for bar. If this class was the receiver of
- * the message send instead of the interface I, then no problem would be reported.
- *
- interface I1 {
- void bar(J j);
- }
- interface I2 {
- // void bar(J j);
- void bar(Object o);
- }
- interface I extends I1, I2 {}
- interface J {}
-
- class X implements J {}
-
- class Y extends X {
- public void foo(I i, X x) { i.bar(x); }
- }
- */
- protected final MethodBinding mostSpecificInterfaceMethodBinding(
- MethodBinding[] visible,
- int visibleSize) {
- MethodBinding method = null;
- nextVisible : for (int i = 0; i < visibleSize; i++) {
- method = visible[i];
- for (int j = 0; j < visibleSize; j++) {
- if (i == j)
- continue;
- MethodBinding next = visible[j];
- if (!areParametersAssignable(next.parameters, method.parameters))
- continue nextVisible;
+ // check if the name is in the current package (answer the problem binding unless its not found in which case continue to look)
+ ReferenceBinding type = findType(name, unitScope.fPackage, unitScope.fPackage); // is always visible
+ if (type != null)
+ return type;
+
+ // check on demand imports
+ boolean foundInImport = false;
+ for (int i = 0, length = unitScope.imports.length; i < length; i++) {
+ if (unitScope.imports[i].onDemand) {
+ Binding resolvedImport = unitScope.imports[i].resolvedImport;
+ ReferenceBinding temp =
+ (resolvedImport instanceof PackageBinding)
+ ? findType(name, (PackageBinding) resolvedImport, unitScope.fPackage)
+ : findDirectMemberType(name, (ReferenceBinding) resolvedImport);
+ if (temp != null && temp.isValidBinding()) {
+ if (foundInImport)
+ // Answer error binding -- import on demand conflict; name found in two import on demand packages.
+ return new ProblemReferenceBinding(name, Ambiguous);
+ type = temp;
+ foundInImport = true;
+ }
}
- compilationUnitScope().addTypeReferences(method.thrownExceptions);
- return method;
}
- return new ProblemMethodBinding(
- visible[0].selector,
- visible[0].parameters,
- Ambiguous);
- }
- public final ClassScope outerMostClassScope() {
- ClassScope lastClassScope = null;
- Scope scope = this;
- do {
- if (scope instanceof ClassScope)
- lastClassScope = (ClassScope) scope;
- scope = scope.parent;
- } while (scope != null);
- return lastClassScope; // may answer null if no class around
+ if (type != null)
+ return type;
}
- public final MethodScope outerMostMethodScope() {
- MethodScope lastMethodScope = null;
- Scope scope = this;
- do {
- if (scope instanceof MethodScope)
- lastMethodScope = (MethodScope) scope;
- scope = scope.parent;
- } while (scope != null);
- return lastMethodScope; // may answer null if no method around
+ // see if the name is a package
+ if ((mask & PACKAGE) != 0) {
+ PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
+ if (packageBinding != null)
+ return packageBinding;
}
- public final CompilationUnitDeclaration referenceCompilationUnit() {
- Scope scope, unitScope = this;
- while ((scope = unitScope.parent) != null)
- unitScope = scope;
- return ((CompilationUnitScope) unitScope).referenceContext;
+ // Answer error binding -- could not find name
+ compilationUnitScope().addNamespaceReference(new ProblemPackageBinding(name, NotFound));
+ return new ProblemReferenceBinding(name, NotFound);
+}
+/* Answer whether the type is defined in the same compilation unit as the receiver
+*/
+
+public final boolean isDefinedInSameUnit(ReferenceBinding type) {
+ // find the outer most enclosing type
+ ReferenceBinding enclosingType = type;
+ while ((type = enclosingType.enclosingType()) != null)
+ enclosingType = type;
+
+ // find the compilation unit scope
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+
+ // test that the enclosingType is not part of the compilation unit
+ SourceTypeBinding[] topLevelTypes = ((CompilationUnitScope) unitScope).topLevelTypes;
+ for (int i = topLevelTypes.length; --i >= 0;)
+ if (topLevelTypes[i] == enclosingType)
+ return true;
+ return false;
+}
+public final boolean isJavaIoSerializable(TypeBinding tb){
+ //a first -none optimized version-...:-)....
+ //please modify as needed
+
+ return tb == getJavaIoSerializable();
+}
+public final boolean isJavaLangCloneable(TypeBinding tb){
+ //a first -none optimized version-...:-)....
+ //please modify as needed
+
+ return tb == getJavaLangCloneable();
+}
+public final boolean isJavaLangObject(TypeBinding type) {
+ return type.id == T_JavaLangObject;
+}
+public final MethodScope methodScope() {
+ Scope scope = this;
+ do {
+ if (scope instanceof MethodScope)
+ return (MethodScope) scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return null;
+}
+// Internal use only
+
+/* All methods in visible are acceptable matches for the method in question...
+* The methods defined by the receiver type appear before those defined by its
+* superclass and so on. We want to find the one which matches best.
+*
+* Since the receiver type is a class, we know each method's declaring class is
+* either the receiver type or one of its superclasses. It is an error if the best match
+* is defined by a superclass, when a lesser match is defined by the receiver type
+* or a closer superclass.
+*/
+
+protected final MethodBinding mostSpecificClassMethodBinding(MethodBinding[] visible, int visibleSize) {
+ MethodBinding method = null;
+ MethodBinding previous = null;
+ nextVisible: for (int i = 0; i < visibleSize; i++) {
+ method = visible[i];
+ if (previous != null && method.declaringClass != previous.declaringClass)
+ break; // cannot answer a method farther up the hierarchy than the first method found
+ previous = method;
+ for (int j = 0; j < visibleSize; j++) {
+ if (i == j) continue;
+ MethodBinding next = visible[j];
+ if (!areParametersAssignable(next.parameters, method.parameters))
+ continue nextVisible;
+ }
+ compilationUnitScope().addTypeReferences(method.thrownExceptions);
+ return method;
}
- // start position in this scope - for ordering scopes vs. variables
- int startIndex() {
- return 0;
+ return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, Ambiguous);
+}
+// Internal use only
+
+/* All methods in visible are acceptable matches for the method in question...
+* Since the receiver type is an interface, we ignore the possibility that 2 inherited
+* but unrelated superinterfaces may define the same method in acceptable but
+* not identical ways... we just take the best match that we find since any class which
+* implements the receiver interface MUST implement all signatures for the method...
+* in which case the best match is correct.
+*
+* NOTE: This is different than javac... in the following example, the message send of
+* bar(X) in class Y is supposed to be ambiguous. But any class which implements the
+* interface I MUST implement both signatures for bar. If this class was the receiver of
+* the message send instead of the interface I, then no problem would be reported.
+*
+interface I1 {
+ void bar(J j);
+}
+interface I2 {
+// void bar(J j);
+ void bar(Object o);
+}
+interface I extends I1, I2 {}
+interface J {}
+
+class X implements J {}
+
+class Y extends X {
+ public void foo(I i, X x) { i.bar(x); }
+}
+*/
+
+protected final MethodBinding mostSpecificInterfaceMethodBinding(MethodBinding[] visible, int visibleSize) {
+ MethodBinding method = null;
+ nextVisible: for (int i = 0; i < visibleSize; i++) {
+ method = visible[i];
+ for (int j = 0; j < visibleSize; j++) {
+ if (i == j) continue;
+ MethodBinding next = visible[j];
+ if (!areParametersAssignable(next.parameters, method.parameters))
+ continue nextVisible;
+ }
+ compilationUnitScope().addTypeReferences(method.thrownExceptions);
+ return method;
}
-} \ No newline at end of file
+ return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, Ambiguous);
+}
+public final ClassScope outerMostClassScope() {
+ ClassScope lastClassScope = null;
+ Scope scope = this;
+ do {
+ if (scope instanceof ClassScope)
+ lastClassScope = (ClassScope) scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return lastClassScope; // may answer null if no class around
+}
+public final MethodScope outerMostMethodScope() {
+ MethodScope lastMethodScope = null;
+ Scope scope = this;
+ do {
+ if (scope instanceof MethodScope)
+ lastMethodScope = (MethodScope) scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return lastMethodScope; // may answer null if no method around
+}
+public abstract ProblemReporter problemReporter();
+public final CompilationUnitDeclaration referenceCompilationUnit() {
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+ return ((CompilationUnitScope) unitScope).referenceContext;
+}
+// start position in this scope - for ordering scopes vs. variables
+int startIndex() {
+ return 0;
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index 00767da49f..4f1f13b1a6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -118,7 +118,7 @@ public FieldBinding addSyntheticField(LocalVariableBinding actualOuterLocalVaria
synthField.name = CharOperation.concat(
SyntheticArgumentBinding.OuterLocalPrefix,
actualOuterLocalVariable.name,
- ("$" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
+ ("$"/*nonNLS*/ + String.valueOf(index++)).toCharArray());
needRecheck = true;
break;
}
@@ -176,7 +176,7 @@ public FieldBinding addSyntheticField(TypeBinding targetType, BlockScope blockSc
FieldBinding synthField = (FieldBinding) synthetics[CLASS_LITERAL].get(targetType);
if (synthField == null) {
synthField = new SyntheticFieldBinding(
- ("class$" + synthetics[CLASS_LITERAL].size()).toCharArray(), //$NON-NLS-1$
+ ("class$"/*nonNLS*/ + synthetics[CLASS_LITERAL].size()).toCharArray(),
blockScope.getJavaLangClass(),
AccDefault | AccStatic | AccSynthetic,
this,
@@ -198,51 +198,6 @@ public FieldBinding addSyntheticField(TypeBinding targetType, BlockScope blockSc
}
return synthField;
}
-
-/* Add a new synthetic field for the emulation of the assert statement.
-* Answer the new field or the existing field if one already existed.
-*/
-public FieldBinding addSyntheticField(AssertStatement assertStatement, BlockScope blockScope) {
- if (synthetics == null) {
- synthetics = new Hashtable[] { new Hashtable(5), new Hashtable(5), new Hashtable(5) };
- }
-
- // use a different table than FIELDS, given there might be a collision between emulation of X.this$0 and X.class.
- FieldBinding synthField = (FieldBinding) synthetics[FIELD].get("assertionEmulation"); //$NON-NLS-1$
- if (synthField == null) {
- synthField = new SyntheticFieldBinding(
- "$assertionsDisabled".toCharArray(), //$NON-NLS-1$
- BooleanBinding,
- AccDefault | AccStatic | AccSynthetic | AccFinal,
- this,
- Constant.NotAConstant,
- 0);
- synthetics[FIELD].put("assertionEmulation", synthField); //$NON-NLS-1$
- }
- // ensure there is not already such a field defined by the user
- // ensure there is not already such a field defined by the user
- boolean needRecheck;
- int index = 0;
- do {
- needRecheck = false;
- FieldBinding existingField;
- if ((existingField = this.getField(synthField.name)) != null) {
- TypeDeclaration typeDecl = scope.referenceContext;
- for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
- FieldDeclaration fieldDecl = typeDecl.fields[i];
- if (fieldDecl.binding == existingField) {
- synthField.name = CharOperation.concat(
- "$assertionsDisabled".toCharArray(), //$NON-NLS-1$
- ("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
- needRecheck = true;
- break;
- }
- }
- }
- } while (needRecheck);
- return synthField;
-}
-
/* Add a new synthetic access method for read/write access to <targetField>.
Answer the new method or the existing method if one already existed.
*/
@@ -777,71 +732,71 @@ public FieldBinding[] syntheticFields() {
return bindings;
}
public String toString() {
- String s = "(id="+(id == NoId ? "NoId" : (""+id) ) +")\n"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$ //$NON-NLS-1$
+ String s = "(id="/*nonNLS*/+(id == NoId ? "NoId"/*nonNLS*/ : (""/*nonNLS*/+id) ) +")\n"/*nonNLS*/;
- if (isDeprecated()) s += "deprecated "; //$NON-NLS-1$
- if (isPublic()) s += "public "; //$NON-NLS-1$
- if (isProtected()) s += "protected "; //$NON-NLS-1$
- if (isPrivate()) s += "private "; //$NON-NLS-1$
- if (isAbstract() && isClass()) s += "abstract "; //$NON-NLS-1$
- if (isStatic() && isNestedType()) s += "static "; //$NON-NLS-1$
- if (isFinal()) s += "final "; //$NON-NLS-1$
+ if (isDeprecated()) s += "deprecated "/*nonNLS*/;
+ if (isPublic()) s += "public "/*nonNLS*/;
+ if (isProtected()) s += "protected "/*nonNLS*/;
+ if (isPrivate()) s += "private "/*nonNLS*/;
+ if (isAbstract() && isClass()) s += "abstract "/*nonNLS*/;
+ if (isStatic() && isNestedType()) s += "static "/*nonNLS*/;
+ if (isFinal()) s += "final "/*nonNLS*/;
- s += isInterface() ? "interface " : "class "; //$NON-NLS-1$ //$NON-NLS-2$
- s += (compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"; //$NON-NLS-1$
+ s += isInterface() ? "interface "/*nonNLS*/ : "class "/*nonNLS*/;
+ s += (compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED TYPE"/*nonNLS*/;
- s += "\n\textends "; //$NON-NLS-1$
- s += (superclass != null) ? superclass.debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += "\n\textends "/*nonNLS*/;
+ s += (superclass != null) ? superclass.debugName() : "NULL TYPE"/*nonNLS*/;
if (superInterfaces != null) {
if (superInterfaces != NoSuperInterfaces) {
- s += "\n\timplements : "; //$NON-NLS-1$
+ s += "\n\timplements : "/*nonNLS*/;
for (int i = 0, length = superInterfaces.length; i < length; i++) {
if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += (superInterfaces[i] != null) ? superInterfaces[i].debugName() : "NULL TYPE"; //$NON-NLS-1$
+ s += ", "/*nonNLS*/;
+ s += (superInterfaces[i] != null) ? superInterfaces[i].debugName() : "NULL TYPE"/*nonNLS*/;
}
}
} else {
- s += "NULL SUPERINTERFACES"; //$NON-NLS-1$
+ s += "NULL SUPERINTERFACES"/*nonNLS*/;
}
if (enclosingType() != null) {
- s += "\n\tenclosing type : "; //$NON-NLS-1$
+ s += "\n\tenclosing type : "/*nonNLS*/;
s += enclosingType().debugName();
}
if (fields != null) {
if (fields != NoFields) {
- s += "\n/* fields */"; //$NON-NLS-1$
+ s += "\n/* fields */"/*nonNLS*/;
for (int i = 0, length = fields.length; i < length; i++)
- s += (fields[i] != null) ? "\n" + fields[i].toString() : "\nNULL FIELD"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (fields[i] != null) ? "\n"/*nonNLS*/ + fields[i].toString() : "\nNULL FIELD"/*nonNLS*/;
}
} else {
- s += "NULL FIELDS"; //$NON-NLS-1$
+ s += "NULL FIELDS"/*nonNLS*/;
}
if (methods != null) {
if (methods != NoMethods) {
- s += "\n/* methods */"; //$NON-NLS-1$
+ s += "\n/* methods */"/*nonNLS*/;
for (int i = 0, length = methods.length; i < length; i++)
- s += (methods[i] != null) ? "\n" + methods[i].toString() : "\nNULL METHOD"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (methods[i] != null) ? "\n"/*nonNLS*/ + methods[i].toString() : "\nNULL METHOD"/*nonNLS*/;
}
} else {
- s += "NULL METHODS"; //$NON-NLS-1$
+ s += "NULL METHODS"/*nonNLS*/;
}
if (memberTypes != null) {
if (memberTypes != NoMemberTypes) {
- s += "\n/* members */"; //$NON-NLS-1$
+ s += "\n/* members */"/*nonNLS*/;
for (int i = 0, length = memberTypes.length; i < length; i++)
- s += (memberTypes[i] != null) ? "\n" + memberTypes[i].toString() : "\nNULL TYPE"; //$NON-NLS-1$ //$NON-NLS-2$
+ s += (memberTypes[i] != null) ? "\n"/*nonNLS*/ + memberTypes[i].toString() : "\nNULL TYPE"/*nonNLS*/;
}
} else {
- s += "NULL MEMBER TYPES"; //$NON-NLS-1$
+ s += "NULL MEMBER TYPES"/*nonNLS*/;
}
- s += "\n\n\n"; //$NON-NLS-1$
+ s += "\n\n\n"/*nonNLS*/;
return s;
}
void verifyMethods(MethodVerifier verifier) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index d0db104d62..cef8fc3bb2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -17,7 +17,6 @@ public interface TypeConstants {
// Constant compound names
final char[][] JAVA_LANG = new char[][] {JAVA, LANG};
final char[][] JAVA_IO = new char[][] {JAVA, IO};
- final char[][] JAVA_LANG_ASSERTIONERROR = new char[][] {JAVA, LANG, "AssertionError".toCharArray()}; //$NON-NLS-1$
final char[][] JAVA_LANG_CLASS = new char[][] {JAVA, LANG, {'C', 'l', 'a', 's', 's'}};
final char[][] JAVA_LANG_CLASSNOTFOUNDEXCEPTION = new char[][] {JAVA, LANG, {'C', 'l', 'a', 's', 's', 'N', 'o', 't', 'F', 'o', 'u', 'n', 'd', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n'}};
final char[][] JAVA_LANG_CLONEABLE = new char[][] {JAVA, LANG, {'C', 'l', 'o', 'n', 'e', 'a', 'b', 'l', 'e'}};
@@ -33,15 +32,15 @@ public interface TypeConstants {
final char[][] JAVA_LANG_REFLECT_CONSTRUCTOR = new char[][] {JAVA, LANG, REFLECT, {'C', 'o', 'n', 's', 't', 'r', 'u', 'c', 't', 'o', 'r'}};
final char[][] JAVA_IO_PRINTSTREAM = new char[][] {JAVA, IO, {'P', 'r', 'i', 'n', 't', 'S', 't', 'r', 'e', 'a', 'm'}};
final char[][] JAVA_IO_SERIALIZABLE = new char[][] {JAVA, IO, {'S', 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 'b', 'l', 'e'}};
- final char[][] JAVA_LANG_BYTE = new char[][] {JAVA, LANG, "Byte".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_SHORT = new char[][] {JAVA, LANG, "Short".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_CHARACTER = new char[][] {JAVA, LANG, "Character".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_INTEGER = new char[][] {JAVA, LANG, "Integer".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_LONG = new char[][] {JAVA, LANG, "Long".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_FLOAT = new char[][] {JAVA, LANG, "Float".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_DOUBLE = new char[][] {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_BOOLEAN = new char[][] {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_VOID = new char[][] {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_BYTE = new char[][] {JAVA, LANG, "Byte"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_SHORT = new char[][] {JAVA, LANG, "Short"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_CHARACTER = new char[][] {JAVA, LANG, "Character"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_INTEGER = new char[][] {JAVA, LANG, "Integer"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_LONG = new char[][] {JAVA, LANG, "Long"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_FLOAT = new char[][] {JAVA, LANG, "Float"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_DOUBLE = new char[][] {JAVA, LANG, "Double"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_BOOLEAN = new char[][] {JAVA, LANG, "Boolean"/*nonNLS*/.toCharArray()};
+ final char[][] JAVA_LANG_VOID = new char[][] {JAVA, LANG, "Void"/*nonNLS*/.toCharArray()};
// Constants used by the flow analysis
final int EqualOrMoreSpecific = -1;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
index 61b633610f..8647522e85 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
@@ -52,9 +52,6 @@ public interface TypeIds {
final int T_JavaLangDouble = 32;
final int T_JavaLangBoolean = 33;
final int T_JavaLangVoid = 34;
-
- // 1.4 feature
- final int T_JavaLangAssertionError = 35;
final int NoId = Integer.MAX_VALUE;
// implicit conversions: <compileType> to <runtimeType> (note: booleans are integers at runtime)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
index b5920110f8..0ad1bf118f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
@@ -32,6 +32,6 @@ ReferenceBinding resolve(LookupEnvironment environment) {
return null; // will not get here since the above error aborts the compilation
}
public String toString() {
- return "Unresolved type " + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$
+ return "Unresolved type "/*nonNLS*/ + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"/*nonNLS*/);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
index 5006fbae1c..6bdad125b4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
@@ -26,9 +26,9 @@ public char[] readableName() {
return name;
}
public String toString() {
- String s = (type != null) ? type.debugName() : "UNDEFINED TYPE"; //$NON-NLS-1$
- s += " "; //$NON-NLS-1$
- s += (name != null) ? new String(name) : "UNNAMED FIELD"; //$NON-NLS-1$
+ String s = (type != null) ? type.debugName() : "UNDEFINED TYPE"/*nonNLS*/;
+ s += " "/*nonNLS*/;
+ s += (name != null) ? new String(name) : "UNNAMED FIELD"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java
deleted file mode 100644
index 8642a67ef3..0000000000
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.jdt.internal.compiler.parser;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
-
-public class NLSLine {
-
- private int fLineNumber;
- private List fElements;
-
- public NLSLine(int lineNumber) {
- fLineNumber= lineNumber;
- fElements= new ArrayList();
- }
-
- /**
- * Adds a NLS element to this line.
- */
- public void add(StringLiteral element) {
- fElements.add(element);
- }
-
- /**
- * returns an Iterator over NLSElements
- */
- public Iterator iterator() {
- return fElements.iterator();
- }
-
- public StringLiteral get(int index) {
- return (StringLiteral) fElements.get(index);
- }
-
- public void set(int index, StringLiteral literal) {
- fElements.set(index, literal);
- }
-
- public boolean exists(int index) {
- return index >= 0 && index < fElements.size();
- }
-
- public int size(){
- return fElements.size();
- }
-
- public String toString() {
- StringBuffer result= new StringBuffer();
- result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$
- for (Iterator iter= iterator(); iter.hasNext(); ) {
- result.append("\t"); //$NON-NLS-1$
- result.append(iter.next().toString());
- result.append("\n"); //$NON-NLS-1$
- }
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 1b916afeca..11a9f3e9f8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -13,7 +13,6 @@ import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
import java.io.*;
-import java.util.ArrayList;
public class Parser implements BindingIds, ParserBasicInformation, TerminalSymbols, CompilerModifiers, OperatorIds, TypeIds {
protected ProblemReporter problemReporter;
@@ -34,9 +33,6 @@ public class Parser implements BindingIds, ParserBasicInformation, TerminalSymbo
protected int lastIgnoredToken, nextIgnoredToken;
protected int lastErrorEndPosition;
- // 1.4 feature
- protected boolean assertMode = false;
-
//internal data for the automat
protected final static int StackIncrement = 255;
protected int stateStackTop;
@@ -82,270 +78,274 @@ public class Parser implements BindingIds, ParserBasicInformation, TerminalSymbo
protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...]
protected int[] variablesCounter;
//===DATA===DATA===DATA===DATA===DATA===DATA===//
- public final static byte rhs[] = {0,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,1,1,1,1,3,4,0,1,2,1,1,1,1,
- 1,1,1,1,1,5,1,2,1,2,2,2,1,1,2,
- 2,2,4,1,1,1,1,2,1,1,1,1,1,1,1,
- 1,1,1,1,2,3,3,2,2,1,3,1,3,1,2,
- 1,1,1,3,0,3,1,1,1,1,1,1,1,4,1,
- 3,3,7,0,0,0,0,0,2,1,1,1,2,2,4,
- 4,5,4,4,2,1,2,3,3,1,3,3,1,3,1,
- 4,0,2,1,2,4,1,1,2,5,5,7,7,7,7,
- 2,2,3,2,2,3,1,2,1,2,1,1,2,2,1,
- 1,1,1,1,3,3,4,1,3,4,0,1,2,1,1,
- 1,1,2,3,4,0,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 3,3,2,1,1,1,1,1,1,1,5,7,7,6,2,
- 3,3,4,1,2,2,1,2,3,2,5,5,7,9,9,
- 1,1,1,1,3,3,5,2,3,2,3,3,3,5,1,
- 3,4,1,2,5,2,1,1,1,1,1,1,3,1,1,
- 3,3,3,3,3,1,1,5,6,8,7,2,0,2,0,
- 1,3,4,4,1,2,3,2,1,1,2,2,3,3,4,
- 6,6,4,4,1,1,1,1,2,2,0,1,1,3,3,
- 1,3,3,1,3,3,1,5,5,4,1,3,3,3,1,
- 3,3,1,3,3,3,1,3,3,3,3,3,1,3,3,
- 1,3,1,3,1,3,1,3,1,3,1,5,1,1,3,
- 3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,
- 1,0,2,0,1,0,1,0,1,0,1,0,1,0,1,
- 0,1,0,2,0,0,1,0,1,0,1,0,1,0,1
- };
+
+ public final static byte rhs[] = {0,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,1,1,1,1,3,4,0,1,2,1,1,1,1,
+ 1,1,1,1,1,5,1,2,1,2,2,2,1,1,2,
+ 2,2,4,1,1,1,1,2,1,1,1,1,1,1,1,
+ 1,1,1,1,2,3,3,2,2,1,3,1,3,1,2,
+ 1,1,1,3,0,1,1,1,1,1,1,1,4,1,3,
+ 3,7,0,0,0,0,0,2,1,1,1,2,2,4,4,
+ 5,4,4,2,1,2,3,3,1,3,3,1,3,1,4,
+ 0,2,1,2,4,1,1,2,5,5,7,7,7,7,2,
+ 2,3,2,2,3,1,2,1,2,1,1,2,2,1,1,
+ 1,1,1,3,3,4,1,3,4,0,1,2,1,1,1,
+ 1,2,3,4,0,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,
+ 2,1,1,1,1,1,1,1,5,7,7,6,2,3,3,
+ 4,1,2,2,1,2,3,2,5,5,7,9,9,1,1,
+ 1,1,3,2,3,2,3,3,3,5,1,3,4,1,2,
+ 5,2,1,1,1,1,1,1,3,1,1,3,3,3,3,
+ 3,1,1,5,6,8,7,2,0,2,0,1,3,4,4,
+ 1,2,3,2,1,1,2,2,3,3,4,6,6,4,4,
+ 1,1,1,1,2,2,0,1,1,3,3,1,3,3,1,
+ 3,3,1,5,5,4,1,3,3,3,1,3,3,1,3,
+ 3,3,1,3,3,3,3,3,1,3,3,1,3,1,3,
+ 1,3,1,3,1,3,1,5,1,1,3,3,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,1,0,1,0,1,0,1,0,1,0,1,0,2,0,
+ 1,0,1,0,1,0,1,0,1,0,1,0,1,0,2,
+ 0,0,1,0,1,0,1,0,1,0,1
+ };
public static char asb[] = null;
public static char asr[] = null;
public static char symbol_index[] = null;
- private static final String UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$
-
- public final static String name[] = { null,
- "++", //$NON-NLS-1$
- "--", //$NON-NLS-1$
- "==", //$NON-NLS-1$
- "<=", //$NON-NLS-1$
- ">=", //$NON-NLS-1$
- "!=", //$NON-NLS-1$
- "<<", //$NON-NLS-1$
- ">>", //$NON-NLS-1$
- ">>>", //$NON-NLS-1$
- "+=", //$NON-NLS-1$
- "-=", //$NON-NLS-1$
- "*=", //$NON-NLS-1$
- "/=", //$NON-NLS-1$
- "&=", //$NON-NLS-1$
- "|=", //$NON-NLS-1$
- "^=", //$NON-NLS-1$
- "%=", //$NON-NLS-1$
- "<<=", //$NON-NLS-1$
- ">>=", //$NON-NLS-1$
- ">>>=", //$NON-NLS-1$
- "||", //$NON-NLS-1$
- "&&", //$NON-NLS-1$
- "+", //$NON-NLS-1$
- "-", //$NON-NLS-1$
- "!", //$NON-NLS-1$
- "%", //$NON-NLS-1$
- "^", //$NON-NLS-1$
- "&", //$NON-NLS-1$
- "*", //$NON-NLS-1$
- "|", //$NON-NLS-1$
- "~", //$NON-NLS-1$
- "/", //$NON-NLS-1$
- ">", //$NON-NLS-1$
- "<", //$NON-NLS-1$
- "(", //$NON-NLS-1$
- ")", //$NON-NLS-1$
- "{", //$NON-NLS-1$
- "}", //$NON-NLS-1$
- "[", //$NON-NLS-1$
- "]", //$NON-NLS-1$
- ";", //$NON-NLS-1$
- "?", //$NON-NLS-1$
- ":", //$NON-NLS-1$
- ",", //$NON-NLS-1$
- ".", //$NON-NLS-1$
- "=", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "$empty", //$NON-NLS-1$
- "Identifier", //$NON-NLS-1$
- "abstract", //$NON-NLS-1$
- "assert", //$NON-NLS-1$
- "boolean", //$NON-NLS-1$
- "break", //$NON-NLS-1$
- "byte", //$NON-NLS-1$
- "case", //$NON-NLS-1$
- "catch", //$NON-NLS-1$
- "char", //$NON-NLS-1$
- "class", //$NON-NLS-1$
- "continue", //$NON-NLS-1$
- "default", //$NON-NLS-1$
- "do", //$NON-NLS-1$
- "double", //$NON-NLS-1$
- "else", //$NON-NLS-1$
- "extends", //$NON-NLS-1$
- "false", //$NON-NLS-1$
- "final", //$NON-NLS-1$
- "finally", //$NON-NLS-1$
- "float", //$NON-NLS-1$
- "for", //$NON-NLS-1$
- "if", //$NON-NLS-1$
- "implements", //$NON-NLS-1$
- "import", //$NON-NLS-1$
- "instanceof", //$NON-NLS-1$
- "int", //$NON-NLS-1$
- "interface", //$NON-NLS-1$
- "long", //$NON-NLS-1$
- "native", //$NON-NLS-1$
- "new", //$NON-NLS-1$
- "null", //$NON-NLS-1$
- "package", //$NON-NLS-1$
- "private", //$NON-NLS-1$
- "protected", //$NON-NLS-1$
- "public", //$NON-NLS-1$
- "return", //$NON-NLS-1$
- "short", //$NON-NLS-1$
- "static", //$NON-NLS-1$
- "strictfp", //$NON-NLS-1$
- "super", //$NON-NLS-1$
- "switch", //$NON-NLS-1$
- "synchronized", //$NON-NLS-1$
- "this", //$NON-NLS-1$
- "throw", //$NON-NLS-1$
- "throws", //$NON-NLS-1$
- "transient", //$NON-NLS-1$
- "true", //$NON-NLS-1$
- "try", //$NON-NLS-1$
- "void", //$NON-NLS-1$
- "volatile", //$NON-NLS-1$
- "while", //$NON-NLS-1$
- "IntegerLiteral", //$NON-NLS-1$
- "LongLiteral", //$NON-NLS-1$
- "FloatingPointLiteral", //$NON-NLS-1$
- "DoubleLiteral", //$NON-NLS-1$
- "CharacterLiteral", //$NON-NLS-1$
- "StringLiteral", //$NON-NLS-1$
- UNEXPECTED_EOF,
- "Invalid Character", //$NON-NLS-1$
- "Goal", //$NON-NLS-1$
- "MethodBody", //$NON-NLS-1$
- "ConstructorBody", //$NON-NLS-1$
- "StaticInitializer", //$NON-NLS-1$
- "Initializer", //$NON-NLS-1$
- "Headers", //$NON-NLS-1$
- "BlockStatements", //$NON-NLS-1$
- "MethodPushModifiersHeader", //$NON-NLS-1$
- "CatchHeader", //$NON-NLS-1$
- "FieldDeclaration", //$NON-NLS-1$
- "ImportDeclaration", //$NON-NLS-1$
- "PackageDeclaration", //$NON-NLS-1$
- "TypeDeclaration", //$NON-NLS-1$
- "GenericMethodDeclaration", //$NON-NLS-1$
- "ClassBodyDeclaration", //$NON-NLS-1$
- "Expression", //$NON-NLS-1$
- "Type", //$NON-NLS-1$
- "PrimitiveType", //$NON-NLS-1$
- "ReferenceType", //$NON-NLS-1$
- "ClassOrInterfaceType", //$NON-NLS-1$
- "ArrayType", //$NON-NLS-1$
- "Name", //$NON-NLS-1$
- "Dims", //$NON-NLS-1$
- "ClassType", //$NON-NLS-1$
- "SimpleName", //$NON-NLS-1$
- "Header", //$NON-NLS-1$
- "ClassHeader", //$NON-NLS-1$
- "InterfaceHeader", //$NON-NLS-1$
- "MethodHeader", //$NON-NLS-1$
- "ConstructorHeader", //$NON-NLS-1$
- "FormalParameter", //$NON-NLS-1$
- "ImportDeclarations", //$NON-NLS-1$
- "TypeDeclarations", //$NON-NLS-1$
- "PackageDeclarationName", //$NON-NLS-1$
- "SingleTypeImportDeclarationName", //$NON-NLS-1$
- "TypeImportOnDemandDeclarationName", //$NON-NLS-1$
- "Modifiers", //$NON-NLS-1$
- "Modifier", //$NON-NLS-1$
- "ClassBody", //$NON-NLS-1$
- "ClassHeaderName", //$NON-NLS-1$
- "InterfaceTypeList", //$NON-NLS-1$
- "InterfaceType", //$NON-NLS-1$
- "ClassBodyDeclarations", //$NON-NLS-1$
- "Block", //$NON-NLS-1$
- "VariableDeclarators", //$NON-NLS-1$
- "VariableDeclarator", //$NON-NLS-1$
- "VariableDeclaratorId", //$NON-NLS-1$
- "VariableInitializer", //$NON-NLS-1$
- "ArrayInitializer", //$NON-NLS-1$
- "MethodHeaderName", //$NON-NLS-1$
- "MethodHeaderParameters", //$NON-NLS-1$
- "MethodPushModifiersHeaderName", //$NON-NLS-1$
- "ClassTypeList", //$NON-NLS-1$
- "ConstructorHeaderName", //$NON-NLS-1$
- "FormalParameterList", //$NON-NLS-1$
- "ClassTypeElt", //$NON-NLS-1$
- "StaticOnly", //$NON-NLS-1$
- "ExplicitConstructorInvocation", //$NON-NLS-1$
- "Primary", //$NON-NLS-1$
- "InterfaceBody", //$NON-NLS-1$
- "InterfaceHeaderName", //$NON-NLS-1$
- "InterfaceMemberDeclarations", //$NON-NLS-1$
- "InterfaceMemberDeclaration", //$NON-NLS-1$
- "VariableInitializers", //$NON-NLS-1$
- "BlockStatement", //$NON-NLS-1$
- "Statement", //$NON-NLS-1$
- "LocalVariableDeclaration", //$NON-NLS-1$
- "StatementWithoutTrailingSubstatement", //$NON-NLS-1$
- "StatementNoShortIf", //$NON-NLS-1$
- "StatementExpression", //$NON-NLS-1$
- "PostIncrementExpression", //$NON-NLS-1$
- "PostDecrementExpression", //$NON-NLS-1$
- "MethodInvocation", //$NON-NLS-1$
- "ClassInstanceCreationExpression", //$NON-NLS-1$
- "SwitchBlock", //$NON-NLS-1$
- "SwitchBlockStatements", //$NON-NLS-1$
- "SwitchLabels", //$NON-NLS-1$
- "SwitchBlockStatement", //$NON-NLS-1$
- "SwitchLabel", //$NON-NLS-1$
- "ConstantExpression", //$NON-NLS-1$
- "StatementExpressionList", //$NON-NLS-1$
- "OnlySynchronized", //$NON-NLS-1$
- "Catches", //$NON-NLS-1$
- "Finally", //$NON-NLS-1$
- "CatchClause", //$NON-NLS-1$
- "PushLPAREN", //$NON-NLS-1$
- "PushRPAREN", //$NON-NLS-1$
- "PrimaryNoNewArray", //$NON-NLS-1$
- "FieldAccess", //$NON-NLS-1$
- "ArrayAccess", //$NON-NLS-1$
- "ClassInstanceCreationExpressionName", //$NON-NLS-1$
- "ArgumentList", //$NON-NLS-1$
- "DimWithOrWithOutExprs", //$NON-NLS-1$
- "DimWithOrWithOutExpr", //$NON-NLS-1$
- "DimsLoop", //$NON-NLS-1$
- "OneDimLoop", //$NON-NLS-1$
- "PostfixExpression", //$NON-NLS-1$
- "UnaryExpression", //$NON-NLS-1$
- "UnaryExpressionNotPlusMinus", //$NON-NLS-1$
- "MultiplicativeExpression", //$NON-NLS-1$
- "AdditiveExpression", //$NON-NLS-1$
- "ShiftExpression", //$NON-NLS-1$
- "RelationalExpression", //$NON-NLS-1$
- "EqualityExpression", //$NON-NLS-1$
- "AndExpression", //$NON-NLS-1$
- "ExclusiveOrExpression", //$NON-NLS-1$
- "InclusiveOrExpression", //$NON-NLS-1$
- "ConditionalAndExpression", //$NON-NLS-1$
- "ConditionalOrExpression", //$NON-NLS-1$
- "ConditionalExpression", //$NON-NLS-1$
- "AssignmentExpression", //$NON-NLS-1$
- "LeftHandSide", //$NON-NLS-1$
- "AssignmentOperator" //$NON-NLS-1$
- };
-
+ private static final String UNEXPECTED_EOF = "Unexpected End Of File"/*nonNLS*/ ;
+
+ public final static String name[] = { null,
+ "++"/*nonNLS*/,
+ "--"/*nonNLS*/,
+ "=="/*nonNLS*/,
+ "<="/*nonNLS*/,
+ ">="/*nonNLS*/,
+ "!="/*nonNLS*/,
+ "<<"/*nonNLS*/,
+ ">>"/*nonNLS*/,
+ ">>>"/*nonNLS*/,
+ "+="/*nonNLS*/,
+ "-="/*nonNLS*/,
+ "*="/*nonNLS*/,
+ "/="/*nonNLS*/,
+ "&="/*nonNLS*/,
+ "|="/*nonNLS*/,
+ "^="/*nonNLS*/,
+ "%="/*nonNLS*/,
+ "<<="/*nonNLS*/,
+ ">>="/*nonNLS*/,
+ ">>>="/*nonNLS*/,
+ "||"/*nonNLS*/,
+ "&&"/*nonNLS*/,
+ "+"/*nonNLS*/,
+ "-"/*nonNLS*/,
+ "!"/*nonNLS*/,
+ "%"/*nonNLS*/,
+ "^"/*nonNLS*/,
+ "&"/*nonNLS*/,
+ "*"/*nonNLS*/,
+ "|"/*nonNLS*/,
+ "~"/*nonNLS*/,
+ "/"/*nonNLS*/,
+ ">"/*nonNLS*/,
+ "<"/*nonNLS*/,
+ "("/*nonNLS*/,
+ ")"/*nonNLS*/,
+ "{"/*nonNLS*/,
+ "}"/*nonNLS*/,
+ "["/*nonNLS*/,
+ "]"/*nonNLS*/,
+ ";"/*nonNLS*/,
+ "?"/*nonNLS*/,
+ ":"/*nonNLS*/,
+ ","/*nonNLS*/,
+ "."/*nonNLS*/,
+ "="/*nonNLS*/,
+ ""/*nonNLS*/,
+ "$empty"/*nonNLS*/,
+ "Identifier"/*nonNLS*/,
+ "abstract"/*nonNLS*/,
+ "boolean"/*nonNLS*/,
+ "break"/*nonNLS*/,
+ "byte"/*nonNLS*/,
+ "case"/*nonNLS*/,
+ "catch"/*nonNLS*/,
+ "char"/*nonNLS*/,
+ "class"/*nonNLS*/,
+ "continue"/*nonNLS*/,
+ "default"/*nonNLS*/,
+ "do"/*nonNLS*/,
+ "double"/*nonNLS*/,
+ "else"/*nonNLS*/,
+ "extends"/*nonNLS*/,
+ "false"/*nonNLS*/,
+ "final"/*nonNLS*/,
+ "finally"/*nonNLS*/,
+ "float"/*nonNLS*/,
+ "for"/*nonNLS*/,
+ "if"/*nonNLS*/,
+ "implements"/*nonNLS*/,
+ "import"/*nonNLS*/,
+ "instanceof"/*nonNLS*/,
+ "int"/*nonNLS*/,
+ "interface"/*nonNLS*/,
+ "long"/*nonNLS*/,
+ "native"/*nonNLS*/,
+ "new"/*nonNLS*/,
+ "null"/*nonNLS*/,
+ "package"/*nonNLS*/,
+ "private"/*nonNLS*/,
+ "protected"/*nonNLS*/,
+ "public"/*nonNLS*/,
+ "return"/*nonNLS*/,
+ "short"/*nonNLS*/,
+ "static"/*nonNLS*/,
+ "strictfp"/*nonNLS*/,
+ "super"/*nonNLS*/,
+ "switch"/*nonNLS*/,
+ "synchronized"/*nonNLS*/,
+ "this"/*nonNLS*/,
+ "throw"/*nonNLS*/,
+ "throws"/*nonNLS*/,
+ "transient"/*nonNLS*/,
+ "true"/*nonNLS*/,
+ "try"/*nonNLS*/,
+ "void"/*nonNLS*/,
+ "volatile"/*nonNLS*/,
+ "while"/*nonNLS*/,
+ "IntegerLiteral"/*nonNLS*/,
+ "LongLiteral"/*nonNLS*/,
+ "FloatingPointLiteral"/*nonNLS*/,
+ "DoubleLiteral"/*nonNLS*/,
+ "CharacterLiteral"/*nonNLS*/,
+ "StringLiteral"/*nonNLS*/,
+ UNEXPECTED_EOF,
+ "Invalid Character"/*nonNLS*/,
+ "Goal"/*nonNLS*/,
+ "MethodBody"/*nonNLS*/,
+ "ConstructorBody"/*nonNLS*/,
+ "StaticInitializer"/*nonNLS*/,
+ "ClassBodyDeclaration"/*nonNLS*/,
+ "Headers"/*nonNLS*/,
+ "BlockStatements"/*nonNLS*/,
+ "MethodPushModifiersHeader"/*nonNLS*/,
+ "CatchHeader"/*nonNLS*/,
+ "FieldDeclaration"/*nonNLS*/,
+ "ImportDeclaration"/*nonNLS*/,
+ "PackageDeclaration"/*nonNLS*/,
+ "TypeDeclaration"/*nonNLS*/,
+ "GenericMethodDeclaration"/*nonNLS*/,
+ "Expression"/*nonNLS*/,
+ "Type"/*nonNLS*/,
+ "PrimitiveType"/*nonNLS*/,
+ "ReferenceType"/*nonNLS*/,
+ "ClassOrInterfaceType"/*nonNLS*/,
+ "ArrayType"/*nonNLS*/,
+ "Name"/*nonNLS*/,
+ "Dims"/*nonNLS*/,
+ "ClassType"/*nonNLS*/,
+ "SimpleName"/*nonNLS*/,
+ "Header"/*nonNLS*/,
+ "ClassHeader"/*nonNLS*/,
+ "InterfaceHeader"/*nonNLS*/,
+ "MethodHeader"/*nonNLS*/,
+ "ConstructorHeader"/*nonNLS*/,
+ "FormalParameter"/*nonNLS*/,
+ "ImportDeclarations"/*nonNLS*/,
+ "TypeDeclarations"/*nonNLS*/,
+ "PackageDeclarationName"/*nonNLS*/,
+ "SingleTypeImportDeclarationNam"/*nonNLS*/ +
+ "e"/*nonNLS*/,
+ "TypeImportOnDemandDeclarationN"/*nonNLS*/ +
+ "ame"/*nonNLS*/,
+ "Modifiers"/*nonNLS*/,
+ "Modifier"/*nonNLS*/,
+ "ClassBody"/*nonNLS*/,
+ "ClassHeaderName"/*nonNLS*/,
+ "InterfaceTypeList"/*nonNLS*/,
+ "InterfaceType"/*nonNLS*/,
+ "ClassBodyDeclarations"/*nonNLS*/,
+ "Block"/*nonNLS*/,
+ "VariableDeclarators"/*nonNLS*/,
+ "VariableDeclarator"/*nonNLS*/,
+ "VariableDeclaratorId"/*nonNLS*/,
+ "VariableInitializer"/*nonNLS*/,
+ "ArrayInitializer"/*nonNLS*/,
+ "MethodHeaderName"/*nonNLS*/,
+ "MethodHeaderParameters"/*nonNLS*/,
+ "MethodPushModifiersHeaderName"/*nonNLS*/,
+ "ClassTypeList"/*nonNLS*/,
+ "ConstructorHeaderName"/*nonNLS*/,
+ "FormalParameterList"/*nonNLS*/,
+ "ClassTypeElt"/*nonNLS*/,
+ "StaticOnly"/*nonNLS*/,
+ "ExplicitConstructorInvocation"/*nonNLS*/,
+ "Primary"/*nonNLS*/,
+ "InterfaceBody"/*nonNLS*/,
+ "InterfaceHeaderName"/*nonNLS*/,
+ "InterfaceMemberDeclarations"/*nonNLS*/,
+ "InterfaceMemberDeclaration"/*nonNLS*/,
+ "VariableInitializers"/*nonNLS*/,
+ "BlockStatement"/*nonNLS*/,
+ "Statement"/*nonNLS*/,
+ "LocalVariableDeclaration"/*nonNLS*/,
+ "StatementWithoutTrailingSubsta"/*nonNLS*/ +
+ "tement"/*nonNLS*/,
+ "StatementNoShortIf"/*nonNLS*/,
+ "StatementExpression"/*nonNLS*/,
+ "PostIncrementExpression"/*nonNLS*/,
+ "PostDecrementExpression"/*nonNLS*/,
+ "MethodInvocation"/*nonNLS*/,
+ "ClassInstanceCreationExpressio"/*nonNLS*/ +
+ "n"/*nonNLS*/,
+ "SwitchBlock"/*nonNLS*/,
+ "SwitchBlockStatements"/*nonNLS*/,
+ "SwitchLabels"/*nonNLS*/,
+ "SwitchBlockStatement"/*nonNLS*/,
+ "SwitchLabel"/*nonNLS*/,
+ "ConstantExpression"/*nonNLS*/,
+ "StatementExpressionList"/*nonNLS*/,
+ "OnlySynchronized"/*nonNLS*/,
+ "Catches"/*nonNLS*/,
+ "Finally"/*nonNLS*/,
+ "CatchClause"/*nonNLS*/,
+ "PushLPAREN"/*nonNLS*/,
+ "PushRPAREN"/*nonNLS*/,
+ "PrimaryNoNewArray"/*nonNLS*/,
+ "FieldAccess"/*nonNLS*/,
+ "ArrayAccess"/*nonNLS*/,
+ "ClassInstanceCreationExpressio"/*nonNLS*/ +
+ "nName"/*nonNLS*/,
+ "ArgumentList"/*nonNLS*/,
+ "DimWithOrWithOutExprs"/*nonNLS*/,
+ "DimWithOrWithOutExpr"/*nonNLS*/,
+ "DimsLoop"/*nonNLS*/,
+ "OneDimLoop"/*nonNLS*/,
+ "PostfixExpression"/*nonNLS*/,
+ "UnaryExpression"/*nonNLS*/,
+ "UnaryExpressionNotPlusMinus"/*nonNLS*/,
+ "MultiplicativeExpression"/*nonNLS*/,
+ "AdditiveExpression"/*nonNLS*/,
+ "ShiftExpression"/*nonNLS*/,
+ "RelationalExpression"/*nonNLS*/,
+ "EqualityExpression"/*nonNLS*/,
+ "AndExpression"/*nonNLS*/,
+ "ExclusiveOrExpression"/*nonNLS*/,
+ "InclusiveOrExpression"/*nonNLS*/,
+ "ConditionalAndExpression"/*nonNLS*/,
+ "ConditionalOrExpression"/*nonNLS*/,
+ "ConditionalExpression"/*nonNLS*/,
+ "AssignmentExpression"/*nonNLS*/,
+ "LeftHandSide"/*nonNLS*/,
+ "AssignmentOperator"/*nonNLS*/
+ };
+
public static short check_table[] = null;
public static char lhs[] = null;
public static char action[] = lhs;
- private final static String FILEPREFIX = "parser"; //$NON-NLS-1$
+ private final static String FILEPREFIX = "parser"/*nonNLS*/;
static {
try{
@@ -363,13 +363,9 @@ public Parser(ProblemReporter problemReporter) {
this(problemReporter, false);
}
public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
- this(problemReporter, false, false);
-}
-public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals, boolean assertMode) {
this.problemReporter = problemReporter;
this.optimizeStringLiterals = optimizeStringLiterals;
- this.assertMode = assertMode;
this.initializeScanner();
astLengthStack = new int[50];
expressionLengthStack = new int[30];
@@ -432,7 +428,7 @@ private final static void buildFileFor(String filename, String tag, String[] tok
char[] chars = new char[tokens.length]; //can't be bigger
int ic = 0;
String token;
- while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
+ while (!(token = tokens[i++]).equals("}"/*nonNLS*/)) {
int c = Integer.parseInt(token);
if (isShort)
c += 32768;
@@ -475,11 +471,11 @@ public final static void buildFilesFromLPG(String dataFilename) throws java.io.I
reader.read(contents, 0, contents.length);
reader.close();
} catch (IOException ex) {
- System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$
+ System.out.println(Util.bind("parser.incorrectPath"/*nonNLS*/));
return;
}
java.util.StringTokenizer st =
- new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;"); //$NON-NLS-1$
+ new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;"/*nonNLS*/);
String[] tokens = new String[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
@@ -487,12 +483,12 @@ public final static void buildFilesFromLPG(String dataFilename) throws java.io.I
}
final String prefix = FILEPREFIX;
i = 0;
- buildFileFor(prefix + (++i) + ".rsc", "lhs", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileFor(prefix + (++i) + ".rsc", "check_table", tokens, true); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileFor(prefix + (++i) + ".rsc", "asb", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileFor(prefix + (++i) + ".rsc", "asr", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$
- buildFileFor(prefix + (++i) + ".rsc", "symbol_index", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$
- System.out.println(Util.bind("parser.moveFiles")); //$NON-NLS-1$
+ buildFileFor(prefix + (++i) + ".rsc"/*nonNLS*/, "lhs"/*nonNLS*/, tokens, false);
+ buildFileFor(prefix + (++i) + ".rsc"/*nonNLS*/, "check_table"/*nonNLS*/, tokens, true);
+ buildFileFor(prefix + (++i) + ".rsc"/*nonNLS*/, "asb"/*nonNLS*/, tokens, false);
+ buildFileFor(prefix + (++i) + ".rsc"/*nonNLS*/, "asr"/*nonNLS*/, tokens, false);
+ buildFileFor(prefix + (++i) + ".rsc"/*nonNLS*/, "symbol_index"/*nonNLS*/, tokens, false);
+ System.out.println(Util.bind("parser.moveFiles"/*nonNLS*/));
}
/*
* Build initial recovery state.
@@ -537,8 +533,7 @@ public RecoveredElement buildInitialRecoveryState(){
TypeDeclaration type = (TypeDeclaration) referenceContext;
for (int i = 0; i < type.fields.length; i++){
FieldDeclaration field = type.fields[i];
- if (!field.isField()
- && field.declarationSourceStart <= scanner.initialPosition
+ if (field.declarationSourceStart <= scanner.initialPosition
&& scanner.initialPosition <= field.declarationSourceEnd
&& scanner.eofPosition <= field.declarationSourceEnd+1){
element = new RecoveredInitializer((Initializer) field, null, 1, this);
@@ -618,8 +613,8 @@ protected static short check(int i) {
*/
public boolean checkAndReportBracketAnomalies(ProblemReporter problemReporter) {
- scanner.wasAcr = false;
boolean anomaliesDetected = false;
+ this.scanner.wasAcr = false;
try {
char[] source = scanner.source;
int[] leftCount = {0, 0, 0};
@@ -1148,13 +1143,6 @@ protected void consumeArrayInitializer() {
arrayInitializer(expressionLengthStack[expressionLengthPtr--]);
}
-
-protected void consumeAssertStatement() {
- // AssertStatement ::= 'assert' Expression ':' Expression ';'
- expressionLengthPtr-=2;
- pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], expressionStack[expressionPtr--], intStack[intPtr--]));
-}
-
protected void consumeAssignment() {
// Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
//optimize the push/pop
@@ -1391,9 +1379,6 @@ protected void consumeClassDeclaration() {
}
//always add <clinit> (will be remove at code gen time if empty)
- if (this.scanner.containsAssertKeyword) {
- typeDecl.bits |= Statement.AddAssertionMASK;
- }
typeDecl.addClinit();
typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition);
}
@@ -2132,9 +2117,6 @@ protected void consumeInterfaceDeclaration() {
typeDecl.checkConstructors(this);
//always add <clinit> (will be remove at code gen time if empty)
- if (this.scanner.containsAssertKeyword) {
- typeDecl.bits |= Statement.AddAssertionMASK;
- }
typeDecl.addClinit();
typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition);
}
@@ -2717,678 +2699,662 @@ protected void consumeRightParen() {
// PushRPAREN ::= ')'
pushOnIntStack(rParenPos);
}
- // This method is part of an automatic generation : do NOT edit-modify
- protected void consumeRule(int act) {
- switch (act) {
- case 29 : // System.out.println("Type ::= PrimitiveType");
- consumePrimitiveType();
- break;
- case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType");
- consumeReferenceType();
- break;
- case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName");
- consumeQualifiedName();
- break;
- case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt");
- consumeCompilationUnit();
- break;
- case 54 : // System.out.println("EnterCompilationUnit ::=");
- consumeEnterCompilationUnit();
- break;
- case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE");
- consumeCatchHeader();
- break;
- case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration");
- consumeImportDeclarations();
- break;
- case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration");
- consumeTypeDeclarations();
- break;
- case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON");
- consumePackageDeclaration();
- break;
- case 72 : // System.out.println("PackageDeclarationName ::= package Name");
- consumePackageDeclarationName();
- break;
- case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON");
- consumeSingleTypeImportDeclaration();
- break;
- case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name");
- consumeSingleTypeImportDeclarationName();
- break;
- case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON");
- consumeTypeImportOnDemandDeclaration();
- break;
- case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY");
- consumeTypeImportOnDemandDeclarationName();
- break;
- case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON");
- consumeEmptyTypeDeclaration();
- break;
- case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody");
- consumeClassDeclaration();
- break;
- case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt");
- consumeClassHeader();
- break;
- case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier");
- consumeClassHeaderName();
- break;
- case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType");
- consumeClassHeaderExtends();
- break;
- case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList");
- consumeClassHeaderImplements();
- break;
- case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType");
- consumeInterfaceTypeList();
- break;
- case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType");
- consumeInterfaceType();
- break;
- case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration");
- consumeClassBodyDeclarations();
- break;
- case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block");
- consumeClassBodyDeclaration();
- break;
- case 110 : // System.out.println("Diet ::=");
- consumeDiet();
- break;
- case 111 : // System.out.println("Initializer ::= Diet NestedMethod Block");
- consumeClassBodyDeclaration();
- break;
- case 118 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON");
- consumeEmptyClassMemberDeclaration();
- break;
- case 119 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON");
- consumeFieldDeclaration();
- break;
- case 121 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator");
- consumeVariableDeclarators();
- break;
- case 124 : // System.out.println("EnterVariable ::=");
- consumeEnterVariable();
- break;
- case 125 : // System.out.println("ExitVariableWithInitialization ::=");
- consumeExitVariableWithInitialization();
- break;
- case 126 : // System.out.println("ExitVariableWithoutInitialization ::=");
- consumeExitVariableWithoutInitialization();
- break;
- case 127 : // System.out.println("ForceNoDiet ::=");
- consumeForceNoDiet();
- break;
- case 128 : // System.out.println("RestoreDiet ::=");
- consumeRestoreDiet();
- break;
- case 133 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody");
- // set to true to consume a method with a body
- consumeMethodDeclaration(true);
- break;
- case 134 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON");
- // set to false to consume a method without body
- consumeMethodDeclaration(false);
- break;
- case 135 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims");
- consumeMethodHeader();
- break;
- case 136 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters");
- consumeMethodHeader();
- break;
- case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN");
- consumeMethodPushModifiersHeaderName();
- break;
- case 138 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN");
- consumeMethodPushModifiersHeaderName();
- break;
- case 139 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN");
- consumeMethodHeaderName();
- break;
- case 140 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN");
- consumeMethodHeaderParameters();
- break;
- case 141 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt");
- consumeMethodHeaderExtendedDims();
- break;
- case 142 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList");
- consumeMethodHeaderThrowsClause();
- break;
- case 143 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters...");
- consumeConstructorHeader();
- break;
- case 144 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN");
- consumeConstructorHeaderName();
- break;
- case 146 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter");
- consumeFormalParameterList();
- break;
- case 147 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId");
- // the boolean is used to know if the modifiers should be reset
- consumeFormalParameter();
- break;
- case 149 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt");
- consumeClassTypeList();
- break;
- case 150 : // System.out.println("ClassTypeElt ::= ClassType");
- consumeClassTypeElt();
- break;
- case 151 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE");
- consumeMethodBody();
- break;
- case 152 : // System.out.println("NestedMethod ::=");
- consumeNestedMethod();
- break;
- case 153 : // System.out.println("StaticInitializer ::= StaticOnly Block");
- consumeStaticInitializer();
- break;
- case 154 : // System.out.println("StaticOnly ::= static");
- consumeStaticOnly();
- break;
- case 155 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody");
- consumeConstructorDeclaration();
- break;
- case 156 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE");
- consumeConstructorBody();
- break;
- case 159 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements");
- consumeConstructorBlockStatements();
- break;
- case 160 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON");
- consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.This);
- break;
- case 161 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON");
- consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.Super);
- break;
- case 162 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN");
- consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super);
- break;
- case 163 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super);
- break;
- case 164 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This);
- break;
- case 165 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This);
- break;
- case 166 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody");
- consumeInterfaceDeclaration();
- break;
- case 167 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt");
- consumeInterfaceHeader();
- break;
- case 168 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier");
- consumeInterfaceHeaderName();
- break;
- case 170 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList");
- consumeInterfaceHeaderExtends();
- break;
- case 173 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations...");
- consumeInterfaceMemberDeclarations();
- break;
- case 174 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON");
- consumeEmptyInterfaceMemberDeclaration();
- break;
- case 177 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration");
- ignoreMethodBody();
- break;
- case 178 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody");
- ignoreInvalidConstructorDeclaration(true);
- break;
- case 179 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON");
- ignoreInvalidConstructorDeclaration(false);
- break;
- case 185 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE");
- consumeEmptyArrayInitializer();
- break;
- case 186 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE");
- consumeArrayInitializer();
- break;
- case 187 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE");
- consumeArrayInitializer();
- break;
- case 189 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer");
- consumeVariableInitializers();
- break;
- case 190 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE");
- consumeBlock();
- break;
- case 191 : // System.out.println("OpenBlock ::=");
- consumeOpenBlock();
- break;
- case 193 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement");
- consumeBlockStatements();
- break;
- case 197 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration");
- ignoreInterfaceDeclaration();
- break;
- case 198 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON");
- consumeLocalVariableDeclarationStatement();
- break;
- case 199 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators");
- consumeLocalVariableDeclaration();
- break;
- case 200 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators");
- consumeLocalVariableDeclaration();
- break;
- case 201 : // System.out.println("PushModifiers ::=");
- consumePushModifiers();
- break;
- case 225 : // System.out.println("EmptyStatement ::= SEMICOLON");
- consumeEmptyStatement();
- break;
- case 226 : // System.out.println("LabeledStatement ::= Identifier COLON Statement");
- consumeStatementLabel();
- break;
- case 227 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf");
- consumeStatementLabel();
- break;
- case 228 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON");
- consumeExpressionStatement();
- break;
- case 236 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement");
- consumeStatementIfNoElse();
- break;
- case 237 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else...");
- consumeStatementIfWithElse();
- break;
- case 238 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf...");
- consumeStatementIfWithElse();
- break;
- case 239 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock");
- consumeStatementSwitch();
- break;
- case 240 : // System.out.println("SwitchBlock ::= LBRACE RBRACE");
- consumeEmptySwitchBlock();
- break;
- case 243 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE");
- consumeSwitchBlock();
- break;
- case 245 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement");
- consumeSwitchBlockStatements();
- break;
- case 246 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements");
- consumeSwitchBlockStatement();
- break;
- case 248 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel");
- consumeSwitchLabels();
- break;
- case 249 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON");
- consumeCaseLabel();
- break;
- case 250 : // System.out.println("SwitchLabel ::= default COLON");
- consumeDefaultLabel();
- break;
- case 251 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement");
- consumeStatementWhile();
- break;
- case 252 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf");
- consumeStatementWhile();
- break;
- case 253 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON");
- consumeStatementDo();
- break;
- case 254 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON...");
- consumeStatementFor();
- break;
- case 255 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON");
- consumeStatementFor();
- break;
- case 256 : // System.out.println("ForInit ::= StatementExpressionList");
- consumeForInit();
- break;
- case 260 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression");
- consumeStatementExpressionList();
- break;
- case 261 : // System.out.println("AssertStatement ::= assert Expression SEMICOLON");
- consumeSimpleAssertStatement();
- break;
- case 262 : // System.out.println("AssertStatement ::= assert Expression COLON Expression SEMICOLON");
- consumeAssertStatement();
- break;
- case 263 : // System.out.println("BreakStatement ::= break SEMICOLON");
- consumeStatementBreak();
- break;
- case 264 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON");
- consumeStatementBreakWithLabel();
- break;
- case 265 : // System.out.println("ContinueStatement ::= continue SEMICOLON");
- consumeStatementContinue();
- break;
- case 266 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON");
- consumeStatementContinueWithLabel();
- break;
- case 267 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON");
- consumeStatementReturn();
- break;
- case 268 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON");
- consumeStatementThrow();
- break;
- case 269 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block");
- consumeStatementSynchronized();
- break;
- case 270 : // System.out.println("OnlySynchronized ::= synchronized");
- consumeOnlySynchronized();
- break;
- case 271 : // System.out.println("TryStatement ::= try Block Catches");
- consumeStatementTry(false);
- break;
- case 272 : // System.out.println("TryStatement ::= try Block Catchesopt Finally");
- consumeStatementTry(true);
- break;
- case 274 : // System.out.println("Catches ::= Catches CatchClause");
- consumeCatches();
- break;
- case 275 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block");
- consumeStatementCatch();
- break;
- case 277 : // System.out.println("PushLPAREN ::= LPAREN");
- consumeLeftParen();
- break;
- case 278 : // System.out.println("PushRPAREN ::= RPAREN");
- consumeRightParen();
- break;
- case 282 : // System.out.println("PrimaryNoNewArray ::= this");
- consumePrimaryNoNewArrayThis();
- break;
- case 283 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN");
- consumePrimaryNoNewArray();
- break;
- case 286 : // System.out.println("PrimaryNoNewArray ::= Name DOT this");
- consumePrimaryNoNewArrayNameThis();
- break;
- case 287 : // System.out.println("PrimaryNoNewArray ::= Name DOT super");
- consumePrimaryNoNewArrayNameSuper();
- break;
- case 288 : // System.out.println("PrimaryNoNewArray ::= Name DOT class");
- consumePrimaryNoNewArrayName();
- break;
- case 289 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class");
- consumePrimaryNoNewArrayArrayType();
- break;
- case 290 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class");
- consumePrimaryNoNewArrayPrimitiveType();
- break;
- case 293 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN");
- consumeAllocationHeader();
- break;
- case 294 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN...");
- consumeClassInstanceCreationExpression();
- break;
- case 295 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN...");
- consumeClassInstanceCreationExpressionQualified();
- break;
- case 296 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new...");
- consumeClassInstanceCreationExpressionQualified();
- break;
- case 297 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT");
- consumeClassInstanceCreationExpressionName();
- break;
- case 298 : // System.out.println("ClassBodyopt ::=");
- consumeClassBodyopt();
- break;
- case 300 : // System.out.println("EnterAnonymousClassBody ::=");
- consumeEnterAnonymousClassBody();
- break;
- case 302 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression");
- consumeArgumentList();
- break;
- case 303 : // System.out.println("ArrayCreationExpression ::= new PrimitiveType DimWithOrWithOutExprs...");
- consumeArrayCreationExpression();
- break;
- case 304 : // System.out.println("ArrayCreationExpression ::= new ClassOrInterfaceType DimWithOrWithOutExprs...");
- consumeArrayCreationExpression();
- break;
- case 306 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr");
- consumeDimWithOrWithOutExprs();
- break;
- case 308 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET");
- consumeDimWithOrWithOutExpr();
- break;
- case 309 : // System.out.println("Dims ::= DimsLoop");
- consumeDims();
- break;
- case 312 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET");
- consumeOneDimLoop();
- break;
- case 313 : // System.out.println("FieldAccess ::= Primary DOT Identifier");
- consumeFieldAccess(false);
- break;
- case 314 : // System.out.println("FieldAccess ::= super DOT Identifier");
- consumeFieldAccess(true);
- break;
- case 315 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationName();
- break;
- case 316 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationPrimary();
- break;
- case 317 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationSuper();
- break;
- case 318 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET");
- consumeArrayAccess(true);
- break;
- case 319 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET");
- consumeArrayAccess(false);
- break;
- case 321 : // System.out.println("PostfixExpression ::= Name");
- consumePostfixExpression();
- break;
- case 324 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS");
- consumeUnaryExpression(OperatorExpression.PLUS, true);
- break;
- case 325 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS");
- consumeUnaryExpression(OperatorExpression.MINUS, true);
- break;
- case 326 : // System.out.println("PushPosition ::=");
- consumePushPosition();
- break;
- case 329 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.PLUS);
- break;
- case 330 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.MINUS);
- break;
- case 332 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.PLUS, false);
- break;
- case 333 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.MINUS, false);
- break;
- case 335 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.TWIDDLE);
- break;
- case 336 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.NOT);
- break;
- case 338 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression");
- consumeCastExpression();
- break;
- case 339 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus");
- consumeCastExpression();
- break;
- case 340 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus");
- consumeCastExpressionLL1();
- break;
- case 342 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression");
- consumeBinaryExpression(OperatorExpression.MULTIPLY);
- break;
- case 343 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression");
- consumeBinaryExpression(OperatorExpression.DIVIDE);
- break;
- case 344 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression");
- consumeBinaryExpression(OperatorExpression.REMAINDER);
- break;
- case 346 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression");
- consumeBinaryExpression(OperatorExpression.PLUS);
- break;
- case 347 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression");
- consumeBinaryExpression(OperatorExpression.MINUS);
- break;
- case 349 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.LEFT_SHIFT);
- break;
- case 350 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT);
- break;
- case 351 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT);
- break;
- case 353 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression");
- consumeBinaryExpression(OperatorExpression.LESS);
- break;
- case 354 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression");
- consumeBinaryExpression(OperatorExpression.GREATER);
- break;
- case 355 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression");
- consumeBinaryExpression(OperatorExpression.LESS_EQUAL);
- break;
- case 356 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression");
- consumeBinaryExpression(OperatorExpression.GREATER_EQUAL);
- break;
- case 357 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType");
- consumeInstanceOfExpression(OperatorExpression.INSTANCEOF);
- break;
- case 359 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression");
- consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL);
- break;
- case 360 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression");
- consumeEqualityExpression(OperatorExpression.NOT_EQUAL);
- break;
- case 362 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression");
- consumeBinaryExpression(OperatorExpression.AND);
- break;
- case 364 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression");
- consumeBinaryExpression(OperatorExpression.XOR);
- break;
- case 366 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression");
- consumeBinaryExpression(OperatorExpression.OR);
- break;
- case 368 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression");
- consumeBinaryExpression(OperatorExpression.AND_AND);
- break;
- case 370 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression");
- consumeBinaryExpression(OperatorExpression.OR_OR);
- break;
- case 372 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON...");
- consumeConditionalExpression(OperatorExpression.QUESTIONCOLON);
- break;
- case 375 : // System.out.println("Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression");
- consumeAssignment();
- break;
- case 377 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement");
- ignoreExpressionAssignment();
- break;
- case 378 : // System.out.println("LeftHandSide ::= Name");
- consumeLeftHandSide();
- break;
- case 381 : // System.out.println("AssignmentOperator ::= EQUAL");
- consumeAssignmentOperator(EQUAL);
- break;
- case 382 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL");
- consumeAssignmentOperator(MULTIPLY);
- break;
- case 383 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL");
- consumeAssignmentOperator(DIVIDE);
- break;
- case 384 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL");
- consumeAssignmentOperator(REMAINDER);
- break;
- case 385 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL");
- consumeAssignmentOperator(PLUS);
- break;
- case 386 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL");
- consumeAssignmentOperator(MINUS);
- break;
- case 387 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL");
- consumeAssignmentOperator(LEFT_SHIFT);
- break;
- case 388 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL");
- consumeAssignmentOperator(RIGHT_SHIFT);
- break;
- case 389 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL");
- consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
- break;
- case 390 : // System.out.println("AssignmentOperator ::= AND_EQUAL");
- consumeAssignmentOperator(AND);
- break;
- case 391 : // System.out.println("AssignmentOperator ::= XOR_EQUAL");
- consumeAssignmentOperator(XOR);
- break;
- case 392 : // System.out.println("AssignmentOperator ::= OR_EQUAL");
- consumeAssignmentOperator(OR);
- break;
- case 399 : // System.out.println("Expressionopt ::=");
- consumeEmptyExpression();
- break;
- case 403 : // System.out.println("ImportDeclarationsopt ::=");
- consumeEmptyImportDeclarationsopt();
- break;
- case 404 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations");
- consumeImportDeclarationsopt();
- break;
- case 405 : // System.out.println("TypeDeclarationsopt ::=");
- consumeEmptyTypeDeclarationsopt();
- break;
- case 406 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations");
- consumeTypeDeclarationsopt();
- break;
- case 407 : // System.out.println("ClassBodyDeclarationsopt ::=");
- consumeEmptyClassBodyDeclarationsopt();
- break;
- case 408 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations");
- consumeClassBodyDeclarationsopt();
- break;
- case 409 : // System.out.println("Modifiersopt ::=");
- consumeDefaultModifiers();
- break;
- case 410 : // System.out.println("Modifiersopt ::= Modifiers");
- consumeModifiers();
- break;
- case 411 : // System.out.println("BlockStatementsopt ::=");
- consumeEmptyBlockStatementsopt();
- break;
- case 413 : // System.out.println("Dimsopt ::=");
- consumeEmptyDimsopt();
- break;
- case 415 : // System.out.println("ArgumentListopt ::=");
- consumeEmptyArgumentListopt();
- break;
- case 419 : // System.out.println("FormalParameterListopt ::=");
- consumeFormalParameterListopt();
- break;
- case 423 : // System.out.println("InterfaceMemberDeclarationsopt ::=");
- consumeEmptyInterfaceMemberDeclarationsopt();
- break;
- case 424 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations");
- consumeInterfaceMemberDeclarationsopt();
- break;
- case 425 : // System.out.println("NestedType ::=");
- consumeNestedType();
- break;
- case 426 : // System.out.println("ForInitopt ::=");
- consumeEmptyForInitopt();
- break;
- case 428 : // System.out.println("ForUpdateopt ::=");
- consumeEmptyForUpdateopt();
- break;
- case 432 : // System.out.println("Catchesopt ::=");
- consumeEmptyCatchesopt();
- break;
- case 434 : // System.out.println("ArrayInitializeropt ::=");
- consumeEmptyArrayInitializeropt();
- break;
- }
+// This method is part of an automatic generation : do NOT edit-modify
+protected void consumeRule(int act) {
+ switch (act) {
+ case 29 : // System.out.println("Type ::= PrimitiveType");
+ consumePrimitiveType();
+ break;
+ case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType");
+ consumeReferenceType();
+ break;
+ case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName");
+ consumeQualifiedName();
+ break;
+ case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt");
+ consumeCompilationUnit();
+ break;
+ case 54 : // System.out.println("EnterCompilationUnit ::=");
+ consumeEnterCompilationUnit();
+ break;
+ case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE");
+ consumeCatchHeader();
+ break;
+ case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration");
+ consumeImportDeclarations();
+ break;
+ case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration");
+ consumeTypeDeclarations();
+ break;
+ case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON");
+ consumePackageDeclaration();
+ break;
+ case 72 : // System.out.println("PackageDeclarationName ::= package Name");
+ consumePackageDeclarationName();
+ break;
+ case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON");
+ consumeSingleTypeImportDeclaration();
+ break;
+ case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name");
+ consumeSingleTypeImportDeclarationName();
+ break;
+ case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON");
+ consumeTypeImportOnDemandDeclaration();
+ break;
+ case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY");
+ consumeTypeImportOnDemandDeclarationName();
+ break;
+ case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON");
+ consumeEmptyTypeDeclaration();
+ break;
+ case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody");
+ consumeClassDeclaration();
+ break;
+ case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt");
+ consumeClassHeader();
+ break;
+ case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier");
+ consumeClassHeaderName();
+ break;
+ case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType");
+ consumeClassHeaderExtends();
+ break;
+ case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList");
+ consumeClassHeaderImplements();
+ break;
+ case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType");
+ consumeInterfaceTypeList();
+ break;
+ case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType");
+ consumeInterfaceType();
+ break;
+ case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration");
+ consumeClassBodyDeclarations();
+ break;
+ case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block");
+ consumeClassBodyDeclaration();
+ break;
+ case 110 : // System.out.println("Diet ::=");
+ consumeDiet();
+ break;
+ case 117 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON");
+ consumeEmptyClassMemberDeclaration();
+ break;
+ case 118 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON");
+ consumeFieldDeclaration();
+ break;
+ case 120 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator");
+ consumeVariableDeclarators();
+ break;
+ case 123 : // System.out.println("EnterVariable ::=");
+ consumeEnterVariable();
+ break;
+ case 124 : // System.out.println("ExitVariableWithInitialization ::=");
+ consumeExitVariableWithInitialization();
+ break;
+ case 125 : // System.out.println("ExitVariableWithoutInitialization ::=");
+ consumeExitVariableWithoutInitialization();
+ break;
+ case 126 : // System.out.println("ForceNoDiet ::=");
+ consumeForceNoDiet();
+ break;
+ case 127 : // System.out.println("RestoreDiet ::=");
+ consumeRestoreDiet();
+ break;
+ case 132 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody");
+ // set to true to consume a method with a body
+ consumeMethodDeclaration(true);
+ break;
+ case 133 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON");
+ // set to false to consume a method without body
+ consumeMethodDeclaration(false);
+ break;
+ case 134 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims");
+ consumeMethodHeader();
+ break;
+ case 135 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters");
+ consumeMethodHeader();
+ break;
+ case 136 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN");
+ consumeMethodPushModifiersHeaderName();
+ break;
+ case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN");
+ consumeMethodPushModifiersHeaderName();
+ break;
+ case 138 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN");
+ consumeMethodHeaderName();
+ break;
+ case 139 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN");
+ consumeMethodHeaderParameters();
+ break;
+ case 140 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt");
+ consumeMethodHeaderExtendedDims();
+ break;
+ case 141 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList");
+ consumeMethodHeaderThrowsClause();
+ break;
+ case 142 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters...");
+ consumeConstructorHeader();
+ break;
+ case 143 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN");
+ consumeConstructorHeaderName();
+ break;
+ case 145 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter");
+ consumeFormalParameterList();
+ break;
+ case 146 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId");
+ // the boolean is used to know if the modifiers should be reset
+ consumeFormalParameter();
+ break;
+ case 148 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt");
+ consumeClassTypeList();
+ break;
+ case 149 : // System.out.println("ClassTypeElt ::= ClassType");
+ consumeClassTypeElt();
+ break;
+ case 150 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE");
+ consumeMethodBody();
+ break;
+ case 151 : // System.out.println("NestedMethod ::=");
+ consumeNestedMethod();
+ break;
+ case 152 : // System.out.println("StaticInitializer ::= StaticOnly Block");
+ consumeStaticInitializer();
+ break;
+ case 153 : // System.out.println("StaticOnly ::= static");
+ consumeStaticOnly();
+ break;
+ case 154 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody");
+ consumeConstructorDeclaration();
+ break;
+ case 155 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE");
+ consumeConstructorBody();
+ break;
+ case 158 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements");
+ consumeConstructorBlockStatements();
+ break;
+ case 159 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON");
+ consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.This);
+ break;
+ case 160 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON");
+ consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.Super);
+ break;
+ case 161 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN");
+ consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super);
+ break;
+ case 162 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super);
+ break;
+ case 163 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This);
+ break;
+ case 164 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This);
+ break;
+ case 165 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody");
+ consumeInterfaceDeclaration();
+ break;
+ case 166 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt");
+ consumeInterfaceHeader();
+ break;
+ case 167 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier");
+ consumeInterfaceHeaderName();
+ break;
+ case 169 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList");
+ consumeInterfaceHeaderExtends();
+ break;
+ case 172 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations...");
+ consumeInterfaceMemberDeclarations();
+ break;
+ case 173 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON");
+ consumeEmptyInterfaceMemberDeclaration();
+ break;
+ case 176 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration");
+ ignoreMethodBody();
+ break;
+ case 177 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody");
+ ignoreInvalidConstructorDeclaration(true);
+ break;
+ case 178 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON");
+ ignoreInvalidConstructorDeclaration(false);
+ break;
+ case 184 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE");
+ consumeEmptyArrayInitializer();
+ break;
+ case 185 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE");
+ consumeArrayInitializer();
+ break;
+ case 186 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE");
+ consumeArrayInitializer();
+ break;
+ case 188 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer");
+ consumeVariableInitializers();
+ break;
+ case 189 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE");
+ consumeBlock();
+ break;
+ case 190 : // System.out.println("OpenBlock ::=");
+ consumeOpenBlock();
+ break;
+ case 192 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement");
+ consumeBlockStatements();
+ break;
+ case 196 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration");
+ ignoreInterfaceDeclaration();
+ break;
+ case 197 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON");
+ consumeLocalVariableDeclarationStatement();
+ break;
+ case 198 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators");
+ consumeLocalVariableDeclaration();
+ break;
+ case 199 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators");
+ consumeLocalVariableDeclaration();
+ break;
+ case 200 : // System.out.println("PushModifiers ::=");
+ consumePushModifiers();
+ break;
+ case 223 : // System.out.println("EmptyStatement ::= SEMICOLON");
+ consumeEmptyStatement();
+ break;
+ case 224 : // System.out.println("LabeledStatement ::= Identifier COLON Statement");
+ consumeStatementLabel();
+ break;
+ case 225 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf");
+ consumeStatementLabel();
+ break;
+ case 226 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON");
+ consumeExpressionStatement();
+ break;
+ case 234 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement");
+ consumeStatementIfNoElse();
+ break;
+ case 235 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else...");
+ consumeStatementIfWithElse();
+ break;
+ case 236 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf...");
+ consumeStatementIfWithElse();
+ break;
+ case 237 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock");
+ consumeStatementSwitch();
+ break;
+ case 238 : // System.out.println("SwitchBlock ::= LBRACE RBRACE");
+ consumeEmptySwitchBlock();
+ break;
+ case 241 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE");
+ consumeSwitchBlock();
+ break;
+ case 243 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement");
+ consumeSwitchBlockStatements();
+ break;
+ case 244 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements");
+ consumeSwitchBlockStatement();
+ break;
+ case 246 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel");
+ consumeSwitchLabels();
+ break;
+ case 247 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON");
+ consumeCaseLabel();
+ break;
+ case 248 : // System.out.println("SwitchLabel ::= default COLON");
+ consumeDefaultLabel();
+ break;
+ case 249 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement");
+ consumeStatementWhile();
+ break;
+ case 250 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf");
+ consumeStatementWhile();
+ break;
+ case 251 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON");
+ consumeStatementDo();
+ break;
+ case 252 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON...");
+ consumeStatementFor();
+ break;
+ case 253 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON");
+ consumeStatementFor();
+ break;
+ case 254 : // System.out.println("ForInit ::= StatementExpressionList");
+ consumeForInit();
+ break;
+ case 258 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression");
+ consumeStatementExpressionList();
+ break;
+ case 259 : // System.out.println("BreakStatement ::= break SEMICOLON");
+ consumeStatementBreak();
+ break;
+ case 260 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON");
+ consumeStatementBreakWithLabel();
+ break;
+ case 261 : // System.out.println("ContinueStatement ::= continue SEMICOLON");
+ consumeStatementContinue();
+ break;
+ case 262 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON");
+ consumeStatementContinueWithLabel();
+ break;
+ case 263 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON");
+ consumeStatementReturn();
+ break;
+ case 264 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON");
+ consumeStatementThrow();
+ break;
+ case 265 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block");
+ consumeStatementSynchronized();
+ break;
+ case 266 : // System.out.println("OnlySynchronized ::= synchronized");
+ consumeOnlySynchronized();
+ break;
+ case 267 : // System.out.println("TryStatement ::= try Block Catches");
+ consumeStatementTry(false);
+ break;
+ case 268 : // System.out.println("TryStatement ::= try Block Catchesopt Finally");
+ consumeStatementTry(true);
+ break;
+ case 270 : // System.out.println("Catches ::= Catches CatchClause");
+ consumeCatches();
+ break;
+ case 271 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block");
+ consumeStatementCatch();
+ break;
+ case 273 : // System.out.println("PushLPAREN ::= LPAREN");
+ consumeLeftParen();
+ break;
+ case 274 : // System.out.println("PushRPAREN ::= RPAREN");
+ consumeRightParen();
+ break;
+ case 278 : // System.out.println("PrimaryNoNewArray ::= this");
+ consumePrimaryNoNewArrayThis();
+ break;
+ case 279 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN");
+ consumePrimaryNoNewArray();
+ break;
+ case 282 : // System.out.println("PrimaryNoNewArray ::= Name DOT this");
+ consumePrimaryNoNewArrayNameThis();
+ break;
+ case 283 : // System.out.println("PrimaryNoNewArray ::= Name DOT super");
+ consumePrimaryNoNewArrayNameSuper();
+ break;
+ case 284 : // System.out.println("PrimaryNoNewArray ::= Name DOT class");
+ consumePrimaryNoNewArrayName();
+ break;
+ case 285 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class");
+ consumePrimaryNoNewArrayArrayType();
+ break;
+ case 286 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class");
+ consumePrimaryNoNewArrayPrimitiveType();
+ break;
+ case 289 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN");
+ consumeAllocationHeader();
+ break;
+ case 290 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN...");
+ consumeClassInstanceCreationExpression();
+ break;
+ case 291 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN...");
+ consumeClassInstanceCreationExpressionQualified();
+ break;
+ case 292 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new...");
+ consumeClassInstanceCreationExpressionQualified();
+ break;
+ case 293 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT");
+ consumeClassInstanceCreationExpressionName();
+ break;
+ case 294 : // System.out.println("ClassBodyopt ::=");
+ consumeClassBodyopt();
+ break;
+ case 296 : // System.out.println("EnterAnonymousClassBody ::=");
+ consumeEnterAnonymousClassBody();
+ break;
+ case 298 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression");
+ consumeArgumentList();
+ break;
+ case 299 : // System.out.println("ArrayCreationExpression ::= new PrimitiveType DimWithOrWithOutExprs...");
+ consumeArrayCreationExpression();
+ break;
+ case 300 : // System.out.println("ArrayCreationExpression ::= new ClassOrInterfaceType DimWithOrWithOutExprs...");
+ consumeArrayCreationExpression();
+ break;
+ case 302 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr");
+ consumeDimWithOrWithOutExprs();
+ break;
+ case 304 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET");
+ consumeDimWithOrWithOutExpr();
+ break;
+ case 305 : // System.out.println("Dims ::= DimsLoop");
+ consumeDims();
+ break;
+ case 308 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET");
+ consumeOneDimLoop();
+ break;
+ case 309 : // System.out.println("FieldAccess ::= Primary DOT Identifier");
+ consumeFieldAccess(false);
+ break;
+ case 310 : // System.out.println("FieldAccess ::= super DOT Identifier");
+ consumeFieldAccess(true);
+ break;
+ case 311 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationName();
+ break;
+ case 312 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationPrimary();
+ break;
+ case 313 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationSuper();
+ break;
+ case 314 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET");
+ consumeArrayAccess(true);
+ break;
+ case 315 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET");
+ consumeArrayAccess(false);
+ break;
+ case 317 : // System.out.println("PostfixExpression ::= Name");
+ consumePostfixExpression();
+ break;
+ case 320 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS");
+ consumeUnaryExpression(OperatorExpression.PLUS, true);
+ break;
+ case 321 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS");
+ consumeUnaryExpression(OperatorExpression.MINUS, true);
+ break;
+ case 322 : // System.out.println("PushPosition ::=");
+ consumePushPosition();
+ break;
+ case 325 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.PLUS);
+ break;
+ case 326 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.MINUS);
+ break;
+ case 328 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.PLUS, false);
+ break;
+ case 329 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.MINUS, false);
+ break;
+ case 331 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.TWIDDLE);
+ break;
+ case 332 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.NOT);
+ break;
+ case 334 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression");
+ consumeCastExpression();
+ break;
+ case 335 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus");
+ consumeCastExpression();
+ break;
+ case 336 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus");
+ consumeCastExpressionLL1();
+ break;
+ case 338 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.MULTIPLY);
+ break;
+ case 339 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.DIVIDE);
+ break;
+ case 340 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.REMAINDER);
+ break;
+ case 342 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression");
+ consumeBinaryExpression(OperatorExpression.PLUS);
+ break;
+ case 343 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression");
+ consumeBinaryExpression(OperatorExpression.MINUS);
+ break;
+ case 345 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.LEFT_SHIFT);
+ break;
+ case 346 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT);
+ break;
+ case 347 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT);
+ break;
+ case 349 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.LESS);
+ break;
+ case 350 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.GREATER);
+ break;
+ case 351 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.LESS_EQUAL);
+ break;
+ case 352 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.GREATER_EQUAL);
+ break;
+ case 353 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType");
+ consumeInstanceOfExpression(OperatorExpression.INSTANCEOF);
+ break;
+ case 355 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression");
+ consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL);
+ break;
+ case 356 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression");
+ consumeEqualityExpression(OperatorExpression.NOT_EQUAL);
+ break;
+ case 358 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression");
+ consumeBinaryExpression(OperatorExpression.AND);
+ break;
+ case 360 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression");
+ consumeBinaryExpression(OperatorExpression.XOR);
+ break;
+ case 362 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression");
+ consumeBinaryExpression(OperatorExpression.OR);
+ break;
+ case 364 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression");
+ consumeBinaryExpression(OperatorExpression.AND_AND);
+ break;
+ case 366 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression");
+ consumeBinaryExpression(OperatorExpression.OR_OR);
+ break;
+ case 368 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON...");
+ consumeConditionalExpression(OperatorExpression.QUESTIONCOLON);
+ break;
+ case 371 : // System.out.println("Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression");
+ consumeAssignment();
+ break;
+ case 373 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement");
+ ignoreExpressionAssignment();
+ break;
+ case 374 : // System.out.println("LeftHandSide ::= Name");
+ consumeLeftHandSide();
+ break;
+ case 377 : // System.out.println("AssignmentOperator ::= EQUAL");
+ consumeAssignmentOperator(EQUAL);
+ break;
+ case 378 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL");
+ consumeAssignmentOperator(MULTIPLY);
+ break;
+ case 379 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL");
+ consumeAssignmentOperator(DIVIDE);
+ break;
+ case 380 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL");
+ consumeAssignmentOperator(REMAINDER);
+ break;
+ case 381 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL");
+ consumeAssignmentOperator(PLUS);
+ break;
+ case 382 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL");
+ consumeAssignmentOperator(MINUS);
+ break;
+ case 383 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL");
+ consumeAssignmentOperator(LEFT_SHIFT);
+ break;
+ case 384 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL");
+ consumeAssignmentOperator(RIGHT_SHIFT);
+ break;
+ case 385 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL");
+ consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
+ break;
+ case 386 : // System.out.println("AssignmentOperator ::= AND_EQUAL");
+ consumeAssignmentOperator(AND);
+ break;
+ case 387 : // System.out.println("AssignmentOperator ::= XOR_EQUAL");
+ consumeAssignmentOperator(XOR);
+ break;
+ case 388 : // System.out.println("AssignmentOperator ::= OR_EQUAL");
+ consumeAssignmentOperator(OR);
+ break;
+ case 395 : // System.out.println("Expressionopt ::=");
+ consumeEmptyExpression();
+ break;
+ case 399 : // System.out.println("ImportDeclarationsopt ::=");
+ consumeEmptyImportDeclarationsopt();
+ break;
+ case 400 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations");
+ consumeImportDeclarationsopt();
+ break;
+ case 401 : // System.out.println("TypeDeclarationsopt ::=");
+ consumeEmptyTypeDeclarationsopt();
+ break;
+ case 402 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations");
+ consumeTypeDeclarationsopt();
+ break;
+ case 403 : // System.out.println("ClassBodyDeclarationsopt ::=");
+ consumeEmptyClassBodyDeclarationsopt();
+ break;
+ case 404 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations");
+ consumeClassBodyDeclarationsopt();
+ break;
+ case 405 : // System.out.println("Modifiersopt ::=");
+ consumeDefaultModifiers();
+ break;
+ case 406 : // System.out.println("Modifiersopt ::= Modifiers");
+ consumeModifiers();
+ break;
+ case 407 : // System.out.println("BlockStatementsopt ::=");
+ consumeEmptyBlockStatementsopt();
+ break;
+ case 409 : // System.out.println("Dimsopt ::=");
+ consumeEmptyDimsopt();
+ break;
+ case 411 : // System.out.println("ArgumentListopt ::=");
+ consumeEmptyArgumentListopt();
+ break;
+ case 415 : // System.out.println("FormalParameterListopt ::=");
+ consumeFormalParameterListopt();
+ break;
+ case 419 : // System.out.println("InterfaceMemberDeclarationsopt ::=");
+ consumeEmptyInterfaceMemberDeclarationsopt();
+ break;
+ case 420 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations");
+ consumeInterfaceMemberDeclarationsopt();
+ break;
+ case 421 : // System.out.println("NestedType ::=");
+ consumeNestedType();
+ break;
+ case 422 : // System.out.println("ForInitopt ::=");
+ consumeEmptyForInitopt();
+ break;
+ case 424 : // System.out.println("ForUpdateopt ::=");
+ consumeEmptyForUpdateopt();
+ break;
+ case 428 : // System.out.println("Catchesopt ::=");
+ consumeEmptyCatchesopt();
+ break;
+ case 430 : // System.out.println("ArrayInitializeropt ::=");
+ consumeEmptyArrayInitializeropt();
+ break;
}
-
-protected void consumeSimpleAssertStatement() {
- // AssertStatement ::= 'assert' Expression ';'
- expressionLengthPtr--;
- pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], intStack[intPtr--]));
}
-
protected void consumeSingleTypeImportDeclaration() {
// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
@@ -3840,24 +3806,12 @@ protected void consumeSwitchLabels() {
protected void consumeToken(int type) {
/* remember the last consumed value */
/* try to minimize the number of build values */
- if (scanner.wasNonExternalizedStringLiteral) {
- StringLiteral[] literals = this.scanner.nonNLSStrings;
- for (int i = 0, max = literals.length; i < max; i++) {
- problemReporter().nonExternalizedStringLiteral(literals[i]);
- }
- scanner.currentLine = null;
- scanner.wasNonExternalizedStringLiteral = false;
- }
//System.out.println(scanner.toStringAction(type));
switch (type) {
case TokenNameIdentifier :
pushIdentifier();
- if (scanner.useAssertAsAnIndentifier) {
- long positions = identifierPositionStack[identifierPtr];
- problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions);
- }
break;
case TokenNameinterface :
@@ -3985,6 +3939,7 @@ protected void consumeToken(int type) {
scanner.getCurrentTokenSourceString(),
scanner.startPosition,
scanner.currentPosition - 1);
+ if (scanner.wasNonExternalizedStringLiteral) problemReporter().nonExternalizedStringLiteral(stringLiteral);
pushOnExpressionStack(stringLiteral);
break;
case TokenNamefalse :
@@ -4006,7 +3961,6 @@ protected void consumeToken(int type) {
endPosition = scanner.currentPosition - 1;
pushOnIntStack(scanner.startPosition);
break;
- case TokenNameassert :
case TokenNameimport :
case TokenNamepackage :
case TokenNamethrow :
@@ -4340,17 +4294,17 @@ protected CompilationUnitDeclaration endParse(int act) {
if (currentElement != null){
currentElement.topElement().updateParseTree();
if (VERBOSE_RECOVERY){
- System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
- System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.print(Util.bind("parser.syntaxRecovery"/*nonNLS*/));
+ System.out.println("--------------------------"/*nonNLS*/);
System.out.println(compilationUnit);
- System.out.println("----------------------------------"); //$NON-NLS-1$
+ System.out.println("----------------------------------"/*nonNLS*/);
}
} else {
if (diet & VERBOSE_RECOVERY){
- System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$
- System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.print(Util.bind("parser.regularParse"/*nonNLS*/));
+ System.out.println("--------------------------"/*nonNLS*/);
System.out.println(compilationUnit);
- System.out.println("----------------------------------"); //$NON-NLS-1$
+ System.out.println("----------------------------------"/*nonNLS*/);
}
}
if (scanner.recordLineSeparator) {
@@ -4598,10 +4552,6 @@ public void goForCompilationUnit(){
firstToken = TokenNamePLUS_PLUS ;
scanner.linePtr = -1;
scanner.recordLineSeparator = true;
- scanner.currentLineNr= -1;
- scanner.previousLineNr= -1;
- scanner.currentLine= null;
- scanner.lines= new ArrayList();
}
public void goForConstructorBody(){
//tells the scanner to go for compilation unit parsing
@@ -4694,7 +4644,7 @@ $Terminals
Identifier
- abstract assert boolean break byte case catch char class
+ abstract boolean break byte case catch char class
continue default do double else extends false final finally float
for if implements import instanceof int
interface long native new null package private
@@ -4825,7 +4775,7 @@ Goal ::= '--' MethodBody
Goal ::= '==' ConstructorBody
-- Initializer
Goal ::= '>>' StaticInitializer
-Goal ::= '>>' Initializer
+Goal ::= '>>' ClassBodyDeclaration
-- error recovery
Goal ::= '>>>' Headers
Goal ::= '*' BlockStatements
@@ -5029,9 +4979,6 @@ ClassBodyDeclaration ::= Diet NestedMethod Block
Diet ::= $empty
/.$putCase consumeDiet(); $break./
-Initializer ::= Diet NestedMethod Block
-/.$putCase consumeClassBodyDeclaration(); $break ./
-
ClassMemberDeclaration -> FieldDeclaration
ClassMemberDeclaration -> MethodDeclaration
--1.1 feature
@@ -5332,7 +5279,6 @@ StatementNoShortIf -> IfThenElseStatementNoShortIf
StatementNoShortIf -> WhileStatementNoShortIf
StatementNoShortIf -> ForStatementNoShortIf
-StatementWithoutTrailingSubstatement -> AssertStatement
StatementWithoutTrailingSubstatement -> Block
StatementWithoutTrailingSubstatement -> EmptyStatement
StatementWithoutTrailingSubstatement -> ExpressionStatement
@@ -5427,13 +5373,6 @@ StatementExpressionList -> StatementExpression
StatementExpressionList ::= StatementExpressionList ',' StatementExpression
/.$putCase consumeStatementExpressionList() ; $break ./
--- 1.4 feature
-AssertStatement ::= 'assert' Expression ';'
-/.$putCase consumeSimpleAssertStatement() ; $break ./
-
-AssertStatement ::= 'assert' Expression ':' Expression ';'
-/.$putCase consumeAssertStatement() ; $break ./
-
BreakStatement ::= 'break' ';'
/.$putCase consumeStatementBreak() ; $break ./
@@ -6067,21 +6006,21 @@ public void initialize() {
lastErrorEndPosition = -1;
}
public void initializeScanner(){
- this.scanner = new Scanner(false, false, this.problemReporter.options.getNonExternalizedStringLiteralSeverity() != ProblemSeverities.Ignore , this.assertMode);
+ this.scanner = new Scanner(false, false, this.problemReporter.options.isNonExternalizedStringLiteralHandledAsWarning());
}
public final static void initTables() throws java.io.IOException {
final String prefix = FILEPREFIX;
int i = 0;
- lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
- char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
+ lhs = readTable(prefix + (++i) + ".rsc"/*nonNLS*/);
+ char[] chars = readTable(prefix + (++i) + ".rsc"/*nonNLS*/);
check_table = new short[chars.length];
for (int c = chars.length; c-- > 0;) {
check_table[c] = (short) (chars[c] - 32768);
}
- asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
- asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
- symbol_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
+ asb = readTable(prefix + (++i) + ".rsc"/*nonNLS*/);
+ asr = readTable(prefix + (++i) + ".rsc"/*nonNLS*/);
+ symbol_index = readTable(prefix + (++i) + ".rsc"/*nonNLS*/);
action = lhs;
}
public final void jumpOverMethodBody() {
@@ -6701,7 +6640,7 @@ protected static char[] readTable(String filename) throws java.io.IOException {
InputStream stream = Parser.class.getResourceAsStream(filename);
if (stream == null) {
- throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Util.bind("parser.missingFile"/*nonNLS*/,filename));
}
ByteArrayOutputStream os = new ByteArrayOutputStream(32000);
@@ -6719,7 +6658,7 @@ protected static char[] readTable(String filename) throws java.io.IOException {
//minimal integrity check (even size expected)
if (streamLength % 2 != 0)
- throw new java.io.IOException(Util.bind("parser.corruptedFile",filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Util.bind("parser.corruptedFile"/*nonNLS*/,filename));
// convert bytes into chars
char[] chars = new char[streamLength / 2];
@@ -6802,9 +6741,9 @@ protected void reportSyntaxError(int act, int currentKind, int stateStackTop) {
}
} else { //the next test is HEAVILY grammar DEPENDENT.
if ((length == 2)
- && (tokenName.equals(";")) //$NON-NLS-1$
- && (expectings[0] == "++") //$NON-NLS-1$
- && (expectings[1] == "--") //$NON-NLS-1$
+ && (tokenName.equals(";"/*nonNLS*/))
+ && (expectings[0] == "++"/*nonNLS*/)
+ && (expectings[1] == "--"/*nonNLS*/)
&& (expressionPtr > -1)) {
// the ; is not the expected token ==> it ends a statement when an expression is not ended
problemReporter().invalidExpressionAsStatement(expressionStack[expressionPtr]);
@@ -6905,40 +6844,40 @@ protected static int tAction(int state, int sym) {
}
public String toString() {
- String s = "identifierStack : char[][] = {"; //$NON-NLS-1$
+ String s = "identifierStack : char[][] = {"/*nonNLS*/;
for (int i = 0; i <= identifierPtr; i++) {
- s = s + "\"" + String.valueOf(identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "\""/*nonNLS*/ + String.valueOf(identifierStack[i]) + "\","/*nonNLS*/;
};
- s = s + "}\n"; //$NON-NLS-1$
+ s = s + "}\n"/*nonNLS*/;
- s = s + "identierLengthStack : int[] = {"; //$NON-NLS-1$
+ s = s + "identierLengthStack : int[] = {"/*nonNLS*/;
for (int i = 0; i <= identifierLengthPtr; i++) {
- s = s + identifierLengthStack[i] + ","; //$NON-NLS-1$
+ s = s + identifierLengthStack[i] + ","/*nonNLS*/;
};
- s = s + "}\n"; //$NON-NLS-1$
+ s = s + "}\n"/*nonNLS*/;
- s = s + "astLengthStack : int[] = {"; //$NON-NLS-1$
+ s = s + "astLengthStack : int[] = {"/*nonNLS*/;
for (int i = 0; i <= astLengthPtr; i++) {
- s = s + astLengthStack[i] + ","; //$NON-NLS-1$
+ s = s + astLengthStack[i] + ","/*nonNLS*/;
};
- s = s + "}\n"; //$NON-NLS-1$
- s = s + "astPtr : int = " + String.valueOf(astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "}\n"/*nonNLS*/;
+ s = s + "astPtr : int = "/*nonNLS*/ + String.valueOf(astPtr) + "\n"/*nonNLS*/;
- s = s + "intStack : int[] = {"; //$NON-NLS-1$
+ s = s + "intStack : int[] = {"/*nonNLS*/;
for (int i = 0; i <= intPtr; i++) {
- s = s + intStack[i] + ","; //$NON-NLS-1$
+ s = s + intStack[i] + ","/*nonNLS*/;
};
- s = s + "}\n"; //$NON-NLS-1$
+ s = s + "}\n"/*nonNLS*/;
- s = s + "expressionLengthStack : int[] = {"; //$NON-NLS-1$
+ s = s + "expressionLengthStack : int[] = {"/*nonNLS*/;
for (int i = 0; i <= expressionLengthPtr; i++) {
- s = s + expressionLengthStack[i] + ","; //$NON-NLS-1$
+ s = s + expressionLengthStack[i] + ","/*nonNLS*/;
};
- s = s + "}\n"; //$NON-NLS-1$
+ s = s + "}\n"/*nonNLS*/;
- s = s + "expressionPtr : int = " + String.valueOf(expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ s = s + "expressionPtr : int = "/*nonNLS*/ + String.valueOf(expressionPtr) + "\n"/*nonNLS*/;
- s = s + "\n\n\n----------------Scanner--------------\n" + scanner.toString(); //$NON-NLS-1$
+ s = s + "\n\n\n----------------Scanner--------------\n"/*nonNLS*/ + scanner.toString();
return s;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
index 349c4bb702..0606e3a773 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
@@ -10,22 +10,21 @@ import org.eclipse.jdt.internal.compiler.*;
public interface ParserBasicInformation {
- public final static int
- ERROR_SYMBOL = 307,
- MAX_NAME_LENGTH = 36,
- NUM_STATES = 591,
- NT_OFFSET = 308,
- SCOPE_UBOUND = -1,
- SCOPE_SIZE = 0,
- LA_STATE_OFFSET = 16965,
- MAX_LA = 1,
- NUM_RULES = 435,
- NUM_TERMINALS = 105,
- NUM_NON_TERMINALS = 203,
- NUM_SYMBOLS = 308,
- START_STATE = 12259,
- EOFT_SYMBOL = 158,
- EOLT_SYMBOL = 158,
- ACCEPT_ACTION = 16964,
- ERROR_ACTION = 16965;
+ public final static int ERROR_SYMBOL = 304,
+ MAX_NAME_LENGTH = 36,
+ NUM_STATES = 586,
+ NT_OFFSET = 305,
+ SCOPE_UBOUND = -1,
+ SCOPE_SIZE = 0,
+ LA_STATE_OFFSET = 17754,
+ MAX_LA = 1,
+ NUM_RULES = 431,
+ NUM_TERMINALS = 104,
+ NUM_NON_TERMINALS = 201,
+ NUM_SYMBOLS = 305,
+ START_STATE = 12614,
+ EOFT_SYMBOL = 156,
+ EOLT_SYMBOL = 156,
+ ACCEPT_ACTION = 17753,
+ ERROR_ACTION = 17754;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
index 6487e83ad7..a26bdaa8be 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
@@ -134,11 +134,11 @@ public AstNode parseTree(){
}
public String toString(int tab) {
StringBuffer result = new StringBuffer(tabString(tab));
- result.append("Recovered block:\n"); //$NON-NLS-1$
+ result.append("Recovered block:\n"/*nonNLS*/);
result.append(blockDeclaration.toString(tab + 1));
if (this.statements != null) {
for (int i = 0; i < this.statementCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.statements[i].toString(tab + 1));
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
index 3e86663287..4de01e86d6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
@@ -215,7 +215,7 @@ public int sourceEnd(){
protected String tabString(int tab) {
StringBuffer result = new StringBuffer();
for (int i = tab; i > 0; i--) {
- result.append(" "); //$NON-NLS-1$
+ result.append(" "/*nonNLS*/);
}
return result.toString();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
index c1efacb2d4..7d3800cd56 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
@@ -85,11 +85,11 @@ public int sourceEnd(){
}
public String toString(int tab){
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer.append("Recovered field:\n"); //$NON-NLS-1$
+ buffer.append("Recovered field:\n"/*nonNLS*/);
buffer.append(fieldDeclaration.toString(tab + 1));
if (this.anonymousTypes != null) {
for (int i = 0; i < this.anonymousTypeCount; i++){
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
buffer.append(anonymousTypes[i].toString(tab + 1));
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
index af0493f972..139deadc0b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
@@ -29,7 +29,7 @@ public int sourceEnd(){
return this.importReference.declarationSourceEnd;
}
public String toString(int tab) {
- return tabString(tab) + "Recovered import: " + importReference.toString(); //$NON-NLS-1$
+ return tabString(tab) + "Recovered import: "/*nonNLS*/ + importReference.toString();
}
public ImportReference updatedImportReference(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
index 337292544a..36f41b9983 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
@@ -161,10 +161,10 @@ public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalance)
}
public String toString(int tab) {
StringBuffer result = new StringBuffer(tabString(tab));
- result.append("Recovered initializer:\n"); //$NON-NLS-1$
+ result.append("Recovered initializer:\n"/*nonNLS*/);
result.append(this.fieldDeclaration.toString(tab + 1));
if (this.initializerBody != null) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.initializerBody.toString(tab + 1));
}
return result.toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
index de77227707..3d3df3a717 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
@@ -31,7 +31,7 @@ public int sourceEnd(){
return this.localDeclaration.declarationSourceEnd;
}
public String toString(int tab) {
- return tabString(tab) + "Recovered local variable:\n" + localDeclaration.toString(tab + 1); //$NON-NLS-1$
+ return tabString(tab) + "Recovered local variable:\n"/*nonNLS*/ + localDeclaration.toString(tab + 1);
}
public Statement updatedStatement(){
return localDeclaration;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
index 49b642e9b9..d330454bae 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
@@ -189,16 +189,16 @@ public int sourceEnd(){
}
public String toString(int tab) {
StringBuffer result = new StringBuffer(tabString(tab));
- result.append("Recovered method:\n"); //$NON-NLS-1$
+ result.append("Recovered method:\n"/*nonNLS*/);
result.append(this.methodDeclaration.toString(tab + 1));
if (this.localTypes != null) {
for (int i = 0; i < this.localTypeCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.localTypes[i].toString(tab + 1));
}
}
if (this.methodBody != null) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.methodBody.toString(tab + 1));
}
return result.toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
index 5ab597a337..48be014678 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
@@ -30,7 +30,7 @@ public int sourceEnd(){
return this.statement.sourceEnd;
}
public String toString(int tab){
- return tabString(tab) + "Recovered statement:\n" + statement.toString(tab + 1); //$NON-NLS-1$
+ return tabString(tab) + "Recovered statement:\n"/*nonNLS*/ + statement.toString(tab + 1);
}
public Statement updatedStatement(){
return statement;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
index 48bae14d5a..e1bc17f076 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
@@ -185,27 +185,27 @@ public int sourceEnd(){
}
public String toString(int tab) {
StringBuffer result = new StringBuffer(tabString(tab));
- result.append("Recovered type:\n"); //$NON-NLS-1$
+ result.append("Recovered type:\n"/*nonNLS*/);
if (typeDeclaration instanceof AnonymousLocalTypeDeclaration) {
result.append(tabString(tab));
- result.append(" "); //$NON-NLS-1$
+ result.append(" "/*nonNLS*/);
}
result.append(typeDeclaration.toString(tab + 1));
if (this.memberTypes != null) {
for (int i = 0; i < this.memberTypeCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.memberTypes[i].toString(tab + 1));
}
}
if (this.fields != null) {
for (int i = 0; i < this.fieldCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.fields[i].toString(tab + 1));
}
}
if (this.methods != null) {
for (int i = 0; i < this.methodCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.methods[i].toString(tab + 1));
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
index 83a438effe..eb678048d5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
@@ -106,19 +106,19 @@ public int sourceEnd(){
}
public String toString(int tab) {
StringBuffer result = new StringBuffer(tabString(tab));
- result.append("Recovered unit: [\n"); //$NON-NLS-1$
+ result.append("Recovered unit: [\n"/*nonNLS*/);
result.append(unitDeclaration.toString(tab + 1));
result.append(tabString(tab + 1));
- result.append("]"); //$NON-NLS-1$
+ result.append("]"/*nonNLS*/);
if (this.imports != null) {
for (int i = 0; i < this.importCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.imports[i].toString(tab + 1));
}
}
if (this.types != null) {
for (int i = 0; i < this.typeCount; i++) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
result.append(this.types[i].toString(tab + 1));
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 5264792da4..a4421327e4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -4,11 +4,8 @@ package org.eclipse.jdt.internal.compiler.parser;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
+
import java.io.*;
-import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
public class Scanner implements TerminalSymbols {
@@ -21,11 +18,6 @@ public class Scanner implements TerminalSymbols {
- currentPosition-1 gives the sourceEnd position into the stream
*/
- // 1.4 feature
- public boolean assertMode;
- public boolean useAssertAsAnIndentifier = false;
- public boolean containsAssertKeyword = false;
-
public boolean recordLineSeparator;
public char currentCharacter;
public int startPosition;
@@ -70,21 +62,21 @@ public class Scanner implements TerminalSymbols {
public int linePtr = -1;
public boolean wasAcr = false;
- public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
+ public static final String END_OF_SOURCE = "End_Of_Source"/*nonNLS*/;
- public static final String INVALID_HEXA = "Invalid_Hexa_Literal"; //$NON-NLS-1$
- public static final String INVALID_OCTAL = "Invalid_Octal_Literal"; //$NON-NLS-1$
+ public static final String INVALID_HEXA = "Invalid_Hexa_Literal"/*nonNLS*/;
+ public static final String INVALID_OCTAL = "Invalid_Octal_Literal"/*nonNLS*/;
public static final String INVALID_CHARACTER_CONSTANT =
- "Invalid_Character_Constant"; //$NON-NLS-1$
- public static final String INVALID_ESCAPE = "Invalid_Escape"; //$NON-NLS-1$
- public static final String INVALID_INPUT = "Invalid_Input"; //$NON-NLS-1$
- public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"; //$NON-NLS-1$
- public static final String INVALID_FLOAT = "Invalid_Float_Literal"; //$NON-NLS-1$
+ "Invalid_Character_Constant"/*nonNLS*/;
+ public static final String INVALID_ESCAPE = "Invalid_Escape"/*nonNLS*/;
+ public static final String INVALID_INPUT = "Invalid_Input"/*nonNLS*/;
+ public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"/*nonNLS*/;
+ public static final String INVALID_FLOAT = "Invalid_Float_Literal"/*nonNLS*/;
- public static final String NULL_SOURCE_STRING = "Null_Source_String"; //$NON-NLS-1$
- public static final String UNTERMINATED_STRING = "Unterminated_String"; //$NON-NLS-1$
- public static final String UNTERMINATED_COMMENT = "Unterminated_Comment"; //$NON-NLS-1$
- public static final String INVALID_CHAR_IN_STRING = "Invalid_Char_In_String"; //$NON-NLS-1$
+ public static final String NULL_SOURCE_STRING = "Null_Source_String"/*nonNLS*/;
+ public static final String UNTERMINATED_STRING = "Unterminated_String"/*nonNLS*/;
+ public static final String UNTERMINATED_COMMENT = "Unterminated_Comment"/*nonNLS*/;
+ public static final String INVALID_CHAR_IN_STRING = "Invalid_Char_In_String"/*nonNLS*/;
//----------------optimized identifier managment------------------
static final char[] charArray_a = new char[] {'a'},
@@ -121,18 +113,9 @@ public class Scanner implements TerminalSymbols {
public /*static*/ final char[][][][] charArray_length =
new char[OptimizedLength][TableSize][InternalTableSize][];
// support for detecting non-externalized string literals
- int currentLineNr= -1;
- int previousLineNr= -1;
- NLSLine currentLine= null;
- List lines= new ArrayList();
- public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
- public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length();
- public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$
- public static final int TAG_POSTFIX_LENGTH= TAG_POSTFIX.length();
- public StringLiteral[] nonNLSStrings = null;
public boolean checkNonExternalizedStringLiterals = true;
+ public static char[] NonNLS_TAG = "/*nonNLS*/"/*nonNLS*/.toCharArray();
public boolean wasNonExternalizedStringLiteral = false;
-
/*static*/ {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < TableSize; j++) {
@@ -657,14 +640,9 @@ public int getNextToken() throws InvalidInputException {
&& (source[currentPosition] == 'u')) {
isWhiteSpace = jumpOverUnicodeWhiteSpace();
} else {
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
- checkNonExternalizeString();
- if (recordLineSeparator) {
- pushLineSeparator();
- } else {
- linePtr++;
- }
- }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ pushLineSeparator();
isWhiteSpace =
(currentCharacter == ' ') || Character.isWhitespace(currentCharacter);
}
@@ -938,18 +916,15 @@ public int getNextToken() throws InvalidInputException {
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals){ // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
- currentLineNr = linePtr;
- if (currentLineNr != previousLineNr) {
- currentLine= new NLSLine(currentLineNr);
- lines.add(currentLine);
- previousLineNr= currentLineNr;
+ if (checkNonExternalizedStringLiterals){ // check for presence of /*nonNLS*/
+ int lookAhead = 0;
+ for (; lookAhead < 10; lookAhead++){
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] != NonNLS_TAG[lookAhead])
+ break;
}
- currentLine.add(
- new StringLiteral(
- getCurrentTokenSourceString(),
- startPosition,
- currentPosition - 1));
+ this.wasNonExternalizedStringLiteral = lookAhead != 10;
}
return TokenNameStringLiteral;
case '/' :
@@ -1017,18 +992,13 @@ public int getNextToken() throws InvalidInputException {
} //jump over the \\
}
recordComment(false);
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
- checkNonExternalizeString();
- if (recordLineSeparator) {
- if (isUnicode) {
- pushUnicodeLineSeparator();
- } else {
- pushLineSeparator();
- }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ if (isUnicode) {
+ pushUnicodeLineSeparator();
} else {
- linePtr++;
+ pushLineSeparator();
}
- }
if (tokenizeComments) {
if (!isUnicode) {
currentPosition--; // reset one character behind
@@ -1036,10 +1006,10 @@ public int getNextToken() throws InvalidInputException {
return TokenNameCOMMENT_LINE;
}
} catch (IndexOutOfBoundsException e) { //an eof will them be generated
- if (tokenizeComments) {
- currentPosition--; // reset one character behind
- return TokenNameCOMMENT_LINE;
- }
+ if (tokenizeComments) {
+ currentPosition--; // reset one character behind
+ return TokenNameCOMMENT_LINE;
+ }
}
break;
}
@@ -1060,14 +1030,9 @@ public int getNextToken() throws InvalidInputException {
isJavadoc = true;
star = true;
}
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
- checkNonExternalizeString();
- if (recordLineSeparator) {
- pushLineSeparator();
- } else {
- linePtr++;
- }
- }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ pushLineSeparator();
try { //get the next char
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
@@ -1085,14 +1050,9 @@ public int getNextToken() throws InvalidInputException {
}
//loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
- checkNonExternalizeString();
- if (recordLineSeparator) {
- pushLineSeparator();
- } else {
- linePtr++;
- }
- }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ pushLineSeparator();
star = currentCharacter == '*';
//get next char
if (((currentCharacter = source[currentPosition++]) == '\\')
@@ -1125,7 +1085,7 @@ public int getNextToken() throws InvalidInputException {
if (atEnd())
return TokenNameEOF;
//the atEnd may not be <currentPosition == source.length> if source is only some part of a real (external) stream
- throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
+ throw new InvalidInputException("Ctrl-Z"/*nonNLS*/);
default :
if (Character.isJavaIdentifierStart(currentCharacter))
@@ -1747,9 +1707,11 @@ final char[] optimizedCurrentTokenSource6() {
newEntry6 = max;
return r;
}
-public final void pushLineSeparator() throws InvalidInputException {
+public final void pushLineSeparator() {
//see comment on isLineDelimiter(char) for the use of '\n' and '\r'
+
final int INCREMENT = 250;
+
//currentCharacter is at position currentPosition-1
// cr 000D
@@ -1886,7 +1848,6 @@ public void resetTo(int begin, int end) {
eofPosition = end + 1;
commentPtr = -1; // reset comment stack
}
-
public final void scanEscapeCharacter() throws InvalidInputException {
// the string with "\\u" is a legal string of two chars \ and u
//thus we use a direct access to the source (for regular cases).
@@ -1975,7 +1936,7 @@ public int scanIdentifierOrKeyword() throws InvalidInputException {
//then the length. If there are several
//keywors with the same length AND the same first char, then do another
//disptach on the second char :-)...cool....but fast !
- useAssertAsAnIndentifier = false;
+
while (getNextCharAsJavaIdentifierPart()) {};
int index, length;
@@ -2002,39 +1963,20 @@ public int scanIdentifierOrKeyword() throws InvalidInputException {
firstLetter = data[index];
switch (firstLetter) {
- case 'a' :
- switch(length) {
- case 8: //abstract
- if ((data[++index] == 'b')
- && (data[++index] == 's')
- && (data[++index] == 't')
- && (data[++index] == 'r')
- && (data[++index] == 'a')
- && (data[++index] == 'c')
- && (data[++index] == 't')) {
- return TokenNameabstract;
- } else {
- return TokenNameIdentifier;
- }
- case 6: // assert
- if ((data[++index] == 's')
- && (data[++index] == 's')
- && (data[++index] == 'e')
- && (data[++index] == 'r')
- && (data[++index] == 't')) {
- if (assertMode) {
- containsAssertKeyword = true;
- return TokenNameassert;
- } else {
- useAssertAsAnIndentifier = true;
- return TokenNameIdentifier;
- }
- } else {
- return TokenNameIdentifier;
- }
- default:
- return TokenNameIdentifier;
+ case 'a' : //abstract
+ if (length == 8) {
+ if ((data[++index] == 'b')
+ && (data[++index] == 's')
+ && (data[++index] == 't')
+ && (data[++index] == 'r')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c')
+ && (data[++index] == 't')) {
+ return TokenNameabstract;
+ }
}
+ return TokenNameIdentifier;
+
case 'b' : //boolean break byte
switch (length) {
case 4 :
@@ -2706,7 +2648,6 @@ public final void setSourceBuffer(char[] sourceString){
source = sourceString;
startPosition = -1;
initialPosition = currentPosition = 0;
- containsAssertKeyword = false;
if (source == null) {
source = new char[0];
}
@@ -2714,9 +2655,9 @@ public final void setSourceBuffer(char[] sourceString){
}
public String toString() {
if (startPosition == source.length)
- return "EOF\n\n" + new String(source); //$NON-NLS-1$
+ return "EOF\n\n"/*nonNLS*/ + new String(source);
if (currentPosition > source.length)
- return "behind the EOF :-( ....\n\n" + new String(source); //$NON-NLS-1$
+ return "behind the EOF :-( ....\n\n"/*nonNLS*/ + new String(source);
char front[] = new char[startPosition];
System.arraycopy(source, 0, front, 0, startPosition);
@@ -2744,280 +2685,228 @@ public String toString() {
source.length - (currentPosition - 1) - 1);
return new String(front)
- + "\n===============================\nStarts here -->" //$NON-NLS-1$
+ + "\n===============================\nStarts here -->"/*nonNLS*/
+ new String(middle)
- + "<-- Ends here\n===============================\n" //$NON-NLS-1$
+ + "<-- Ends here\n===============================\n"/*nonNLS*/
+ new String(end);
}
public final String toStringAction(int act) {
switch (act) {
case TokenNameIdentifier :
- return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Identifier("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameabstract :
- return "abstract"; //$NON-NLS-1$
+ return "abstract"/*nonNLS*/;
case TokenNameboolean :
- return "boolean"; //$NON-NLS-1$
+ return "boolean"/*nonNLS*/;
case TokenNamebreak :
- return "break"; //$NON-NLS-1$
+ return "break"/*nonNLS*/;
case TokenNamebyte :
- return "byte"; //$NON-NLS-1$
+ return "byte"/*nonNLS*/;
case TokenNamecase :
- return "case"; //$NON-NLS-1$
+ return "case"/*nonNLS*/;
case TokenNamecatch :
- return "catch"; //$NON-NLS-1$
+ return "catch"/*nonNLS*/;
case TokenNamechar :
- return "char"; //$NON-NLS-1$
+ return "char"/*nonNLS*/;
case TokenNameclass :
- return "class"; //$NON-NLS-1$
+ return "class"/*nonNLS*/;
case TokenNamecontinue :
- return "continue"; //$NON-NLS-1$
+ return "continue"/*nonNLS*/;
case TokenNamedefault :
- return "default"; //$NON-NLS-1$
+ return "default"/*nonNLS*/;
case TokenNamedo :
- return "do"; //$NON-NLS-1$
+ return "do"/*nonNLS*/;
case TokenNamedouble :
- return "double"; //$NON-NLS-1$
+ return "double"/*nonNLS*/;
case TokenNameelse :
- return "else"; //$NON-NLS-1$
+ return "else"/*nonNLS*/;
case TokenNameextends :
- return "extends"; //$NON-NLS-1$
+ return "extends"/*nonNLS*/;
case TokenNamefalse :
- return "false"; //$NON-NLS-1$
+ return "false"/*nonNLS*/;
case TokenNamefinal :
- return "final"; //$NON-NLS-1$
+ return "final"/*nonNLS*/;
case TokenNamefinally :
- return "finally"; //$NON-NLS-1$
+ return "finally"/*nonNLS*/;
case TokenNamefloat :
- return "float"; //$NON-NLS-1$
+ return "float"/*nonNLS*/;
case TokenNamefor :
- return "for"; //$NON-NLS-1$
+ return "for"/*nonNLS*/;
case TokenNameif :
- return "if"; //$NON-NLS-1$
+ return "if"/*nonNLS*/;
case TokenNameimplements :
- return "implements"; //$NON-NLS-1$
+ return "implements"/*nonNLS*/;
case TokenNameimport :
- return "import"; //$NON-NLS-1$
+ return "import"/*nonNLS*/;
case TokenNameinstanceof :
- return "instanceof"; //$NON-NLS-1$
+ return "instanceof"/*nonNLS*/;
case TokenNameint :
- return "int"; //$NON-NLS-1$
+ return "int"/*nonNLS*/;
case TokenNameinterface :
- return "interface"; //$NON-NLS-1$
+ return "interface"/*nonNLS*/;
case TokenNamelong :
- return "long"; //$NON-NLS-1$
+ return "long"/*nonNLS*/;
case TokenNamenative :
- return "native"; //$NON-NLS-1$
+ return "native"/*nonNLS*/;
case TokenNamenew :
- return "new"; //$NON-NLS-1$
+ return "new"/*nonNLS*/;
case TokenNamenull :
- return "null"; //$NON-NLS-1$
+ return "null"/*nonNLS*/;
case TokenNamepackage :
- return "package"; //$NON-NLS-1$
+ return "package"/*nonNLS*/;
case TokenNameprivate :
- return "private"; //$NON-NLS-1$
+ return "private"/*nonNLS*/;
case TokenNameprotected :
- return "protected"; //$NON-NLS-1$
+ return "protected"/*nonNLS*/;
case TokenNamepublic :
- return "public"; //$NON-NLS-1$
+ return "public"/*nonNLS*/;
case TokenNamereturn :
- return "return"; //$NON-NLS-1$
+ return "return"/*nonNLS*/;
case TokenNameshort :
- return "short"; //$NON-NLS-1$
+ return "short"/*nonNLS*/;
case TokenNamestatic :
- return "static"; //$NON-NLS-1$
+ return "static"/*nonNLS*/;
case TokenNamesuper :
- return "super"; //$NON-NLS-1$
+ return "super"/*nonNLS*/;
case TokenNameswitch :
- return "switch"; //$NON-NLS-1$
+ return "switch"/*nonNLS*/;
case TokenNamesynchronized :
- return "synchronized"; //$NON-NLS-1$
+ return "synchronized"/*nonNLS*/;
case TokenNamethis :
- return "this"; //$NON-NLS-1$
+ return "this"/*nonNLS*/;
case TokenNamethrow :
- return "throw"; //$NON-NLS-1$
+ return "throw"/*nonNLS*/;
case TokenNamethrows :
- return "throws"; //$NON-NLS-1$
+ return "throws"/*nonNLS*/;
case TokenNametransient :
- return "transient"; //$NON-NLS-1$
+ return "transient"/*nonNLS*/;
case TokenNametrue :
- return "true"; //$NON-NLS-1$
+ return "true"/*nonNLS*/;
case TokenNametry :
- return "try"; //$NON-NLS-1$
+ return "try"/*nonNLS*/;
case TokenNamevoid :
- return "void"; //$NON-NLS-1$
+ return "void"/*nonNLS*/;
case TokenNamevolatile :
- return "volatile"; //$NON-NLS-1$
+ return "volatile"/*nonNLS*/;
case TokenNamewhile :
- return "while"; //$NON-NLS-1$
+ return "while"/*nonNLS*/;
case TokenNameIntegerLiteral :
- return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Integer("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameLongLiteral :
- return "Long(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Long("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameFloatingPointLiteral :
- return "Float(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Float("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameDoubleLiteral :
- return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Double("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameCharacterLiteral :
- return "Char(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Char("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNameStringLiteral :
- return "String(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "String("/*nonNLS*/ + new String(getCurrentTokenSource()) + ")"/*nonNLS*/;
case TokenNamePLUS_PLUS :
- return "++"; //$NON-NLS-1$
+ return "++"/*nonNLS*/;
case TokenNameMINUS_MINUS :
- return "--"; //$NON-NLS-1$
+ return "--"/*nonNLS*/;
case TokenNameEQUAL_EQUAL :
- return "=="; //$NON-NLS-1$
+ return "=="/*nonNLS*/;
case TokenNameLESS_EQUAL :
- return "<="; //$NON-NLS-1$
+ return "<="/*nonNLS*/;
case TokenNameGREATER_EQUAL :
- return ">="; //$NON-NLS-1$
+ return ">="/*nonNLS*/;
case TokenNameNOT_EQUAL :
- return "!="; //$NON-NLS-1$
+ return "!="/*nonNLS*/;
case TokenNameLEFT_SHIFT :
- return "<<"; //$NON-NLS-1$
+ return "<<"/*nonNLS*/;
case TokenNameRIGHT_SHIFT :
- return ">>"; //$NON-NLS-1$
+ return ">>"/*nonNLS*/;
case TokenNameUNSIGNED_RIGHT_SHIFT :
- return ">>>"; //$NON-NLS-1$
+ return ">>>"/*nonNLS*/;
case TokenNamePLUS_EQUAL :
- return "+="; //$NON-NLS-1$
+ return "+="/*nonNLS*/;
case TokenNameMINUS_EQUAL :
- return "-="; //$NON-NLS-1$
+ return "-="/*nonNLS*/;
case TokenNameMULTIPLY_EQUAL :
- return "*="; //$NON-NLS-1$
+ return "*="/*nonNLS*/;
case TokenNameDIVIDE_EQUAL :
- return "/="; //$NON-NLS-1$
+ return "/="/*nonNLS*/;
case TokenNameAND_EQUAL :
- return "&="; //$NON-NLS-1$
+ return "&="/*nonNLS*/;
case TokenNameOR_EQUAL :
- return "|="; //$NON-NLS-1$
+ return "|="/*nonNLS*/;
case TokenNameXOR_EQUAL :
- return "^="; //$NON-NLS-1$
+ return "^="/*nonNLS*/;
case TokenNameREMAINDER_EQUAL :
- return "%="; //$NON-NLS-1$
+ return "%="/*nonNLS*/;
case TokenNameLEFT_SHIFT_EQUAL :
- return "<<="; //$NON-NLS-1$
+ return "<<="/*nonNLS*/;
case TokenNameRIGHT_SHIFT_EQUAL :
- return ">>="; //$NON-NLS-1$
+ return ">>="/*nonNLS*/;
case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL :
- return ">>>="; //$NON-NLS-1$
+ return ">>>="/*nonNLS*/;
case TokenNameOR_OR :
- return "||"; //$NON-NLS-1$
+ return "||"/*nonNLS*/;
case TokenNameAND_AND :
- return "&&"; //$NON-NLS-1$
+ return "&&"/*nonNLS*/;
case TokenNamePLUS :
- return "+"; //$NON-NLS-1$
+ return "+"/*nonNLS*/;
case TokenNameMINUS :
- return "-"; //$NON-NLS-1$
+ return "-"/*nonNLS*/;
case TokenNameNOT :
- return "!"; //$NON-NLS-1$
+ return "!"/*nonNLS*/;
case TokenNameREMAINDER :
- return "%"; //$NON-NLS-1$
+ return "%"/*nonNLS*/;
case TokenNameXOR :
- return "^"; //$NON-NLS-1$
+ return "^"/*nonNLS*/;
case TokenNameAND :
- return "&"; //$NON-NLS-1$
+ return "&"/*nonNLS*/;
case TokenNameMULTIPLY :
- return "*"; //$NON-NLS-1$
+ return "*"/*nonNLS*/;
case TokenNameOR :
- return "|"; //$NON-NLS-1$
+ return "|"/*nonNLS*/;
case TokenNameTWIDDLE :
- return "~"; //$NON-NLS-1$
+ return "~"/*nonNLS*/;
case TokenNameDIVIDE :
- return "/"; //$NON-NLS-1$
+ return "/"/*nonNLS*/;
case TokenNameGREATER :
- return ">"; //$NON-NLS-1$
+ return ">"/*nonNLS*/;
case TokenNameLESS :
- return "<"; //$NON-NLS-1$
+ return "<"/*nonNLS*/;
case TokenNameLPAREN :
- return "("; //$NON-NLS-1$
+ return "("/*nonNLS*/;
case TokenNameRPAREN :
- return ")"; //$NON-NLS-1$
+ return ")"/*nonNLS*/;
case TokenNameLBRACE :
- return "{"; //$NON-NLS-1$
+ return "{"/*nonNLS*/;
case TokenNameRBRACE :
- return "}"; //$NON-NLS-1$
+ return "}"/*nonNLS*/;
case TokenNameLBRACKET :
- return "["; //$NON-NLS-1$
+ return "["/*nonNLS*/;
case TokenNameRBRACKET :
- return "]"; //$NON-NLS-1$
+ return "]"/*nonNLS*/;
case TokenNameSEMICOLON :
- return ";"; //$NON-NLS-1$
+ return ";"/*nonNLS*/;
case TokenNameQUESTION :
- return "?"; //$NON-NLS-1$
+ return "?"/*nonNLS*/;
case TokenNameCOLON :
- return ":"; //$NON-NLS-1$
+ return ":"/*nonNLS*/;
case TokenNameCOMMA :
- return ","; //$NON-NLS-1$
+ return ","/*nonNLS*/;
case TokenNameDOT :
- return "."; //$NON-NLS-1$
+ return "."/*nonNLS*/;
case TokenNameEQUAL :
- return "="; //$NON-NLS-1$
+ return "="/*nonNLS*/;
case TokenNameEOF :
- return "EOF"; //$NON-NLS-1$
+ return "EOF"/*nonNLS*/;
default :
- return "not-a-token"; //$NON-NLS-1$
+ return "not-a-token"/*nonNLS*/;
}
}
public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals) {
- this(tokenizeComments, tokenizeWhiteSpace, checkNonExternalizedStringLiterals, false);
-}
-
-public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, boolean assertMode) {
this.eofPosition = Integer.MAX_VALUE;
this.tokenizeComments = tokenizeComments;
this.tokenizeWhiteSpace = tokenizeWhiteSpace;
this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
- this.assertMode = assertMode;
-}
-
-private void checkNonExternalizeString() throws InvalidInputException {
- if (currentLine == null || currentLineNr != linePtr)
- return;
- parseTags(currentLine);
-}
-
-private void parseTags(NLSLine line) throws InvalidInputException {
- String s = new String(getCurrentTokenSource());
- int pos = s.indexOf(TAG_PREFIX);
- int lineLength = line.size();
- while (pos != -1) {
- int start = pos + TAG_PREFIX_LENGTH;
- int end = s.indexOf(TAG_POSTFIX, start);
- String index = s.substring(start, end);
- int i = 0;
- try {
- i = Integer.parseInt(index) - 1; // Tags are one based not zero based.
- } catch (NumberFormatException e) {
- i = -1; // we don't want to consider this as a valid NLS tag
- }
- int listIndex = lineLength - i - 1;
- if (line.exists(listIndex)) {
- line.set(listIndex, null);
- }
- pos = s.indexOf(TAG_PREFIX, start);
- }
-
- this.nonNLSStrings = new StringLiteral[lineLength];
- int nonNLSCounter = 0;
- for (Iterator iterator = line.iterator(); iterator.hasNext(); ) {
- StringLiteral literal = (StringLiteral) iterator.next();
- if (literal != null) {
- this.nonNLSStrings[nonNLSCounter++] = literal;
- }
- }
- if (nonNLSCounter == 0) {
- this.nonNLSStrings = null;
- currentLine = null;
- return;
- }
- wasNonExternalizedStringLiteral = true;
- if (nonNLSCounter != lineLength) {
- System.arraycopy(this.nonNLSStrings, 0, (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0, nonNLSCounter);
- }
- currentLine = null;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
index 5cc0193832..40bdc7b7e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
@@ -25,297 +25,285 @@ import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.util.*;
public class SourceTypeConverter implements CompilerModifiers {
+/*
+ * Convert a source element type into a parsed type declaration
+ *
+ * Can optionally ignore fields & methods
+ *
+ * @deprecated - should use the other API with one extra boolean
+ */
+public static CompilationUnitDeclaration buildCompilationUnit(
+ ISourceType sourceType,
+ boolean needFieldsAndMethods,
+ ProblemReporter problemReporter,
+ CompilationResult compilationResult) {
- /*
- * Convert a set of source element types into a parsed compilation unit declaration
- * The argument types are then all grouped in the same unit. The argument types must
- * at least contain one type.
- * Can optionally ignore fields & methods or member types
- */
- public static CompilationUnitDeclaration buildCompilationUnit(
- ISourceType[] sourceTypes,
- boolean needFieldsAndMethods,
- boolean needMemberTypes,
- ProblemReporter problemReporter,
- CompilationResult compilationResult) {
-
- ISourceType sourceType = sourceTypes[0];
- if (sourceType.getName() == null)
- return null; // do a basic test that the sourceType is valid
+ return buildCompilationUnit(sourceType, needFieldsAndMethods, true, problemReporter, compilationResult);
+}
+/*
+ * Convert a source element type into a parsed type declaration
+ *
+ * Can optionally ignore fields & methods or member types
+ */
+public static CompilationUnitDeclaration buildCompilationUnit(
+ ISourceType sourceType,
+ boolean needFieldsAndMethods,
+ boolean needMemberTypes,
+ ProblemReporter problemReporter,
+ CompilationResult compilationResult) {
- CompilationUnitDeclaration compilationUnit =
- new CompilationUnitDeclaration(problemReporter, compilationResult, 0);
- // not filled at this point
+ if (sourceType.getName() == null) return null; // do a basic test that the sourceType is valid
- /* only positions available */
- int start = sourceType.getNameSourceStart();
- int end = sourceType.getNameSourceEnd();
+ CompilationUnitDeclaration compilationUnit =
+ new CompilationUnitDeclaration(problemReporter, compilationResult, 0); // not filled at this point
- /* convert package and imports */
- if (sourceType.getPackageName() != null
- && sourceType.getPackageName().length > 0)
- // if its null then it is defined in the default package
- compilationUnit.currentPackage =
- createImportReference(sourceType.getPackageName(), start, end);
- char[][] importNames = sourceType.getImports();
- int importCount = importNames == null ? 0 : importNames.length;
- compilationUnit.imports = new ImportReference[importCount];
- for (int i = 0; i < importCount; i++)
- compilationUnit.imports[i] = createImportReference(importNames[i], start, end);
- /* convert type(s) */
- int typeCount = sourceTypes.length;
- compilationUnit.types = new TypeDeclaration[typeCount];
- for (int i = 0; i < typeCount; i++) {
- compilationUnit.types[i] =
- convert(sourceTypes[i], needFieldsAndMethods, needMemberTypes);
- }
- return compilationUnit;
- }
-
- /*
- * Convert a field source element into a parsed field declaration
- */
- private static FieldDeclaration convert(ISourceField sourceField) {
+ /* only positions available */
+ int start = sourceType.getNameSourceStart();
+ int end = sourceType.getNameSourceEnd();
+
+ /* convert package and imports */
+ if (sourceType.getPackageName() != null && sourceType.getPackageName().length > 0) // if its null then it is defined in the default package
+ compilationUnit.currentPackage = createImportReference(sourceType.getPackageName(), start, end);
+ char[][] importNames = sourceType.getImports();
+ int importCount = importNames == null ? 0 : importNames.length;
+ compilationUnit.imports = new ImportReference[importCount];
+ for (int i = 0; i < importCount; i++)
+ compilationUnit.imports[i] = createImportReference(importNames[i], start, end);
+ /* convert type */
+ compilationUnit.types = new TypeDeclaration[] {convert(sourceType, needFieldsAndMethods, needMemberTypes)};
- FieldDeclaration field = new FieldDeclaration();
+ return compilationUnit;
+}
+/*
+ * Convert a field source element into a parsed field declaration
+ */
- int start = sourceField.getNameSourceStart();
- int end = sourceField.getNameSourceEnd();
+private static FieldDeclaration convert(ISourceField sourceField) {
- field.name = sourceField.getName();
- field.sourceStart = start;
- field.sourceEnd = end;
- field.type = createTypeReference(sourceField.getTypeName(), start, end);
- field.declarationSourceStart = sourceField.getDeclarationSourceStart();
- field.declarationSourceEnd = sourceField.getDeclarationSourceEnd();
- field.modifiers = sourceField.getModifiers();
+ FieldDeclaration field = new FieldDeclaration();
- /* conversion of field constant: if not present, then cannot generate binary against
- converted parse nodes */
- /*
- if (field.modifiers & AccFinal){
- char[] initializationSource = sourceField.getInitializationSource();
- }
- */
- return field;
- }
+ int start = sourceField.getNameSourceStart();
+ int end = sourceField.getNameSourceEnd();
+ field.name = sourceField.getName();
+ field.sourceStart = start;
+ field.sourceEnd = end;
+ field.type = createTypeReference(sourceField.getTypeName(), start, end);
+ field.declarationSourceStart = sourceField.getDeclarationSourceStart();
+ field.declarationSourceEnd = sourceField.getDeclarationSourceEnd();
+ field.modifiers = sourceField.getModifiers();
+
+ /* conversion of field constant: if not present, then cannot generate binary against
+ converted parse nodes */
/*
- * Convert a method source element into a parsed method/constructor declaration
- */
- private static AbstractMethodDeclaration convert(ISourceMethod sourceMethod) {
+ if (field.modifiers & AccFinal){
+ char[] initializationSource = sourceField.getInitializationSource();
+ }
+ */
+ return field;
+}
+/*
+ * Convert a method source element into a parsed method/constructor declaration
+ */
+private static AbstractMethodDeclaration convert(ISourceMethod sourceMethod) {
- AbstractMethodDeclaration method;
+ AbstractMethodDeclaration method;
- /* only source positions available */
- int start = sourceMethod.getNameSourceStart();
- int end = sourceMethod.getNameSourceEnd();
+ /* only source positions available */
+ int start = sourceMethod.getNameSourceStart();
+ int end = sourceMethod.getNameSourceEnd();
- if (sourceMethod.isConstructor()) {
- ConstructorDeclaration decl = new ConstructorDeclaration();
- decl.isDefaultConstructor = false;
- method = decl;
- } else {
- MethodDeclaration decl = new MethodDeclaration();
- /* convert return type */
- decl.returnType =
- createTypeReference(sourceMethod.getReturnTypeName(), start, end);
- method = decl;
- }
- method.selector = sourceMethod.getSelector();
- method.modifiers = sourceMethod.getModifiers();
- method.sourceStart = start;
- method.sourceEnd = end;
- method.declarationSourceStart = sourceMethod.getDeclarationSourceStart();
- method.declarationSourceEnd = sourceMethod.getDeclarationSourceEnd();
+ if (sourceMethod.isConstructor()) {
+ ConstructorDeclaration decl = new ConstructorDeclaration();
+ decl.isDefaultConstructor = false;
+ method = decl;
+ } else {
+ MethodDeclaration decl = new MethodDeclaration();
+ /* convert return type */
+ decl.returnType =
+ createTypeReference(sourceMethod.getReturnTypeName(), start, end);
+ method = decl;
+ }
+ method.selector = sourceMethod.getSelector();
+ method.modifiers = sourceMethod.getModifiers();
+ method.sourceStart = start;
+ method.sourceEnd = end;
+ method.declarationSourceStart = sourceMethod.getDeclarationSourceStart();
+ method.declarationSourceEnd = sourceMethod.getDeclarationSourceEnd();
- /* convert arguments */
- char[][] argumentTypeNames = sourceMethod.getArgumentTypeNames();
- char[][] argumentNames = sourceMethod.getArgumentNames();
- int argumentCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
- long position = (long) start << 32 + end;
- method.arguments = new Argument[argumentCount];
- for (int i = 0; i < argumentCount; i++) {
- method.arguments[i] =
- new Argument(
- argumentNames[i],
- position,
- createTypeReference(argumentTypeNames[i], start, end),
- AccDefault);
- // do not care whether was final or not
- }
+ /* convert arguments */
+ char[][] argumentTypeNames = sourceMethod.getArgumentTypeNames();
+ char[][] argumentNames = sourceMethod.getArgumentNames();
+ int argumentCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
+ long position = (long) start << 32 + end;
+ method.arguments = new Argument[argumentCount];
+ for (int i = 0; i < argumentCount; i++) {
+ method.arguments[i] =
+ new Argument(
+ argumentNames[i],
+ position,
+ createTypeReference(argumentTypeNames[i], start, end),
+ AccDefault); // do not care whether was final or not
+ }
- /* convert thrown exceptions */
- char[][] exceptionTypeNames = sourceMethod.getExceptionTypeNames();
- int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length;
- method.thrownExceptions = new TypeReference[exceptionCount];
- for (int i = 0; i < exceptionCount; i++) {
- method.thrownExceptions[i] =
- createTypeReference(exceptionTypeNames[i], start, end);
- }
- return method;
+ /* convert thrown exceptions */
+ char[][] exceptionTypeNames = sourceMethod.getExceptionTypeNames();
+ int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length;
+ method.thrownExceptions = new TypeReference[exceptionCount];
+ for (int i = 0; i < exceptionCount; i++) {
+ method.thrownExceptions[i] =
+ createTypeReference(exceptionTypeNames[i], start, end);
}
+ return method;
+}
+/*
+ * Convert a source element type into a parsed type declaration
+ *
+ * Can optionally ignore fields & methods
+ */
+private static TypeDeclaration convert(ISourceType sourceType, boolean needFieldsAndMethods, boolean needMemberTypes) {
- /*
- * Convert a source element type into a parsed type declaration
- *
- * Can optionally ignore fields & methods
- */
- private static TypeDeclaration convert(
- ISourceType sourceType,
- boolean needFieldsAndMethods,
- boolean needMemberTypes) {
- /* create type declaration - can be member type */
- TypeDeclaration type;
- if (sourceType.getEnclosingType() == null) {
- type = new TypeDeclaration();
- } else {
- type = new MemberTypeDeclaration();
- }
- type.name = sourceType.getName();
- int start, end; // only positions available
- type.sourceStart = start = sourceType.getNameSourceStart();
- type.sourceEnd = end = sourceType.getNameSourceEnd();
- type.modifiers = sourceType.getModifiers();
- type.declarationSourceStart = sourceType.getDeclarationSourceStart();
- type.declarationSourceEnd = sourceType.getDeclarationSourceEnd();
+ /* create type declaration - can be member type */
+ TypeDeclaration type;
+ if (sourceType.getEnclosingType() == null){
+ type = new TypeDeclaration();
+ } else {
+ type = new MemberTypeDeclaration();
+ }
+ type.name = sourceType.getName();
+ int start, end; // only positions available
+ type.sourceStart = start = sourceType.getNameSourceStart();
+ type.sourceEnd = end = sourceType.getNameSourceEnd();
+ type.modifiers = sourceType.getModifiers();
+ type.declarationSourceStart = sourceType.getDeclarationSourceStart();
+ type.declarationSourceEnd = sourceType.getDeclarationSourceEnd();
- /* set superclass and superinterfaces */
- if (sourceType.getSuperclassName() != null)
- type.superclass =
- createTypeReference(sourceType.getSuperclassName(), start, end);
- char[][] interfaceNames = sourceType.getInterfaceNames();
- int interfaceCount = interfaceNames == null ? 0 : interfaceNames.length;
- type.superInterfaces = new TypeReference[interfaceCount];
- for (int i = 0; i < interfaceCount; i++) {
- type.superInterfaces[i] = createTypeReference(interfaceNames[i], start, end);
+ /* set superclass and superinterfaces */
+ if (sourceType.getSuperclassName() != null)
+ type.superclass = createTypeReference(sourceType.getSuperclassName(), start, end);
+ char[][] interfaceNames = sourceType.getInterfaceNames();
+ int interfaceCount = interfaceNames == null ? 0 : interfaceNames.length;
+ type.superInterfaces = new TypeReference[interfaceCount];
+ for (int i = 0; i < interfaceCount; i++){
+ type.superInterfaces[i] = createTypeReference(interfaceNames[i], start, end);
+ }
+ /* convert member types */
+ if (needMemberTypes){
+ ISourceType[] sourceMemberTypes = sourceType.getMemberTypes();
+ int sourceMemberTypeCount = sourceMemberTypes == null ? 0 : sourceMemberTypes.length;
+ type.memberTypes = new MemberTypeDeclaration[sourceMemberTypeCount];
+ for (int i = 0; i < sourceMemberTypeCount; i++) {
+ type.memberTypes[i] = (MemberTypeDeclaration) convert(sourceMemberTypes[i], needFieldsAndMethods, true);
}
- /* convert member types */
- if (needMemberTypes) {
- ISourceType[] sourceMemberTypes = sourceType.getMemberTypes();
- int sourceMemberTypeCount =
- sourceMemberTypes == null ? 0 : sourceMemberTypes.length;
- type.memberTypes = new MemberTypeDeclaration[sourceMemberTypeCount];
- for (int i = 0; i < sourceMemberTypeCount; i++) {
- type.memberTypes[i] =
- (MemberTypeDeclaration) convert(sourceMemberTypes[i],
- needFieldsAndMethods,
- true);
- }
+ }
+ /* convert fields and methods */
+ if (needFieldsAndMethods) {
+ /* convert fields */
+ ISourceField[] sourceFields = sourceType.getFields();
+ int sourceFieldCount = sourceFields == null ? 0 : sourceFields.length;
+ type.fields = new FieldDeclaration[sourceFieldCount];
+ for (int i = 0; i < sourceFieldCount; i++) {
+ type.fields[i] = convert(sourceFields[i]);
}
- /* convert fields and methods */
- if (needFieldsAndMethods) {
- /* convert fields */
- ISourceField[] sourceFields = sourceType.getFields();
- int sourceFieldCount = sourceFields == null ? 0 : sourceFields.length;
- type.fields = new FieldDeclaration[sourceFieldCount];
- for (int i = 0; i < sourceFieldCount; i++) {
- type.fields[i] = convert(sourceFields[i]);
- }
- /* convert methods - need to add default constructor if necessary */
- ISourceMethod[] sourceMethods = sourceType.getMethods();
- int sourceMethodCount = sourceMethods == null ? 0 : sourceMethods.length;
+ /* convert methods - need to add default constructor if necessary */
+ ISourceMethod[] sourceMethods = sourceType.getMethods();
+ int sourceMethodCount = sourceMethods == null ? 0 : sourceMethods.length;
- /* source type has a constructor ? */
- /* by default, we assume that one is needed. */
- int neededCount = 1;
- for (int i = 0; i < sourceMethodCount; i++) {
- if (sourceMethods[i].isConstructor()) {
- neededCount = 0;
- // Does not need the extra constructor since one constructor already exists.
- break;
- }
- }
- type.methods = new AbstractMethodDeclaration[sourceMethodCount + neededCount];
- if (neededCount != 0) { // add default constructor in first position
- type.methods[0] = type.createsInternalConstructor(false, false);
- }
- for (int i = 0; i < sourceMethodCount; i++) {
- type.methods[neededCount + i] = convert(sourceMethods[i]);
+ /* source type has a constructor ? */
+ /* by default, we assume that one is needed. */
+ int neededCount = 1;
+ for (int i = 0; i < sourceMethodCount; i++) {
+ if (sourceMethods[i].isConstructor()) {
+ neededCount = 0; // Does not need the extra constructor since one constructor already exists.
+ break;
}
}
- return type;
+ type.methods =
+ new AbstractMethodDeclaration[sourceMethodCount + neededCount];
+ if (neededCount != 0){ // add default constructor in first position
+ type.methods[0] = type.createsInternalConstructor(false, false);
+ }
+ for (int i = 0; i < sourceMethodCount; i++) {
+ type.methods[neededCount + i] = convert(sourceMethods[i]);
+ }
}
+ return type;
+}
+/*
+ * Build an import reference from an import name, e.g. java.lang.*
+ */
+private static ImportReference createImportReference(
+ char[] importName,
+ int start,
+ int end) {
- /*
- * Build an import reference from an import name, e.g. java.lang.*
- */
- private static ImportReference createImportReference(
- char[] importName,
- int start,
- int end) {
+ /* count identifiers */
+ int max = importName.length;
+ int identCount = 0;
+ for (int i = 0; i < max; i++) {
+ if (importName[i] == '.') identCount++;
+ }
+ /* import on demand? */
+ boolean onDemand = importName[max-1] == '*';
+ if (!onDemand) identCount++; // one more ident than dots
- /* count identifiers */
- int max = importName.length;
- int identCount = 0;
- for (int i = 0; i < max; i++) {
- if (importName[i] == '.')
- identCount++;
- }
- /* import on demand? */
- boolean onDemand = importName[max - 1] == '*';
- if (!onDemand)
- identCount++; // one more ident than dots
+ long[] positions = new long[identCount];
+ long position = (long) start << 32 + end;
+ for (int i = 0; i < identCount; i++){
+ positions[i] = position;
+ }
+ return new ImportReference(
+ CharOperation.splitOn('.', importName, 0, max - (onDemand ? 3 : 1)),
+ positions,
+ onDemand);
+}
+/*
+ * Build a type reference from a readable name, e.g. java.lang.Object[][]
+ */
+private static TypeReference createTypeReference(
+ char[] typeSignature,
+ int start,
+ int end) {
- long[] positions = new long[identCount];
- long position = (long) start << 32 + end;
- for (int i = 0; i < identCount; i++) {
- positions[i] = position;
+ /* count identifiers and dimensions */
+ int max = typeSignature.length;
+ int dimStart = max;
+ int dim = 0;
+ int identCount = 1;
+ for (int i = 0; i < max; i++) {
+ switch (typeSignature[i]) {
+ case '[' :
+ if (dim == 0)
+ dimStart = i;
+ dim++;
+ break;
+ case '.' :
+ identCount++;
+ break;
}
- return new ImportReference(
- CharOperation.splitOn('.', importName, 0, max - (onDemand ? 3 : 1)),
- positions,
- onDemand);
}
-
- /*
- * Build a type reference from a readable name, e.g. java.lang.Object[][]
- */
- private static TypeReference createTypeReference(
- char[] typeSignature,
- int start,
- int end) {
-
- /* count identifiers and dimensions */
- int max = typeSignature.length;
- int dimStart = max;
- int dim = 0;
- int identCount = 1;
- for (int i = 0; i < max; i++) {
- switch (typeSignature[i]) {
- case '[' :
- if (dim == 0)
- dimStart = i;
- dim++;
- break;
- case '.' :
- identCount++;
- break;
- }
+ /* rebuild identifiers and dimensions */
+ if (identCount == 1) { // simple type reference
+ if (dim == 0) {
+ return new SingleTypeReference(typeSignature, (long)start << 32 + end);
+ } else {
+ char[] identifier = new char[dimStart];
+ System.arraycopy(typeSignature, 0, identifier, 0, dimStart);
+ return new ArrayTypeReference(identifier, dim, (long)start << 32 + end);
}
- /* rebuild identifiers and dimensions */
- if (identCount == 1) { // simple type reference
- if (dim == 0) {
- return new SingleTypeReference(typeSignature, (long) start << 32 + end);
- } else {
- char[] identifier = new char[dimStart];
- System.arraycopy(typeSignature, 0, identifier, 0, dimStart);
- return new ArrayTypeReference(identifier, dim, (long) start << 32 + end);
- }
- } else { // qualified type reference
- long[] positions = new long[identCount];
- long pos = (long) start << 32 + end;
- for (int i = 0; i < identCount; i++) {
- positions[i] = pos;
- }
- char[][] identifiers =
- CharOperation.splitOn('.', typeSignature, 0, dimStart - 1);
- if (dim == 0) {
- return new QualifiedTypeReference(identifiers, positions);
- } else {
- return new ArrayQualifiedTypeReference(identifiers, dim, positions);
- }
+ } else { // qualified type reference
+ long[] positions = new long[identCount];
+ long pos = (long)start << 32 + end;
+ for(int i = 0; i < identCount; i++){
+ positions[i] = pos;
+ }
+ char[][] identifiers = CharOperation.splitOn('.', typeSignature, 0, dimStart - 1);
+ if (dim == 0){
+ return new QualifiedTypeReference(identifiers, positions);
+ } else {
+ return new ArrayQualifiedTypeReference(identifiers, dim, positions);
}
}
-} \ No newline at end of file
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalSymbols.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalSymbols.java
index 713b71794c..f281179f9d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalSymbols.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalSymbols.java
@@ -10,110 +10,109 @@ This integer is used to represent the terminal when computing a parsing action.
public interface TerminalSymbols {
- public final static int
- TokenNameIdentifier = 5,
- TokenNameabstract = 98,
- TokenNameassert = 118,
- TokenNameboolean = 18,
- TokenNamebreak = 119,
- TokenNamebyte = 19,
- TokenNamecase = 211,
- TokenNamecatch = 225,
- TokenNamechar = 20,
- TokenNameclass = 165,
- TokenNamecontinue = 120,
- TokenNamedefault = 212,
- TokenNamedo = 121,
- TokenNamedouble = 21,
- TokenNameelse = 213,
- TokenNameextends = 243,
- TokenNamefalse = 37,
- TokenNamefinal = 99,
- TokenNamefinally = 226,
- TokenNamefloat = 22,
- TokenNamefor = 122,
- TokenNameif = 123,
- TokenNameimplements = 267,
- TokenNameimport = 191,
- TokenNameinstanceof = 65,
- TokenNameint = 23,
- TokenNameinterface = 180,
- TokenNamelong = 24,
- TokenNamenative = 100,
- TokenNamenew = 32,
- TokenNamenull = 38,
- TokenNamepackage = 214,
- TokenNameprivate = 101,
- TokenNameprotected = 102,
- TokenNamepublic = 103,
- TokenNamereturn = 124,
- TokenNameshort = 25,
- TokenNamestatic = 94,
- TokenNamestrictfp = 104,
- TokenNamesuper = 34,
- TokenNameswitch = 125,
- TokenNamesynchronized = 85,
- TokenNamethis = 35,
- TokenNamethrow = 126,
- TokenNamethrows = 227,
- TokenNametransient = 105,
- TokenNametrue = 39,
- TokenNametry = 127,
- TokenNamevoid = 26,
- TokenNamevolatile = 106,
- TokenNamewhile = 117,
- TokenNameIntegerLiteral = 40,
- TokenNameLongLiteral = 41,
- TokenNameFloatingPointLiteral = 42,
- TokenNameDoubleLiteral = 43,
- TokenNameCharacterLiteral = 44,
- TokenNameStringLiteral = 45,
- TokenNamePLUS_PLUS = 1,
- TokenNameMINUS_MINUS = 2,
- TokenNameEQUAL_EQUAL = 33,
- TokenNameLESS_EQUAL = 66,
- TokenNameGREATER_EQUAL = 67,
- TokenNameNOT_EQUAL = 36,
- TokenNameLEFT_SHIFT = 14,
- TokenNameRIGHT_SHIFT = 11,
- TokenNameUNSIGNED_RIGHT_SHIFT = 12,
- TokenNamePLUS_EQUAL = 168,
- TokenNameMINUS_EQUAL = 169,
- TokenNameMULTIPLY_EQUAL = 170,
- TokenNameDIVIDE_EQUAL = 171,
- TokenNameAND_EQUAL = 172,
- TokenNameOR_EQUAL = 173,
- TokenNameXOR_EQUAL = 174,
- TokenNameREMAINDER_EQUAL = 175,
- TokenNameLEFT_SHIFT_EQUAL = 176,
- TokenNameRIGHT_SHIFT_EQUAL = 177,
- TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL = 178,
- TokenNameOR_OR = 80,
- TokenNameAND_AND = 79,
- TokenNamePLUS = 3,
- TokenNameMINUS = 4,
- TokenNameNOT = 71,
- TokenNameREMAINDER = 9,
- TokenNameXOR = 63,
- TokenNameAND = 62,
- TokenNameMULTIPLY = 8,
- TokenNameOR = 70,
- TokenNameTWIDDLE = 72,
- TokenNameDIVIDE = 10,
- TokenNameGREATER = 68,
- TokenNameLESS = 69,
- TokenNameLPAREN = 7,
- TokenNameRPAREN = 86,
- TokenNameLBRACE = 110,
- TokenNameRBRACE = 95,
- TokenNameLBRACKET = 15,
- TokenNameRBRACKET = 166,
- TokenNameSEMICOLON = 64,
- TokenNameQUESTION = 81,
- TokenNameCOLON = 154,
- TokenNameCOMMA = 90,
- TokenNameDOT = 6,
- TokenNameEQUAL = 167,
- TokenNameEOF = 158,
- TokenNameERROR = 307;
+ public final static int
+ TokenNameIdentifier = 5,
+ TokenNameabstract = 92,
+ TokenNameboolean = 18,
+ TokenNamebreak = 118,
+ TokenNamebyte = 19,
+ TokenNamecase = 211,
+ TokenNamecatch = 225,
+ TokenNamechar = 20,
+ TokenNameclass = 163,
+ TokenNamecontinue = 119,
+ TokenNamedefault = 212,
+ TokenNamedo = 120,
+ TokenNamedouble = 21,
+ TokenNameelse = 213,
+ TokenNameextends = 241,
+ TokenNamefalse = 37,
+ TokenNamefinal = 93,
+ TokenNamefinally = 226,
+ TokenNamefloat = 22,
+ TokenNamefor = 121,
+ TokenNameif = 122,
+ TokenNameimplements = 265,
+ TokenNameimport = 190,
+ TokenNameinstanceof = 65,
+ TokenNameint = 23,
+ TokenNameinterface = 184,
+ TokenNamelong = 24,
+ TokenNamenative = 94,
+ TokenNamenew = 33,
+ TokenNamenull = 38,
+ TokenNamepackage = 214,
+ TokenNameprivate = 95,
+ TokenNameprotected = 96,
+ TokenNamepublic = 97,
+ TokenNamereturn = 123,
+ TokenNameshort = 25,
+ TokenNamestatic = 98,
+ TokenNamestrictfp = 99,
+ TokenNamesuper = 35,
+ TokenNameswitch = 124,
+ TokenNamesynchronized = 84,
+ TokenNamethis = 36,
+ TokenNamethrow = 125,
+ TokenNamethrows = 227,
+ TokenNametransient = 100,
+ TokenNametrue = 39,
+ TokenNametry = 126,
+ TokenNamevoid = 26,
+ TokenNamevolatile = 101,
+ TokenNamewhile = 117,
+ TokenNameIntegerLiteral = 40,
+ TokenNameLongLiteral = 41,
+ TokenNameFloatingPointLiteral = 42,
+ TokenNameDoubleLiteral = 43,
+ TokenNameCharacterLiteral = 44,
+ TokenNameStringLiteral = 45,
+ TokenNamePLUS_PLUS = 1,
+ TokenNameMINUS_MINUS = 2,
+ TokenNameEQUAL_EQUAL = 32,
+ TokenNameLESS_EQUAL = 66,
+ TokenNameGREATER_EQUAL = 67,
+ TokenNameNOT_EQUAL = 34,
+ TokenNameLEFT_SHIFT = 13,
+ TokenNameRIGHT_SHIFT = 11,
+ TokenNameUNSIGNED_RIGHT_SHIFT = 12,
+ TokenNamePLUS_EQUAL = 166,
+ TokenNameMINUS_EQUAL = 167,
+ TokenNameMULTIPLY_EQUAL = 168,
+ TokenNameDIVIDE_EQUAL = 169,
+ TokenNameAND_EQUAL = 170,
+ TokenNameOR_EQUAL = 171,
+ TokenNameXOR_EQUAL = 172,
+ TokenNameREMAINDER_EQUAL = 173,
+ TokenNameLEFT_SHIFT_EQUAL = 174,
+ TokenNameRIGHT_SHIFT_EQUAL = 175,
+ TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL = 176,
+ TokenNameOR_OR = 79,
+ TokenNameAND_AND = 78,
+ TokenNamePLUS = 3,
+ TokenNameMINUS = 4,
+ TokenNameNOT = 71,
+ TokenNameREMAINDER = 8,
+ TokenNameXOR = 63,
+ TokenNameAND = 62,
+ TokenNameMULTIPLY = 7,
+ TokenNameOR = 70,
+ TokenNameTWIDDLE = 72,
+ TokenNameDIVIDE = 9,
+ TokenNameGREATER = 68,
+ TokenNameLESS = 69,
+ TokenNameLPAREN = 10,
+ TokenNameRPAREN = 86,
+ TokenNameLBRACE = 109,
+ TokenNameRBRACE = 102,
+ TokenNameLBRACKET = 14,
+ TokenNameRBRACKET = 164,
+ TokenNameSEMICOLON = 64,
+ TokenNameQUESTION = 80,
+ TokenNameCOLON = 153,
+ TokenNameCOMMA = 88,
+ TokenNameDOT = 6,
+ TokenNameEQUAL = 165,
+ TokenNameEOF = 156,
+ TokenNameERROR = 304;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
index 85a6eefef9..48eab10b64 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
index 8f2dd396ea..434680d292 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
index 99fc9e41da..b9da6ff235 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
index 7d532e6ecd..f60de39fd6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
index bfe7cb4d67..d180c8d55c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
index f5a5c195c9..1d4776dfe5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
@@ -45,7 +45,7 @@ public String errorReportSource(ICompilationUnit compilationUnit) {
//sanity .....
if ((startPosition > endPosition)
|| ((startPosition <= 0) && (endPosition <= 0)))
- return Util.bind("problem.noSourceInformation"); //$NON-NLS-1$
+ return Util.bind("problem.noSourceInformation"/*nonNLS*/);
//regular behavior....(slow code)
@@ -111,8 +111,8 @@ public String errorReportSource(ICompilationUnit compilationUnit) {
//resize underneathto remove 'null' chars
System.arraycopy(underneath, 0, underneath = new char[pos], 0, pos);
- return " " + Util.bind("problem.atLine",String.valueOf(line)) + //$NON-NLS-2$ //$NON-NLS-1$
- "\n\t" + new String(extract) + "\n\t" + new String(underneath); //$NON-NLS-2$ //$NON-NLS-1$
+ return " "/*nonNLS*/ + Util.bind("problem.atLine"/*nonNLS*/,String.valueOf(line)) +
+ "\n\t"/*nonNLS*/ + new String(extract) + "\n\t"/*nonNLS*/ + new String(underneath);
}
/**
* Answer back the original arguments recorded into the problem.
@@ -212,13 +212,13 @@ public void setSourceStart(int sourceStart) {
}
public String toString() {
- String s = "Pb(" + (id & IgnoreCategoriesMask) + ") "; //$NON-NLS-1$ //$NON-NLS-2$
+ String s = "Pb("/*nonNLS*/ + (id & IgnoreCategoriesMask) + ") "/*nonNLS*/;
if (message != null) {
s += message;
} else {
if (arguments != null)
for (int i = 0; i < arguments.length; i++)
- s += " " + arguments[i]; //$NON-NLS-1$
+ s += " "/*nonNLS*/ + arguments[i];
}
return s;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
index 02349c61b5..b08aab3e3d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
@@ -70,9 +70,9 @@ public final String getLocalizedMessage(int id, String[] problemArguments) {
String message =
messageTemplates[(id & ProblemIrritants.IgnoreCategoriesMask)];
if (message == null) {
- return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$
+ return "Unable to retrieve the error message for problem id: "/*nonNLS*/
+ id
- + ". Check compiler resources."; //$NON-NLS-1$
+ + ". Check compiler resources."/*nonNLS*/;
}
int length = message.length();
@@ -87,9 +87,9 @@ public final String getLocalizedMessage(int id, String[] problemArguments) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- return "Corrupted compiler resources for problem id: " //$NON-NLS-1$
+ return "Corrupted compiler resources for problem id: "/*nonNLS*/
+ (id & ProblemIrritants.IgnoreCategoriesMask)
- + ". Check compiler resources."; //$NON-NLS-1$
+ + ". Check compiler resources."/*nonNLS*/;
}
} else {
output.append(message.substring(end, length));
@@ -115,7 +115,7 @@ public final String localizedMessage(IProblem problem) {
* to the current Locale.
*/
public static String[] loadMessageTemplates(Locale loc) {
- ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.jdt.internal.compiler.problem.Messages", loc); //$NON-NLS-1$
+ ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.jdt.internal.compiler.problem.Messages"/*nonNLS*/, loc);
String[] templates = new String[500];
for (int i = 0, max = templates.length; i < max; i++) {
try {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemIrritants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemIrritants.java
index 6b857eae2d..e41300550a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemIrritants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemIrritants.java
@@ -276,7 +276,4 @@ public interface ProblemIrritants { // max: 500
//constant pool
final int TooManyConstantsInConstantPool = Internal + 430;
-
- // identifiers 1.4 assert feature
- final int UseAssertAsAnIdentifier = Internal + 440;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index cf21d9e67b..df2222cef1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -167,7 +167,7 @@ public void cannotAssignToFinalField(FieldBinding field, AstNode location) {
this.handle(
FinalFieldAssignment,
new String[] {
- (field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
+ (field.declaringClass == null ? "array"/*nonNLS*/ : new String(field.declaringClass.readableName())),
new String(field.readableName())},
location.sourceStart(),
location.sourceEnd());
@@ -428,14 +428,7 @@ public int computeSeverity(int problemId){
return Warning;
}
return Ignore;
- case UseAssertAsAnIdentifier :
- if ((errorThreshold & AssertUsedAsAnIdentifier) != 0){
- return Error;
- }
- if ((warningThreshold & AssertUsedAsAnIdentifier) != 0){
- return Warning;
- }
- return Ignore;
+
default:
return Error;
}
@@ -466,10 +459,10 @@ public void constantOutOfFormat(NumberLiteral lit) {
final int radix;
if ((source[1] == 'x') || (source[1] == 'X')) {
radix = 16;
- Radix = "Hexa"; //$NON-NLS-1$
+ Radix = "Hexa"/*nonNLS*/;
} else {
radix = 8;
- Radix = "Octal"; //$NON-NLS-1$
+ Radix = "Octal"/*nonNLS*/;
}
//look for the first digit that is incorrect
int place = -1;
@@ -482,7 +475,7 @@ public void constantOutOfFormat(NumberLiteral lit) {
this.handle(
NumericValueOutOfRange,
- new String[] {Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] {Radix + " "/*nonNLS*/ + new String(source) + " (digit "/*nonNLS*/ + new String(new char[] {source[place]}) + ")"/*nonNLS*/},
lit.sourceStart,
lit.sourceEnd);
return;
@@ -647,7 +640,7 @@ public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeB
StringBuffer buffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
if (i != 0)
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
buffer.append(new String(params[i].readableName()));
}
@@ -660,7 +653,7 @@ public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeB
public void errorThisSuperInStatic(AstNode reference) {
this.handle(
ThisInStaticContext,
- new String[] {reference.isSuper() ? "super" : "this"}, //$NON-NLS-2$ //$NON-NLS-1$
+ new String[] {reference.isSuper() ? "super"/*nonNLS*/ : "this"/*nonNLS*/},
reference.sourceStart,
reference.sourceEnd);
}
@@ -796,7 +789,7 @@ public void hidingEnclosingType(TypeDeclaration typeDecl) {
public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
int start = 0;
int end = 0;
- String typeName = ""; //$NON-NLS-1$
+ String typeName = ""/*nonNLS*/;
if (reference == null) { // can only happen when java.lang.Object is busted
start = sourceType.sourceStart();
@@ -1080,7 +1073,7 @@ public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type,
.append('.')
.append(inheritedMethods[i].readableName());
if (i != 0)
- methodSignatures.append(", "); //$NON-NLS-1$
+ methodSignatures.append(", "/*nonNLS*/);
}
this.handle(
@@ -1195,7 +1188,7 @@ public void invalidEnclosingType(Expression expression, TypeBinding type, TypeBi
this.handle(
flag,
- new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
+ new String[] {new String(enclosingType.readableName()) + "."/*nonNLS*/ + new String(type.readableName())},
expression.sourceStart,
expression.sourceEnd);
}
@@ -1406,7 +1399,7 @@ public void invalidOperator(BinaryExpression expression, TypeBinding leftType, T
InvalidOperator,
new String[] {
expression.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ new String(leftType.readableName()) + ", "/*nonNLS*/ + new String(rightType.readableName())},
expression.sourceStart,
expression.sourceEnd);
}
@@ -1415,7 +1408,7 @@ public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, Typ
InvalidOperator,
new String[] {
assign.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ new String(leftType.readableName()) + ", "/*nonNLS*/ + new String(rightType.readableName())},
assign.sourceStart,
assign.sourceEnd);
}
@@ -1611,7 +1604,7 @@ public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodD
methodDecl.sourceEnd());
}
public void needImplementation() {
- this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
+ this.abortDueToInternalError(Util.bind("abort.missingCode"/*nonNLS*/));
}
public void needToEmulateFieldReadAccess(FieldBinding field, AstNode location) {
this.handle(
@@ -1727,7 +1720,7 @@ private String parametersAsString(MethodBinding method) {
StringBuffer buffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
if (i != 0)
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
buffer.append(new String(params[i].readableName()));
}
return buffer.toString();
@@ -1757,20 +1750,20 @@ public void parseError(
StringBuffer list = new StringBuffer(20);
for (int i = 0, max = possibleTokens.length; i < max; i++) {
if (i > 0)
- list.append(", "); //$NON-NLS-1$
+ list.append(", "/*nonNLS*/);
list.append('"');
list.append(possibleTokens[i]);
list.append('"');
}
//extract the literal when it's a literal
- if ((errorTokenName.equals("IntegerLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("LongLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("FloatingPointLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("DoubleLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("StringLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("CharacterLiteral")) || //$NON-NLS-1$
- (errorTokenName.equals("Identifier"))) { //$NON-NLS-1$
+ if ((errorTokenName.equals("IntegerLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("LongLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("FloatingPointLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("DoubleLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("StringLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("CharacterLiteral"/*nonNLS*/)) ||
+ (errorTokenName.equals("Identifier"/*nonNLS*/))) {
errorTokenName = new String(currentTokenSource);
}
@@ -2162,15 +2155,6 @@ public void unusedLocalVariable(LocalDeclaration localDecl) {
localDecl.sourceStart,
localDecl.sourceEnd);
}
-
-public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
- this.handle(
- UseAssertAsAnIdentifier,
- new String[0],
- sourceStart,
- sourceEnd);
-}
-
public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
this.handle(
VariableTypeCannotBeVoid,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
new file mode 100644
index 0000000000..dd7f42f915
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -0,0 +1,235 @@
+0 = {0}
+1 = super cannot be used in java.lang.Object
+2 = {0} cannot be resolved or is not a type
+3 = The type {0} is not visible
+4 = The type {0} is ambiguous
+5 = The type {0} is deprecated
+6 = The type {0} is an incorrectly specified nested type; replace the '$' with '.'
+15 = Incompatible operand types {0} and {1}
+16 = Incompatible conditional operand types {0} and {1}
+17 = Type mismatch: cannot convert from {0} to {1}
+20 = No enclosing instance of the type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
+21 = Must explicitly qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
+22 = No enclosing instance of the type {0} is accessible in scope
+23 = Illegal enclosing instance specification for type {0}
+24 = Cannot define static initializer in inner type {0}
+25 = Cannot refer to a non-final variable {0} inside an inner class defined in a different method
+26 = The member interface {0} can only be defined inside a top-level class or interface
+27 = Cannot use an expression of the type {0} as a valid enclosing instance
+28 = The default constructor of an anonymous type cannot throw exception {0}. Define an explicit constructor instead
+29 = An anonymous class cannot subclass the final class {0}
+50 = {0} cannot be resolved
+51 = The local variable {0} may not have been initialized
+52 = void is an invalid type for the variable {0}
+53 = An array of void is an invalid type for the variable {0}
+54 = An array of void is an invalid type
+55 = Duplicate local variable {0}
+56 = Duplicate argument {0}
+57 = The final local variable {0} may already have been assigned
+60 = Cannot assign to the final local variable {0} defined outside this inner class
+61 = The local variable {0} is never used
+62 = The argument {0} is never used
+63 = Code of method {0} is exceeding the 65535 bytes limit
+64 = Code for the static initializer is exceeding the 65535 bytes limit
+65 = Too many arguments, parameter {0} is exceeding the limit of 255 words eligible for method arguments
+66 = Too many local variables, local variable {0} is exceeding the limit of 65535 words eligible for method local variables
+70 = {0} cannot be resolved or is not a field
+71 = The field {0} is not visible
+72 = The field {0} is ambiguous
+73 = The field {0}.{1} is deprecated
+74 = Cannot make a static reference to the non-static field {0}
+75 = Cannot reference a field before it is defined
+80 = Cannot assign a value to the final field {0}.{1}
+81 = The blank final field {0} may not have been initialized
+82 = The final field {0} may already have been assigned
+100 = The method {1}({2}) is undefined for the type {0}
+101 = The method {1}({2}) from the type {0} is not visible
+102 = The method {1}({2}) is ambiguous for the type {0}
+103 = The method {1}({2}) from the type {0} is deprecated
+104 = Cannot directly invoke the abstract method {1}({2}) for the type {0}
+105 = Void methods cannot return a value
+106 = Cannot return a void result
+107 = The method requires a body instead of a semicolon
+108 = Must return a result of type {0}
+110 = Method has a constructor name
+111 = Return type for the method is missing
+112 = Native methods do not specify a body
+113 = Abstract methods do not specify a body
+114 = Cannot send {1}({2}) to the primitive type {0}
+115 = The method {1}({2}) in the type {0} is not applicable for the arguments ({3})
+116 = Cannot send {1}({2}) to the array type {0}
+130 = The constructor {0}({1}) is undefined
+131 = The constructor {0}({1}) is not visible
+132 = The constructor {0}({1}) is ambiguous
+133 = The constructor {0}({1}) is deprecated
+135 = Cannot refer to an instance field {0} while explicitly invoking a constructor
+136 = Cannot refer to an instance method while explicitly invoking a constructor
+137 = Recursive constructor invocation {0}({1})
+138 = Cannot refer to 'this' nor 'super' while explicitly invoking a constructor
+150 = The type of the expression must be an array type but it resolved to {0}
+151 = Must explicitly convert the char[] to a String
+152 = String constant is exceeding the limit of 65535 bytes of UTF8 encoding
+153 = case expressions must be constant expressions
+154 = {0} is out of range
+156 = Cannot cast from {0} to {1}
+157 = Cannot instantiate {0}
+158 = Cannot define dimension expressions when an array initializer is provided
+159 = Must provide either dimension expressions or an array initializer
+160 = The operator {0} is undefined for the argument type(s) {1}
+161 = Unreachable code
+162 = Cannot return from within an initializer
+163 = Initializer does not complete normally
+164 = Exception {0} thrown within an initializer must be handled locally
+165 = Catch block is hidden by another one in the same try statement
+166 = Duplicate default case
+167 = Unreachable catch block
+168 = Unhandled exception type {0}
+169 = case constant must be a char, byte, short, or int instead of {0}
+170 = Duplicate case {0}
+171 = Duplicate label {0}
+172 = Missing valid breakable location
+173 = Missing loop-continuation point
+174 = Missing label {0}
+175 = {0} is not a valid type's argument for the synchronized statement
+176 = null is not a valid argument for the synchronized statement
+177 = Cannot throw null
+190 = Read access to enclosing field {0}.{1} is emulated by a synthetic accessor method
+191 = Write access to enclosing field {0}.{1} is emulated by a synthetic accessor method
+192 = Access to enclosing method {1}({2}) from the type {0} is emulated by a synthetic accessor method
+193 = Access to enclosing constructor {0}({1}) is emulated by a synthetic accessor method
+195 = The method {1} is defined in an inherited type and an enclosing scope
+196 = The field {0} is defined in an inherited type and an enclosing scope
+197 = The type {0} is defined in an inherited type and an enclosing scope
+
+200 = Cannot use {0} in a static context
+201 = The method {1}({2}) from the type {0} is not static
+202 = Cannot specify an array dimension after an empty dimension
+203 = Invalid cast type expression
+204 = Syntax error on token "{0}", {1} expected
+205 = Syntax error on token "{0}", no accurate correction available
+206 = Invalid argument to operation ++/--
+207 = Interfaces cannot have constructors
+208 = Array constants can only be used in initializers
+220 = Unmatched bracket
+221 = The primitive type {0} of {1} does not have a field {2}
+222 = Invalid expression as statement
+
+250 = Unexpected end of file
+251 = Invalid hexa literal number
+252 = Invalid octal literal number
+253 = Invalid character constant
+254 = Invalid escape sequence (valid ones are \\b \\t \\n \\f \\r \\" \\' \\\\ )
+255 = Invalid input
+256 = Invalid unicode
+257 = Invalid float literal number
+258 = Null source string
+259 = String literal is not properly closed by a double-quote
+260 = Unexpected end of comment
+261 = Non-externalized string literal; it should immediately be followed by /*nonNLS*/
+
+300 = The interface {0} cannot define an initializer
+301 = Duplicate modifier for the type {0}
+302 = Illegal modifier for the class {0}; only public, abstract & final are permitted
+303 = Illegal modifier for the interface {0}; only public & abstract are permitted
+304 = Illegal modifier for the member class {0}; only public, protected, private, static, abstract & final are permitted
+305 = Illegal modifier for the member interface {0}; only public, protected, private, static & abstract are permitted
+306 = Illegal modifier for the local class {0}; only one of abstract or final is permitted
+308 = The class {0} can be either abstract or final, not both
+309 = The interface member type {0} can only be public
+310 = The member type {0} can only set one of public / protected / private
+311 = The member type {0} cannot be declared static; static types can only be declared in static or top level types
+312 = The interface {0} cannot be the superclass of {1}; a superclass must be a class
+313 = The type {1} cannot subclass the final class {0}
+314 = Duplicate interface {0} for the type {1}
+315 = The class {0} cannot be a superinterface of {1}; a superinterface must be an interface
+316 = {1} causes a cycle - the type {0} cannot extend/implement itself or one of its own member types
+317 = A cycle exists in the type hierarchy between {0} and {1}
+318 = Nested type {0} hides an enclosing type
+319 = Duplicate nested type {0}
+320 = Cannot throw the type {0}
+321 = The package {0} collides with a type
+322 = The type {1} collides with a package
+323 = The type {1} is already defined
+324 = This compilation unit indirectly references the missing type {0} (typically some required class file is referencing a type outside the classpath)
+325 = The public type {1} must be defined in its own file
+326 = A package must be specified in {0} or a default package created
+327 = The hierarchy of the type {0} is inconsistent
+330 = {0} cannot be resolved or is not a valid superclass
+331 = Superclass {0} is not visible
+332 = Superclass {0} is ambiguous
+333 = Superclass {0} is an incorrectly specified nested type; replace the '$' with '.'
+334 = Superclass {0} is defined in an inherited type and an enclosing scope
+335 = {0} cannot be resolved or is not a valid superinterface
+336 = Superinterface {0} is not visible
+337 = Superinterface {0} is ambiguous
+338 = Superinterface {0} is an incorrectly specified nested type; replace the '$' with '.'
+339 = Superinterface {0} is defined in an inherited type and an enclosing scope
+340 = Duplicate field {0}.{1}
+341 = Duplicate modifier for the field {0}
+342 = Illegal modifier for the field {0}; only public, protected, private, static, final, transient & volatile are permitted
+343 = Illegal modifier for the interface field {0}; only public, static & final are permitted
+344 = The field {0} can only set one of public / protected / private
+345 = The field {0} can be either final or volatile, not both
+346 = The field {0} cannot be declared static; static fields can only be declared in static or top level types
+350 = {2} cannot be resolved (or is not a valid type) for the field {1}.{0}
+351 = The type {2} is not visible for the field {1}.{0}
+352 = The type {2} is ambiguous for the field {1}.{0}
+353 = The field type {2} is an incorrectly specified nested type; replace the '$' with '.'
+354 = The field type {2} is defined in an inherited type and an enclosing scope
+355 = Duplicate method {0} in type {1}
+356 = Illegal modifier for argument {2}; only final is permitted
+357 = Duplicate modifier for the method {1} in type {0}
+358 = Illegal modifier for the method {1} in type {0}
+359 = Illegal modifier for the interface method {1} in type {0}; only public & abstract are permitted
+360 = The method {1} in type {0} can only set one of public / protected / private
+361 = The method {1} cannot be declared static; static methods can only be declared in a static or top level type
+362 = The abstract method {1} in type {0} can only set a visibility modifier, one of public or protected
+363 = The abstract method {1} in type {0} can only be defined by an abstract class
+364 = void is an invalid type for the argument {1} of the method {0}
+365 = An array of void is an invalid type for the argument {1} of the method {0}
+366 = An array of void is an invalid return type for the method {0}
+367 = The native method {1} cannot also be declared strictfp
+370 = {2} cannot be resolved (or is not a valid type) for the argument {1} of the method {0}
+371 = The type {2} is not visible for the argument {1} of the method {0}
+372 = The type {2} is ambiguous for the argument {1} of the method {0}
+373 = The argument type {2} is an incorrectly specified nested type; replace the '$' with '.'
+374 = The argument type {2} is defined in an inherited type and an enclosing scope
+375 = {1} cannot be resolved (or is not an exception type) for the method {0}
+376 = The exception type {1} is not visible for the method {0}
+377 = The exception type {1} is ambiguous for the method {0}
+378 = The exception type {1} is an incorrectly specified nested type; replace the '$' with '.'
+379 = The exception type {1} is defined in an inherited type and an enclosing scope
+380 = {1} cannot be resolved (or is not a valid return type) for the method {0}
+381 = The return type {1} is not visible for the method {0}
+382 = The return type {1} is ambiguous for the method {0}
+383 = The return type {1} is an incorrectly specified nested type; replace the '$' with '.'
+384 = The return type {1} is defined in an inherited type and an enclosing scope
+385 = The import {0} conflicts with a type defined in the same file
+386 = The import {0} collides with another imported type
+387 = Only a type can be imported. {0} resolves to a package
+390 = The import {0} cannot be resolved
+391 = The imported type {0} is not visible
+392 = The imported type {0} is ambiguous
+393 = The type {0} is an incorrectly specified nested type; replace the '$' with '.'
+394 = The type {0} is defined in an inherited type and an enclosing scope
+395 = Duplicate modifier for the variable {0}
+396 = Illegal modifier for the variable {0}; only final is permitted
+
+400 = Must implement the inherited abstract method {0}
+401 = Cannot override the final method from {0}
+402 = Exception {0} is not compatible with throws clause in {1}
+403 = Exception {0} in throws clause of {1} is not compatible with {2}
+404 = The return type is incompatible with {0}
+405 = The method {0} cannot hide the public abstract method in {1}
+406 = This instance method cannot override the static method from {0}
+407 = This static method cannot hide the instance method from {0}
+408 = The static method {0} conflicts with the abstract method in {1}
+409 = Cannot reduce the visibility of the inherited method from {0}
+410 = The method {0} does not override the inherited method from {1} since it is private to a different package.
+411 = Must implement the inherited abstract method {1}, but cannot override it since it is not visible from {0}. Either make the type abstract or make the inherited method visible.
+412 = Overrides deprecated method from {0}
+
+420 = Code snippet support cannot find the class {0}
+421 = Code snippet support cannot find the method {0}.{1}({2})
+
+430 = Too many constants, the constant pool for {0} would exceed 65536 entries. \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
index 116c38b760..a66de9c206 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
@@ -542,7 +542,7 @@ final static public char[] toLowerCase(char[] chars) {
final static public String toString(char[][] array) {
char[] result = concatWith(array, '.');
if (result == null)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
return new String(result);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
index 90c20e7398..e1b870db89 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
@@ -77,11 +77,11 @@ public int size() {
return elementSize;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
Object object;
for (int i = 0, length = valueTable.length; i < length; i++)
if ((object = valueTable[i]) != null)
- s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += keyTable[i] + " -> "/*nonNLS*/ + object.toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
index 1191c2c249..8143a934ca 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
@@ -78,11 +78,11 @@ public int size() {
return elementSize;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
Object object;
for (int i = 0, length = valueTable.length; i < length; i++)
if ((object = valueTable[i]) != null)
- s += new String(keyTable[i]) + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += new String(keyTable[i]) + " -> "/*nonNLS*/ + object.toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
index 8990383018..2e4308f2f0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
@@ -79,11 +79,11 @@ public int size() {
return elementSize;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
PackageBinding pkg;
for (int i = 0, length = valueTable.length; i < length; i++)
if ((pkg = valueTable[i]) != null)
- s += pkg.toString() + "\n"; //$NON-NLS-1$
+ s += pkg.toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
index 60bdc8ebcc..487b841a21 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
@@ -79,11 +79,11 @@ public int size() {
return elementSize;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
ReferenceBinding type;
for (int i = 0, length = valueTable.length; i < length; i++)
if ((type = valueTable[i]) != null)
- s += type.toString() + "\n"; //$NON-NLS-1$
+ s += type.toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
index a30e68d606..c47e0ab5b5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
@@ -61,9 +61,9 @@ public void removeAll() {
size = 0;
}
public String toString() {
- String s = ""; //$NON-NLS-1$
+ String s = ""/*nonNLS*/;
for (int i = 0; i < size; i++)
- s += elements[i].toString() + "\n"; //$NON-NLS-1$
+ s += elements[i].toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
index 0b7f0d27e9..1cb38e3d16 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
@@ -57,7 +57,7 @@ public void removeAll() {
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < size; i++) {
- buffer.append(elements[i]).append("\n"); //$NON-NLS-1$
+ buffer.append(elements[i]).append("\n"/*nonNLS*/);
}
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
index 21552a4aea..5334c591f5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -11,7 +11,7 @@ import java.util.ResourceBundle;
public class Util {
/* Bundle containing messages */
protected static ResourceBundle bundle;
- private final static String bundleName = "org.eclipse.jdt.internal.compiler.util.Messages"; //$NON-NLS-1$
+ private final static String bundleName = "org.eclipse.jdt.internal.compiler.util.Messages"/*nonNLS*/;
static {
relocalize();
}
@@ -35,14 +35,14 @@ public static String bind(String id, String binding) {
*/
public static String bind(String id, String[] bindings) {
if (id == null)
- return "No message available"; //$NON-NLS-1$
+ return "No message available"/*nonNLS*/;
String message = null;
try {
message = bundle.getString(id);
} catch (MissingResourceException e) {
// If we got an exception looking for the message, fail gracefully by just returning
// the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
+ return "Missing message: "/*nonNLS*/ + id + " in: "/*nonNLS*/ + bundleName;
}
if (bindings == null)
return message;
@@ -61,7 +61,7 @@ public static String bind(String id, String[] bindings) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
+ output.append("{missing "/*nonNLS*/ + Integer.toString(index) + "}"/*nonNLS*/);
}
} else {
output.append(message.substring(end, length));
@@ -87,6 +87,6 @@ public static void relocalize() {
bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
}
public static void main(String[] arg){
- System.out.println(bind("test")); //$NON-NLS-1$
+ System.out.println(bind("test"/*nonNLS*/));
}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
new file mode 100644
index 0000000000..71f36eac67
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
@@ -0,0 +1,61 @@
+### Eclipse Java Core Compiler messages.
+
+### compilation
+compilation.unresolvedProblem = Unresolved compilation problem: \n
+compilation.unresolvedProblems = Unresolved compilation problems: \n
+compilation.request = request {0}/{1} : {2}
+compilation.process = process {0}/{1} : {2}
+compilation.done = done {0}/{1} : {2}
+compilation.units = {0} units compiled
+compilation.unit = {0} unit compiled
+compilation.internalError = Internal compiler error
+
+### output
+output.isFile = The outDir is a file : {0}
+output.isFileNotDirectory = The outDir is a file not a directory.
+output.dirName = The output dir name is : {0}
+output.notValidAll = The outDir is not a valid directory name. All the directories cannot be created.
+output.fileName = file name : {0}
+output.notValid = The outDir is not a valid directory name. The directory cannot be created.
+
+### problem
+problem.noSourceInformation = \n!! no source information available !!
+problem.atLine = (at line {0})
+
+### abort
+abort.invalidAttribute = SANITY CHECK: Invalid attribute for local variable {0}
+abort.missingCode = Missing code implementation in the compiler
+abort.againstSourceModel = Cannot compile against source model {0} issued from {1}
+
+### accept
+accept.cannot = Cannot accept the compilation unit:
+
+### parser
+parser.incorrectPath = The path for the javadcl.java file is incorrect
+parser.moveFiles = MOVE FILES IN THE Runtime DIRECTORY OF Parser.class
+parser.syntaxRecovery = SYNTAX RECOVERY
+parser.regularParse = REGULAR PARSE
+parser.missingFile = missing file {0}
+parser.corruptedFile = corrupted file {0}
+
+### binding
+binding.subclass = anonymous subclass of {0}
+binding.implementation = anonymous implementation of {0}
+
+### ast
+ast.missingStatement = Missing statement code generation implementation
+ast.variableShouldProvide = Assignment variable should provide an implementation for flow analysis
+ast.compoundPreShouldProvide = Compound pre assignments should provide an implementation for code generation
+ast.compoundVariableShouldProvide = Compound assignment variable should provide an implementation for code generation
+ast.postIncrShouldProvide = Post increment variable should provide an implementation for code generation
+ast.missingCode = Missing code gen implementation
+
+### constant
+constant.cannotCastedInto = {0} constant cannot be casted into {1}
+constant.cannotConvertedTo = {0} constant cannot be converted to {1}
+
+### miscellaneous
+error.undefinedBaseType = Undefined base type: {0}
+
+### test
+test = output.isFile = The outDir is a file
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
index 7a9857e8b3..00f8dd7cea 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
@@ -26,7 +26,7 @@ public CodeSnippetCompiler(
int codeSnippetEnd) {
super(environment, policy, settings, requestor, problemFactory);
this.parser =
- new CodeSnippetParser(problemReporter, evaluationContext, this.options.parseLiteralExpressionsAsConstants, this.options.getAssertMode(), codeSnippetStart, codeSnippetEnd);
+ new CodeSnippetParser(problemReporter, evaluationContext, this.options.parseLiteralExpressionsAsConstants, codeSnippetStart, codeSnippetEnd);
this.parseThreshold = 1; // fully parse only the code snippet compilation unit
}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
index 8052270be8..0d3d9232e8 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
@@ -15,82 +15,82 @@ import org.eclipse.jdt.internal.compiler.util.*;
public class CodeSnippetConstantPool extends ConstantPool implements TypeConstants {
// predefined type constant names
- final static char[][] JAVA_LANG_REFLECT_FIELD = new char[][] {JAVA, LANG, REFLECT, "Field".toCharArray()}; //$NON-NLS-1$
- final static char[][] JAVA_LANG_REFLECT_ACCESSIBLEOBJECT = new char[][] {JAVA, LANG, REFLECT, "AccessibleObject".toCharArray()}; //$NON-NLS-1$
- final static char[][] JAVA_LANG_REFLECT_METHOD = new char[][] {JAVA, LANG, REFLECT, "Method".toCharArray()}; //$NON-NLS-1$
- final static char[][] JAVA_LANG_REFLECT_ARRAY = new char[][] {JAVA, LANG, REFLECT, "Array".toCharArray()}; //$NON-NLS-1$
+ final static char[][] JAVA_LANG_REFLECT_FIELD = new char[][] {JAVA, LANG, REFLECT, "Field"/*nonNLS*/.toCharArray()};
+ final static char[][] JAVA_LANG_REFLECT_ACCESSIBLEOBJECT = new char[][] {JAVA, LANG, REFLECT, "AccessibleObject"/*nonNLS*/.toCharArray()};
+ final static char[][] JAVA_LANG_REFLECT_METHOD = new char[][] {JAVA, LANG, REFLECT, "Method"/*nonNLS*/.toCharArray()};
+ final static char[][] JAVA_LANG_REFLECT_ARRAY = new char[][] {JAVA, LANG, REFLECT, "Array"/*nonNLS*/.toCharArray()};
// predefined methods constant names
- final static char[] GETDECLAREDFIELD_NAME = "getDeclaredField".toCharArray(); //$NON-NLS-1$
- final static char[] GETDECLAREDFIELD_SIGNATURE = "(Ljava/lang/String;)Ljava/lang/reflect/Field;".toCharArray(); //$NON-NLS-1$
- final static char[] SETACCESSIBLE_NAME = "setAccessible".toCharArray(); //$NON-NLS-1$
- final static char[] SETACCESSIBLE_SIGNATURE = "(Z)V".toCharArray(); //$NON-NLS-1$
- final static char[] JAVALANGREFLECTFIELD_CONSTANTPOOLNAME = "java/lang/reflect/Field".toCharArray(); //$NON-NLS-1$
- final static char[] JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME = "java/lang/reflect/AccessibleObject".toCharArray(); //$NON-NLS-1$
- final static char[] JAVALANGREFLECTARRAY_CONSTANTPOOLNAME = "java/lang/reflect/Array".toCharArray(); //$NON-NLS-1$
- final static char[] JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME = "java/lang/reflect/Method".toCharArray(); //$NON-NLS-1$
- final static char[] GET_INT_METHOD_NAME = "getInt".toCharArray(); //$NON-NLS-1$
- final static char[] GET_LONG_METHOD_NAME = "getLong".toCharArray(); //$NON-NLS-1$
- final static char[] GET_DOUBLE_METHOD_NAME = "getDouble".toCharArray(); //$NON-NLS-1$
- final static char[] GET_FLOAT_METHOD_NAME = "getFloat".toCharArray(); //$NON-NLS-1$
- final static char[] GET_BYTE_METHOD_NAME = "getByte".toCharArray(); //$NON-NLS-1$
- final static char[] GET_CHAR_METHOD_NAME = "getChar".toCharArray(); //$NON-NLS-1$
- final static char[] GET_BOOLEAN_METHOD_NAME = "getBoolean".toCharArray(); //$NON-NLS-1$
- final static char[] GET_OBJECT_METHOD_NAME = "get".toCharArray(); //$NON-NLS-1$
- final static char[] GET_SHORT_METHOD_NAME = "getShort".toCharArray(); //$NON-NLS-1$
- final static char[] ARRAY_NEWINSTANCE_NAME = "newInstance".toCharArray(); //$NON-NLS-1$
- final static char[] GET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;)I".toCharArray(); //$NON-NLS-1$
- final static char[] GET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;)J".toCharArray(); //$NON-NLS-1$
- final static char[] GET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;)D".toCharArray(); //$NON-NLS-1$
- final static char[] GET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;)F".toCharArray(); //$NON-NLS-1$
- final static char[] GET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;)B".toCharArray(); //$NON-NLS-1$
- final static char[] GET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;)C".toCharArray(); //$NON-NLS-1$
- final static char[] GET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;)Z".toCharArray(); //$NON-NLS-1$
- final static char[] GET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
- final static char[] GET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;)S".toCharArray(); //$NON-NLS-1$
- final static char[] SET_INT_METHOD_NAME = "setInt".toCharArray(); //$NON-NLS-1$
- final static char[] SET_LONG_METHOD_NAME = "setLong".toCharArray(); //$NON-NLS-1$
- final static char[] SET_DOUBLE_METHOD_NAME = "setDouble".toCharArray(); //$NON-NLS-1$
- final static char[] SET_FLOAT_METHOD_NAME = "setFloat".toCharArray(); //$NON-NLS-1$
- final static char[] SET_BYTE_METHOD_NAME = "setByte".toCharArray(); //$NON-NLS-1$
- final static char[] SET_CHAR_METHOD_NAME = "setChar".toCharArray(); //$NON-NLS-1$
- final static char[] SET_BOOLEAN_METHOD_NAME = "setBoolean".toCharArray(); //$NON-NLS-1$
- final static char[] SET_OBJECT_METHOD_NAME = "set".toCharArray(); //$NON-NLS-1$
- final static char[] SET_SHORT_METHOD_NAME = "setShort".toCharArray(); //$NON-NLS-1$
- final static char[] GETCLASS_OBJECT_METHOD_NAME = "getClass".toCharArray(); //$NON-NLS-1$
- final static char[] SET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;I)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;J)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;D)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;F)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;B)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;C)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;Z)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)V".toCharArray(); //$NON-NLS-1$
- final static char[] SET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;S)V".toCharArray(); //$NON-NLS-1$
- final static char[] GETDECLAREDMETHOD_NAME = "getDeclaredMethod".toCharArray(); //$NON-NLS-1$
- final static char[] GETDECLAREDMETHOD_SIGNATURE = "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;".toCharArray(); //$NON-NLS-1$
- final static char[] ARRAY_NEWINSTANCE_SIGNATURE = "(Ljava/lang/Class;[I)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
- final static char[] GETCLASS_OBJECT_METHOD_SIGNATURE = "()Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
- final static char[] INVOKE_METHOD_METHOD_NAME = "invoke".toCharArray(); //$NON-NLS-1$
- final static char[] INVOKE_METHOD_METHOD_SIGNATURE = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
- final static char[] BYTEVALUE_BYTE_METHOD_NAME = "byteValue".toCharArray(); //$NON-NLS-1$
- final static char[] BYTEVALUE_BYTE_METHOD_SIGNATURE = "()B".toCharArray(); //$NON-NLS-1$
- final static char[] SHORTVALUE_SHORT_METHOD_NAME = "shortValue".toCharArray(); //$NON-NLS-1$
- final static char[] DOUBLEVALUE_DOUBLE_METHOD_NAME = "doubleValue".toCharArray(); //$NON-NLS-1$
- final static char[] FLOATVALUE_FLOAT_METHOD_NAME = "floatValue".toCharArray(); //$NON-NLS-1$
- final static char[] INTVALUE_INTEGER_METHOD_NAME = "intValue".toCharArray(); //$NON-NLS-1$
- final static char[] CHARVALUE_CHARACTER_METHOD_NAME = "charValue".toCharArray(); //$NON-NLS-1$
- final static char[] BOOLEANVALUE_BOOLEAN_METHOD_NAME = "booleanValue".toCharArray(); //$NON-NLS-1$
- final static char[] LONGVALUE_LONG_METHOD_NAME = "longValue".toCharArray(); //$NON-NLS-1$
- final static char[] SHORTVALUE_SHORT_METHOD_SIGNATURE = "()S".toCharArray(); //$NON-NLS-1$
- final static char[] DOUBLEVALUE_DOUBLE_METHOD_SIGNATURE = "()D".toCharArray(); //$NON-NLS-1$
- final static char[] FLOATVALUE_FLOAT_METHOD_SIGNATURE = "()F".toCharArray(); //$NON-NLS-1$
- final static char[] INTVALUE_INTEGER_METHOD_SIGNATURE = "()I".toCharArray(); //$NON-NLS-1$
- final static char[] CHARVALUE_CHARACTER_METHOD_SIGNATURE = "()C".toCharArray(); //$NON-NLS-1$
- final static char[] BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE = "()Z".toCharArray(); //$NON-NLS-1$
- final static char[] LONGVALUE_LONG_METHOD_SIGNATURE = "()J".toCharArray(); //$NON-NLS-1$
- final static char[] GETDECLAREDCONSTRUCTOR_NAME = "getDeclaredConstructor".toCharArray(); //$NON-NLS-1$
- final static char[] GETDECLAREDCONSTRUCTOR_SIGNATURE = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;".toCharArray(); //$NON-NLS-1$
+ final static char[] GETDECLAREDFIELD_NAME = "getDeclaredField"/*nonNLS*/.toCharArray();
+ final static char[] GETDECLAREDFIELD_SIGNATURE = "(Ljava/lang/String;)Ljava/lang/reflect/Field;"/*nonNLS*/.toCharArray();
+ final static char[] SETACCESSIBLE_NAME = "setAccessible"/*nonNLS*/.toCharArray();
+ final static char[] SETACCESSIBLE_SIGNATURE = "(Z)V"/*nonNLS*/.toCharArray();
+ final static char[] JAVALANGREFLECTFIELD_CONSTANTPOOLNAME = "java/lang/reflect/Field"/*nonNLS*/.toCharArray();
+ final static char[] JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME = "java/lang/reflect/AccessibleObject"/*nonNLS*/.toCharArray();
+ final static char[] JAVALANGREFLECTARRAY_CONSTANTPOOLNAME = "java/lang/reflect/Array"/*nonNLS*/.toCharArray();
+ final static char[] JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME = "java/lang/reflect/Method"/*nonNLS*/.toCharArray();
+ final static char[] GET_INT_METHOD_NAME = "getInt"/*nonNLS*/.toCharArray();
+ final static char[] GET_LONG_METHOD_NAME = "getLong"/*nonNLS*/.toCharArray();
+ final static char[] GET_DOUBLE_METHOD_NAME = "getDouble"/*nonNLS*/.toCharArray();
+ final static char[] GET_FLOAT_METHOD_NAME = "getFloat"/*nonNLS*/.toCharArray();
+ final static char[] GET_BYTE_METHOD_NAME = "getByte"/*nonNLS*/.toCharArray();
+ final static char[] GET_CHAR_METHOD_NAME = "getChar"/*nonNLS*/.toCharArray();
+ final static char[] GET_BOOLEAN_METHOD_NAME = "getBoolean"/*nonNLS*/.toCharArray();
+ final static char[] GET_OBJECT_METHOD_NAME = "get"/*nonNLS*/.toCharArray();
+ final static char[] GET_SHORT_METHOD_NAME = "getShort"/*nonNLS*/.toCharArray();
+ final static char[] ARRAY_NEWINSTANCE_NAME = "newInstance"/*nonNLS*/.toCharArray();
+ final static char[] GET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;)I"/*nonNLS*/.toCharArray();
+ final static char[] GET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;)J"/*nonNLS*/.toCharArray();
+ final static char[] GET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;)D"/*nonNLS*/.toCharArray();
+ final static char[] GET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;)F"/*nonNLS*/.toCharArray();
+ final static char[] GET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;)B"/*nonNLS*/.toCharArray();
+ final static char[] GET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;)C"/*nonNLS*/.toCharArray();
+ final static char[] GET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;)Z"/*nonNLS*/.toCharArray();
+ final static char[] GET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;)Ljava/lang/Object;"/*nonNLS*/.toCharArray();
+ final static char[] GET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;)S"/*nonNLS*/.toCharArray();
+ final static char[] SET_INT_METHOD_NAME = "setInt"/*nonNLS*/.toCharArray();
+ final static char[] SET_LONG_METHOD_NAME = "setLong"/*nonNLS*/.toCharArray();
+ final static char[] SET_DOUBLE_METHOD_NAME = "setDouble"/*nonNLS*/.toCharArray();
+ final static char[] SET_FLOAT_METHOD_NAME = "setFloat"/*nonNLS*/.toCharArray();
+ final static char[] SET_BYTE_METHOD_NAME = "setByte"/*nonNLS*/.toCharArray();
+ final static char[] SET_CHAR_METHOD_NAME = "setChar"/*nonNLS*/.toCharArray();
+ final static char[] SET_BOOLEAN_METHOD_NAME = "setBoolean"/*nonNLS*/.toCharArray();
+ final static char[] SET_OBJECT_METHOD_NAME = "set"/*nonNLS*/.toCharArray();
+ final static char[] SET_SHORT_METHOD_NAME = "setShort"/*nonNLS*/.toCharArray();
+ final static char[] GETCLASS_OBJECT_METHOD_NAME = "getClass"/*nonNLS*/.toCharArray();
+ final static char[] SET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;I)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;J)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;D)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;F)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;B)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;C)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;Z)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)V"/*nonNLS*/.toCharArray();
+ final static char[] SET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;S)V"/*nonNLS*/.toCharArray();
+ final static char[] GETDECLAREDMETHOD_NAME = "getDeclaredMethod"/*nonNLS*/.toCharArray();
+ final static char[] GETDECLAREDMETHOD_SIGNATURE = "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"/*nonNLS*/.toCharArray();
+ final static char[] ARRAY_NEWINSTANCE_SIGNATURE = "(Ljava/lang/Class;[I)Ljava/lang/Object;"/*nonNLS*/.toCharArray();
+ final static char[] GETCLASS_OBJECT_METHOD_SIGNATURE = "()Ljava/lang/Class;"/*nonNLS*/.toCharArray();
+ final static char[] INVOKE_METHOD_METHOD_NAME = "invoke"/*nonNLS*/.toCharArray();
+ final static char[] INVOKE_METHOD_METHOD_SIGNATURE = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"/*nonNLS*/.toCharArray();
+ final static char[] BYTEVALUE_BYTE_METHOD_NAME = "byteValue"/*nonNLS*/.toCharArray();
+ final static char[] BYTEVALUE_BYTE_METHOD_SIGNATURE = "()B"/*nonNLS*/.toCharArray();
+ final static char[] SHORTVALUE_SHORT_METHOD_NAME = "shortValue"/*nonNLS*/.toCharArray();
+ final static char[] DOUBLEVALUE_DOUBLE_METHOD_NAME = "doubleValue"/*nonNLS*/.toCharArray();
+ final static char[] FLOATVALUE_FLOAT_METHOD_NAME = "floatValue"/*nonNLS*/.toCharArray();
+ final static char[] INTVALUE_INTEGER_METHOD_NAME = "intValue"/*nonNLS*/.toCharArray();
+ final static char[] CHARVALUE_CHARACTER_METHOD_NAME = "charValue"/*nonNLS*/.toCharArray();
+ final static char[] BOOLEANVALUE_BOOLEAN_METHOD_NAME = "booleanValue"/*nonNLS*/.toCharArray();
+ final static char[] LONGVALUE_LONG_METHOD_NAME = "longValue"/*nonNLS*/.toCharArray();
+ final static char[] SHORTVALUE_SHORT_METHOD_SIGNATURE = "()S"/*nonNLS*/.toCharArray();
+ final static char[] DOUBLEVALUE_DOUBLE_METHOD_SIGNATURE = "()D"/*nonNLS*/.toCharArray();
+ final static char[] FLOATVALUE_FLOAT_METHOD_SIGNATURE = "()F"/*nonNLS*/.toCharArray();
+ final static char[] INTVALUE_INTEGER_METHOD_SIGNATURE = "()I"/*nonNLS*/.toCharArray();
+ final static char[] CHARVALUE_CHARACTER_METHOD_SIGNATURE = "()C"/*nonNLS*/.toCharArray();
+ final static char[] BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE = "()Z"/*nonNLS*/.toCharArray();
+ final static char[] LONGVALUE_LONG_METHOD_SIGNATURE = "()J"/*nonNLS*/.toCharArray();
+ final static char[] GETDECLAREDCONSTRUCTOR_NAME = "getDeclaredConstructor"/*nonNLS*/.toCharArray();
+ final static char[] GETDECLAREDCONSTRUCTOR_SIGNATURE = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;"/*nonNLS*/.toCharArray();
// predefined constant index for well known types
final static int JAVA_LANG_REFLECT_FIELD_TYPE = 0;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
index de0584ab42..4d43bb9eb7 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
@@ -23,8 +23,8 @@ public class CodeSnippetParser extends Parser implements EvaluationConstants {
/**
* Creates a new code snippet parser.
*/
-public CodeSnippetParser(ProblemReporter problemReporter, EvaluationContext evaluationContext, boolean optimizeStringLiterals, boolean assertMode, int codeSnippetStart, int codeSnippetEnd) {
- super(problemReporter, optimizeStringLiterals, assertMode);
+public CodeSnippetParser(ProblemReporter problemReporter, EvaluationContext evaluationContext, boolean optimizeStringLiterals, int codeSnippetStart, int codeSnippetEnd) {
+ super(problemReporter, optimizeStringLiterals);
this.codeSnippetStart = codeSnippetStart;
this.codeSnippetEnd = codeSnippetEnd;
this.evaluationContext = evaluationContext;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
index f9f24ffac3..3f9fe378e4 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
@@ -501,24 +501,17 @@ public TypeBinding reportError(BlockScope scope) {
return super.reportError(scope);
}
- if ((binding instanceof ProblemFieldBinding && ((ProblemFieldBinding) binding).problemId() == NotFound)
- || (binding instanceof ProblemBinding && ((ProblemBinding) binding).problemId() == NotFound)){
+ if (binding instanceof ProblemFieldBinding && ((ProblemFieldBinding) binding).problemId() == NotFound){
+ // will not support innerclass emulation inside delegate
+ binding = scope.getField(delegateThis.type, this.tokens[0], this);
+ if (!binding.isValidBinding()) return super.reportError(scope);
+ return checkFieldAccess(scope);
+ }
+
+ if (binding instanceof ProblemBinding && ((ProblemBinding) binding).problemId() == NotFound){
// will not support innerclass emulation inside delegate
FieldBinding fieldBinding = scope.getField(delegateThis.type, this.tokens[0], this);
- if (!fieldBinding.isValidBinding()) {
- if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) {
- // manage the access to a private field of the enclosing type
- CodeSnippetScope localScope = new CodeSnippetScope(scope);
- binding = localScope.getFieldForCodeSnippet(delegateThis.type, this.tokens[0], this);
- if (binding.isValidBinding()) {
- return checkFieldAccess(scope);
- } else {
- return super.reportError(scope);
- }
- } else {
- return super.reportError(scope);
- }
- }
+ if (!fieldBinding.isValidBinding()) return super.reportError(scope);
binding = fieldBinding;
return checkFieldAccess(scope);
}
@@ -536,6 +529,7 @@ public TypeBinding reportError(BlockScope scope) {
return super.reportError(scope);
}
+
public TypeBinding resolveTypeVisibility(BlockScope scope) {
// field and/or local are done before type lookups
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
index c4ebc48dc0..11c3f6725d 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
@@ -21,15 +21,6 @@ public class CodeSnippetReturnStatement extends ReturnStatement implements Invoc
public CodeSnippetReturnStatement(Expression expr, int s, int e, EvaluationContext evaluationContext) {
super(expr, s, e);
}
-
-public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
- FlowInfo info = super.analyseCode(currentScope, flowContext, flowInfo);
- // we need to remove this optimization in order to prevent the inlining of the return bytecode
- // 1GH0AU7: ITPJCORE:ALL - Eval - VerifyError in scrapbook page
- this.expression.bits &= ~ValueForReturnMASK;
- return info;
-}
-
/**
* Dump the suitable return bytecode for a return statement
*
@@ -91,12 +82,12 @@ public void resolve(BlockScope scope) {
if ((this.expressionType = this.expression.resolveType(scope)) != null) {
TypeBinding javaLangClass = scope.getJavaLangClass();
if (!javaLangClass.isValidBinding()) {
- scope.problemReporter().codeSnippetMissingClass("java.lang.Class", this.sourceStart, this.sourceEnd); //$NON-NLS-1$
+ scope.problemReporter().codeSnippetMissingClass("java.lang.Class"/*nonNLS*/, this.sourceStart, this.sourceEnd);
return;
}
TypeBinding javaLangObject = scope.getJavaLangObject();
if (!javaLangObject.isValidBinding()) {
- scope.problemReporter().codeSnippetMissingClass("java.lang.Object", this.sourceStart, this.sourceEnd); //$NON-NLS-1$
+ scope.problemReporter().codeSnippetMissingClass("java.lang.Object"/*nonNLS*/, this.sourceStart, this.sourceEnd);
return;
}
TypeBinding[] argumentTypes = new TypeBinding[] {javaLangObject, javaLangClass};
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
index 2c64fb0c9d..c06b48ed8f 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
@@ -17,20 +17,20 @@ import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CodeSnippetSkeleton implements IBinaryType, EvaluationConstants {
IBinaryMethod[] methods = new IBinaryMethod[] {
new BinaryMethodSkeleton(
- "<init>".toCharArray(), //$NON-NLS-1$
- "()V".toCharArray(), //$NON-NLS-1$
+ "<init>"/*nonNLS*/.toCharArray(),
+ "()V"/*nonNLS*/.toCharArray(),
new char[][] {},
true
),
new BinaryMethodSkeleton(
- "run".toCharArray(), //$NON-NLS-1$
- "()V".toCharArray(), //$NON-NLS-1$
- new char[][] {"java/lang/Throwable".toCharArray()}, //$NON-NLS-1$
+ "run"/*nonNLS*/.toCharArray(),
+ "()V"/*nonNLS*/.toCharArray(),
+ new char[][] {"java/lang/Throwable"/*nonNLS*/.toCharArray()},
false
),
new BinaryMethodSkeleton(
- "setResult".toCharArray(), //$NON-NLS-1$
- "(Ljava/lang/Object;Ljava/lang/Class;)V".toCharArray(), //$NON-NLS-1$
+ "setResult"/*nonNLS*/.toCharArray(),
+ "(Ljava/lang/Object;Ljava/lang/Class;)V"/*nonNLS*/.toCharArray(),
new char[][] {},
false
)
@@ -87,7 +87,7 @@ public IBinaryField[] getFields() {
return null;
}
public char[] getFileName() {
- return CharOperation.concat(CODE_SNIPPET_NAME, ".java".toCharArray()); //$NON-NLS-1$
+ return CharOperation.concat(CODE_SNIPPET_NAME, ".java"/*nonNLS*/.toCharArray());
}
public char[][] getInterfaceNames() {
return null;
@@ -116,8 +116,4 @@ public boolean isClass() {
public boolean isInterface() {
return false;
}
-
-public char[] sourceFileName() {
- return null;
-}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
index ad99110317..47fe02330d 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
@@ -75,6 +75,6 @@ public void setFieldIndex(int index){
}
public String toStringExpression(){
char[] declaringType = this.evaluationContext.declaringTypeName;
- return "(" + (declaringType == null ? "<NO DECLARING TYPE>" : new String(declaringType)) + ")this"; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ return "("/*nonNLS*/ + (declaringType == null ? "<NO DECLARING TYPE>"/*nonNLS*/ : new String(declaringType)) + ")this"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
index dc64f694ad..fd96616f4e 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
@@ -66,42 +66,42 @@ private void buildCUSource() {
// package declaration
if (this.packageName != null && this.packageName.length != 0) {
- buffer.append("package "); //$NON-NLS-1$
+ buffer.append("package "/*nonNLS*/);
buffer.append(this.packageName);
- buffer.append(";").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append(";"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
this.lineNumberOffset++;
}
// import declarations
char[][] imports = this.imports;
for (int i = 0; i < imports.length; i++) {
- buffer.append("import "); //$NON-NLS-1$
+ buffer.append("import "/*nonNLS*/);
buffer.append(imports[i]);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
this.lineNumberOffset++;
}
// class declaration
- buffer.append("public class "); //$NON-NLS-1$
+ buffer.append("public class "/*nonNLS*/);
buffer.append(this.className);
// super class is either a global variable class or the CodeSnippet class
if (this.varClassName != null) {
- buffer.append(" extends "); //$NON-NLS-1$
+ buffer.append(" extends "/*nonNLS*/);
buffer.append(this.varClassName);
} else {
- buffer.append(" extends "); //$NON-NLS-1$
+ buffer.append(" extends "/*nonNLS*/);
buffer.append(PACKAGE_NAME);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
buffer.append(ROOT_CLASS_NAME);
}
- buffer.append(" {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append(" {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
this.lineNumberOffset++;
if (this.declaringTypeName != null){
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(this.declaringTypeName);
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(DELEGATE_THIS); // val$this
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
this.lineNumberOffset++;
@@ -109,9 +109,9 @@ private void buildCUSource() {
// add some storage location for local variable persisted state
if (localVarNames != null) {
for (int i = 0, max = localVarNames.length; i < max; i++) {
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(localVarTypeNames[i]);
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(LOCAL_VAR_PREFIX); // val$...
buffer.append(localVarNames[i]);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
@@ -119,7 +119,7 @@ private void buildCUSource() {
}
}
// run() method declaration
- buffer.append("public void run() throws Throwable {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("public void run() throws Throwable {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
this.lineNumberOffset++;
startPosOffset = buffer.length();
buffer.append(codeSnippet);
@@ -173,7 +173,7 @@ public ICompletionRequestor getCompletionRequestor(final ICompletionRequestor or
// Remove completion on generated method
if (CharOperation.equals(declaringTypePackageName, CodeSnippetToCuMapper.this.packageName)
&& CharOperation.equals(declaringTypeName, CodeSnippetToCuMapper.this.className)
- && CharOperation.equals(selector, "run".toCharArray())) return; //$NON-NLS-1$
+ && CharOperation.equals(selector, "run"/*nonNLS*/.toCharArray())) return;
originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, selector, parameterPackageNames, parameterTypeNames, returnTypePackageName, returnTypeName, completionName, modifiers, completionStart - startPosOffset, completionEnd - startPosOffset);
}
public void acceptModifier(char[] modifierName, int completionStart, int completionEnd) {
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
index dd900b78cc..51004455e6 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
@@ -7,19 +7,19 @@ package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.util.CharOperation;
public interface EvaluationConstants {
- public static final char[] CODE_SNIPPET_CLASS_NAME_PREFIX = "CodeSnippet_".toCharArray(); //$NON-NLS-1$
- public static final char[] GLOBAL_VARS_CLASS_NAME_PREFIX = "GlobalVariables_".toCharArray(); //$NON-NLS-1$
- public static final char[] PACKAGE_NAME = "org.eclipse.jdt.internal.eval.target".toCharArray(); //$NON-NLS-1$
- public static final char[] CODE_SNIPPET_NAME = "org/eclipse/jdt/internal/eval/target/CodeSnippet".toCharArray(); //$NON-NLS-1$
- public static final char[] ROOT_CLASS_NAME = "CodeSnippet".toCharArray(); //$NON-NLS-1$
- public static final String ROOT_FULL_CLASS_NAME = new String(PACKAGE_NAME) + "." + new String(ROOT_CLASS_NAME); //$NON-NLS-1$
- public static final char[] SETRESULT_SELECTOR = "setResult".toCharArray(); //$NON-NLS-1$
- public static final char[] SETRESULT_ARGUMENTS = "Ljava.lang.Object;Ljava.lang.Class;".toCharArray(); //$NON-NLS-1$
+ public static final char[] CODE_SNIPPET_CLASS_NAME_PREFIX = "CodeSnippet_"/*nonNLS*/.toCharArray();
+ public static final char[] GLOBAL_VARS_CLASS_NAME_PREFIX = "GlobalVariables_"/*nonNLS*/.toCharArray();
+ public static final char[] PACKAGE_NAME = "org.eclipse.jdt.internal.eval.target"/*nonNLS*/.toCharArray();
+ public static final char[] CODE_SNIPPET_NAME = "org/eclipse/jdt/internal/eval/target/CodeSnippet"/*nonNLS*/.toCharArray();
+ public static final char[] ROOT_CLASS_NAME = "CodeSnippet"/*nonNLS*/.toCharArray();
+ public static final String ROOT_FULL_CLASS_NAME = new String(PACKAGE_NAME) + "."/*nonNLS*/ + new String(ROOT_CLASS_NAME);
+ public static final char[] SETRESULT_SELECTOR = "setResult"/*nonNLS*/.toCharArray();
+ public static final char[] SETRESULT_ARGUMENTS = "Ljava.lang.Object;Ljava.lang.Class;"/*nonNLS*/.toCharArray();
public static final char[][] ROOT_COMPOUND_NAME = CharOperation.arrayConcat(CharOperation.splitOn('.', PACKAGE_NAME), ROOT_CLASS_NAME);
- public static final String RUN_METHOD = "run"; //$NON-NLS-1$
- public static final String RESULT_VALUE_FIELD = "resultValue"; //$NON-NLS-1$
- public static final String RESULT_TYPE_FIELD = "resultType"; //$NON-NLS-1$
- public final static char[] LOCAL_VAR_PREFIX = "val$".toCharArray(); //$NON-NLS-1$
- public final static char[] DELEGATE_THIS = "val$this".toCharArray(); //$NON-NLS-1$
+ public static final String RUN_METHOD = "run"/*nonNLS*/;
+ public static final String RESULT_VALUE_FIELD = "resultValue"/*nonNLS*/;
+ public static final String RESULT_TYPE_FIELD = "resultType"/*nonNLS*/;
+ public final static char[] LOCAL_VAR_PREFIX = "val$"/*nonNLS*/.toCharArray();
+ public final static char[] DELEGATE_THIS = "val$this"/*nonNLS*/.toCharArray();
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
index 15bb206ecd..bf2c011886 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
@@ -77,7 +77,7 @@ public GlobalVariable[] allVariables() {
* set of options used to configure the code assist engine.
*/
public void complete(char[] codeSnippet, int completionPosition, ISearchableNameEnvironment environment, ICompletionRequestor requestor, ConfigurableOption[] options) {
- final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$
+ final char[] className = "CodeSnippetCompletion"/*nonNLS*/.toCharArray();
final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper(
codeSnippet,
this.packageName,
@@ -91,7 +91,7 @@ public void complete(char[] codeSnippet, int completionPosition, ISearchableName
);
ICompilationUnit sourceUnit = new ICompilationUnit() {
public char[] getFileName() {
- return CharOperation.concat(className, "java".toCharArray(), '.'); //$NON-NLS-1$
+ return CharOperation.concat(className, "java"/*nonNLS*/.toCharArray(), '.');
}
public char[] getContents() {
return mapper.getCUSource();
@@ -204,7 +204,7 @@ public void evaluate(
if (TIMING) {
long start = System.currentTimeMillis();
classes = evaluator.getClasses();
- System.out.println("Time to compile [" + new String(codeSnippet) + "] was " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ System.out.println("Time to compile ["/*nonNLS*/ + new String(codeSnippet) + "] was "/*nonNLS*/ + (System.currentTimeMillis() - start) + "ms"/*nonNLS*/);
} else {
classes = evaluator.getClasses();
}
@@ -362,50 +362,50 @@ private byte[] getCodeSnippetBytes() {
*/
public static String getCodeSnippetSource() {
return
- "package org.eclipse.jdt.internal.eval.target;\n" + //$NON-NLS-1$
- "\n" + //$NON-NLS-1$
- "/*\n" + //$NON-NLS-1$
- " * (c) Copyright IBM Corp. 2000, 2001.\n" + //$NON-NLS-1$
- " * All Rights Reserved.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * The root of all code snippet classes. Code snippet classes\n" + //$NON-NLS-1$
- " * are supposed to overide the run() method.\n" + //$NON-NLS-1$
- " * <p>\n" + //$NON-NLS-1$
- " * IMPORTANT NOTE:\n" + //$NON-NLS-1$
- " * All methods in this class must be public since this class is going to be loaded by the\n" + //$NON-NLS-1$
- " * bootstrap class loader, and the other code snippet support classes might be loaded by \n" + //$NON-NLS-1$
- " * another class loader (so their runtime packages are going to be different).\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "public class CodeSnippet {\n" + //$NON-NLS-1$
- " private Class resultType = void.class;\n" + //$NON-NLS-1$
- " private Object resultValue = null;\n" + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * Returns the result type of the code snippet evaluation.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "public Class getResultType() {\n" + //$NON-NLS-1$
- " return this.resultType;\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * Returns the result value of the code snippet evaluation.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "public Object getResultValue() {\n" + //$NON-NLS-1$
- " return this.resultValue;\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * The code snippet. Subclasses must override this method with a transformed code snippet\n" + //$NON-NLS-1$
- " * that stores the result using setResult(Class, Object).\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "public void run() {\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "/**\n" + //$NON-NLS-1$
- " * Stores the result type and value of the code snippet evaluation.\n" + //$NON-NLS-1$
- " */\n" + //$NON-NLS-1$
- "public void setResult(Object resultValue, Class resultType) {\n" + //$NON-NLS-1$
- " this.resultValue = resultValue;\n" + //$NON-NLS-1$
- " this.resultType = resultType;\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "}\n"; //$NON-NLS-1$
+ "package org.eclipse.jdt.internal.eval.target;\n"/*nonNLS*/ +
+ "\n"/*nonNLS*/ +
+ "/*\n"/*nonNLS*/ +
+ " * (c) Copyright IBM Corp. 2000, 2001.\n"/*nonNLS*/ +
+ " * All Rights Reserved.\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "/**\n"/*nonNLS*/ +
+ " * The root of all code snippet classes. Code snippet classes\n"/*nonNLS*/ +
+ " * are supposed to overide the run() method.\n"/*nonNLS*/ +
+ " * <p>\n"/*nonNLS*/ +
+ " * IMPORTANT NOTE:\n"/*nonNLS*/ +
+ " * All methods in this class must be public since this class is going to be loaded by the\n"/*nonNLS*/ +
+ " * bootstrap class loader, and the other code snippet support classes might be loaded by \n"/*nonNLS*/ +
+ " * another class loader (so their runtime packages are going to be different).\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "public class CodeSnippet {\n"/*nonNLS*/ +
+ " private Class resultType = void.class;\n"/*nonNLS*/ +
+ " private Object resultValue = null;\n"/*nonNLS*/ +
+ "/**\n"/*nonNLS*/ +
+ " * Returns the result type of the code snippet evaluation.\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "public Class getResultType() {\n"/*nonNLS*/ +
+ " return this.resultType;\n"/*nonNLS*/ +
+ "}\n"/*nonNLS*/ +
+ "/**\n"/*nonNLS*/ +
+ " * Returns the result value of the code snippet evaluation.\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "public Object getResultValue() {\n"/*nonNLS*/ +
+ " return this.resultValue;\n"/*nonNLS*/ +
+ "}\n"/*nonNLS*/ +
+ "/**\n"/*nonNLS*/ +
+ " * The code snippet. Subclasses must override this method with a transformed code snippet\n"/*nonNLS*/ +
+ " * that stores the result using setResult(Class, Object).\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "public void run() {\n"/*nonNLS*/ +
+ "}\n"/*nonNLS*/ +
+ "/**\n"/*nonNLS*/ +
+ " * Stores the result type and value of the code snippet evaluation.\n"/*nonNLS*/ +
+ " */\n"/*nonNLS*/ +
+ "public void setResult(Object resultValue, Class resultType) {\n"/*nonNLS*/ +
+ " this.resultValue = resultValue;\n"/*nonNLS*/ +
+ " this.resultType = resultType;\n"/*nonNLS*/ +
+ "}\n"/*nonNLS*/ +
+ "}\n"/*nonNLS*/;
}
/**
* Returns the imports of this evaluation context. An import is the name of a package
@@ -440,7 +440,7 @@ IBinaryType getRootCodeSnippetBinary() {
private String getSupportClassFileName(String simpleName) {
char separator = File.separatorChar;
char[][] compoundPackageName = CharOperation.splitOn('.', PACKAGE_NAME);
- return new String(CharOperation.concatWith(compoundPackageName, separator)) + separator + simpleName + ".class"; //$NON-NLS-1$
+ return new String(CharOperation.concatWith(compoundPackageName, separator)) + separator + simpleName + ".class"/*nonNLS*/;
}
/**
* Creates a new global variable with the given name, type and initializer.
@@ -487,7 +487,7 @@ public void select(
ISelectionRequestor requestor,
ConfigurableOption[] options) {
- final char[] className = "CodeSnippetSelection".toCharArray(); //$NON-NLS-1$
+ final char[] className = "CodeSnippetSelection"/*nonNLS*/.toCharArray();
final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper(
codeSnippet,
this.packageName,
@@ -501,7 +501,7 @@ public void select(
);
ICompilationUnit sourceUnit = new ICompilationUnit() {
public char[] getFileName() {
- return CharOperation.concat(className, "java".toCharArray(), '.'); //$NON-NLS-1$
+ return CharOperation.concat(className, "java"/*nonNLS*/.toCharArray(), '.');
}
public char[] getContents() {
return mapper.getCUSource();
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
index 1d0e393c57..e0f7ee3ee4 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
@@ -187,37 +187,37 @@ public String toString() {
StringBuffer buffer = new StringBuffer();
switch (this.evaluationType) {
case T_CODE_SNIPPET:
- buffer.append("Code snippet"); //$NON-NLS-1$
+ buffer.append("Code snippet"/*nonNLS*/);
break;
case T_IMPORT:
- buffer.append("Import"); //$NON-NLS-1$
+ buffer.append("Import"/*nonNLS*/);
break;
case T_INTERNAL:
- buffer.append("Internal problem"); //$NON-NLS-1$
+ buffer.append("Internal problem"/*nonNLS*/);
break;
case T_PACKAGE:
- buffer.append("Package"); //$NON-NLS-1$
+ buffer.append("Package"/*nonNLS*/);
break;
case T_VARIABLE:
- buffer.append("Global variable"); //$NON-NLS-1$
+ buffer.append("Global variable"/*nonNLS*/);
break;
}
- buffer.append(": "); //$NON-NLS-1$
+ buffer.append(": "/*nonNLS*/);
buffer.append(this.evaluationID);
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
if (hasProblems()) {
- buffer.append("Problems:\n"); //$NON-NLS-1$
+ buffer.append("Problems:\n"/*nonNLS*/);
for (int i = 0; i < this.problems.length; i++) {
buffer.append(this.problems[i].toString());
}
} else {
if (hasValue()) {
- buffer.append("("); //$NON-NLS-1$
+ buffer.append("("/*nonNLS*/);
buffer.append(this.typeName);
- buffer.append(") "); //$NON-NLS-1$
+ buffer.append(") "/*nonNLS*/);
buffer.append(this.displayString);
} else {
- buffer.append("(No explicit return value)"); //$NON-NLS-1$
+ buffer.append("(No explicit return value)"/*nonNLS*/);
}
}
return buffer.toString();
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
index fcb8e0fdef..f838a69008 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
@@ -113,7 +113,7 @@ ClassFile[] getClasses() {
compiler.compile(new ICompilationUnit[] {new ICompilationUnit() {
public char[] getFileName() {
// Name of class is name of CU
- return CharOperation.concat(Evaluator.this.getClassName(), ".java".toCharArray()); //$NON-NLS-1$
+ return CharOperation.concat(Evaluator.this.getClassName(), ".java"/*nonNLS*/.toCharArray());
}
public char[] getContents() {
return source;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
index 272dbbd714..8b994fa85d 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
@@ -52,13 +52,13 @@ public char[] getTypeName() {
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(this.typeName);
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(this.name);
if (this.initializer != null) {
- buffer.append("= "); //$NON-NLS-1$
+ buffer.append("= "/*nonNLS*/);
buffer.append(this.initializer);
}
- buffer.append(";"); //$NON-NLS-1$
+ buffer.append(";"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
index 0d3c582543..2e31731dfd 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
@@ -176,7 +176,7 @@ protected char[] getSource() {
// package declaration
char[] packageName = getPackageName();
if (packageName.length != 0) {
- buffer.append("package "); //$NON-NLS-1$
+ buffer.append("package "/*nonNLS*/);
buffer.append(packageName);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
@@ -185,20 +185,20 @@ protected char[] getSource() {
// import declarations
char[][] imports = this.context.imports;
for (int i = 0; i < imports.length; i++) {
- buffer.append("import "); //$NON-NLS-1$
+ buffer.append("import "/*nonNLS*/);
buffer.append(imports[i]);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
}
// class declaration
- buffer.append("public class "); //$NON-NLS-1$
+ buffer.append("public class "/*nonNLS*/);
buffer.append(getClassName());
- buffer.append(" extends "); //$NON-NLS-1$
+ buffer.append(" extends "/*nonNLS*/);
buffer.append(PACKAGE_NAME);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
buffer.append(ROOT_CLASS_NAME);
- buffer.append(" {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append(" {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
startPosOffset = buffer.length();
@@ -207,10 +207,10 @@ protected char[] getSource() {
VariablesInfo installedVars = this.context.installedVars;
for (int i = 0; i < this.context.variableCount; i++){
GlobalVariable var = vars[i];
- buffer.append("\tpublic static "); //$NON-NLS-1$
+ buffer.append("\tpublic static "/*nonNLS*/);
var.declarationStart = buffer.length();
buffer.append(var.typeName);
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
char[] varName = var.name;
buffer.append(varName);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
@@ -218,7 +218,7 @@ protected char[] getSource() {
}
// field initializations
- buffer.append("\tstatic {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("\tstatic {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
for (int i = 0; i < this.context.variableCount; i++){
GlobalVariable var = vars[i];
@@ -228,40 +228,40 @@ protected char[] getSource() {
// Initialize with initializer if there was no previous value
char[] initializer = var.initializer;
if (initializer != null) {
- buffer.append("\t\ttry {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("\t\ttry {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
var.initializerLineStart = lineNumberOffset;
- buffer.append("\t\t\t"); //$NON-NLS-1$
+ buffer.append("\t\t\t"/*nonNLS*/);
var.initializerStart = buffer.length();
buffer.append(varName);
- buffer.append("= "); //$NON-NLS-1$
+ buffer.append("= "/*nonNLS*/);
var.initExpressionStart = buffer.length();
buffer.append(initializer);
lineNumberOffset += numberOfCRs(initializer);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
- buffer.append("\t\t} catch (Throwable e) {").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
- buffer.append("\t\t\te.printStackTrace();").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
- buffer.append("\t\t}").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("\t\t} catch (Throwable e) {"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
+ buffer.append("\t\t\te.printStackTrace();"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
+ buffer.append("\t\t}"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset += 4; // 4 CRs
}
} else {
// Initialize with previous value if name and type are the same
- buffer.append("\t\t"); //$NON-NLS-1$
+ buffer.append("\t\t"/*nonNLS*/);
buffer.append(varName);
- buffer.append("= "); //$NON-NLS-1$
+ buffer.append("= "/*nonNLS*/);
char[] installedPackageName = installedVars.packageName;
if (installedPackageName != null && installedPackageName.length != 0) {
buffer.append(installedPackageName);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
}
buffer.append(installedVars.className);
- buffer.append("."); //$NON-NLS-1$
+ buffer.append("."/*nonNLS*/);
buffer.append(varName);
buffer.append(';').append(JavaModelManager.LINE_SEPARATOR);
lineNumberOffset++;
}
}
- buffer.append("\t}").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("\t}"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
// end of class declaration
buffer.append('}').append(JavaModelManager.LINE_SEPARATOR);
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
index 8a638a7098..8c5dac5a26 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
@@ -1,18 +1,14 @@
package org.eclipse.jdt.internal.formatter;
/*
- * Licensed Materials - Property of IBM,
- * WebSphere Studio Workbench
- * (c) Copyright IBM Corp 2000
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
*/
-import org.eclipse.jdt.internal.compiler.parser.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.eclipse.jdt.internal.compiler.parser.Scanner;
-import org.eclipse.jdt.internal.compiler.parser.TerminalSymbols;
-import org.eclipse.jdt.internal.compiler.ConfigurableOption;
-import org.eclipse.jdt.internal.formatter.impl.FormatterOptions;
-import org.eclipse.jdt.internal.formatter.impl.SplitLine;
-import java.util.Locale;
+import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.compiler.parser.*;
+import org.eclipse.jdt.internal.formatter.impl.*;
+import java.util.*;
+
/** <h2>How to format a piece of code ?</h2>
* <ul><li>Create an instance of <code>CodeFormatter</code>
* <li>Use the method <code>void format(aString)</code>
@@ -22,112 +18,112 @@ import java.util.Locale;
public class CodeFormatter implements TerminalSymbols {
- public FormatterOptions options;
-
- /**
- * Represents a block in the <code>constructions</code> stack.
- */
- public static final int BLOCK = TerminalSymbols.TokenNameLBRACE;
- /**
- * Represents a block following a control statement in the <code>constructions</code> stack.
- */
- public static final int NONINDENT_BLOCK = -100;
- /**
- * Contains the formatted output.
- */
- StringBuffer formattedSource;
- /**
- * Contains the current line.<br>
- * Will be dumped at the next "newline"
- */
- StringBuffer currentLineBuffer;
-
- /**
- * Used during the formatting to get each token.
- */
- Scanner scanner;
-
- /**
- * Contains the tokens responsible for the current indentation level
- * and the blocks not closed yet.
- */
- private int[] constructions;
- /**
- * Index in the <code>constructions</code> array.
- */
- private int constructionsCount;
- /**
- * Level of indentation of the current token (number of tab char put in front of it).
- */
- private int indentationLevel;
-
- /**
- * Regular level of indentation of all the lines
- */
- private int initialIndentationLevel;
-
- /**
- * Used to split a line.
- */
- Scanner splitScanner;
- /**
- * To remember the offset between the beginning of the line and the
- * beginning of the comment.
- */
- int currentCommentOffset;
- int currentLineIndentationLevel;
- int maxLineSize = 30;
- private boolean containsOpenCloseBraces;
- private int indentationLevelForOpenCloseBraces;
-
- /**
- * Collections of positions to map
- */
- private int[] positionsToMap;
-
- /**
- * Collections of mapped positions
- */
- private int[] mappedPositions;
-
- private int indexToMap;
-
- private int indexInMap;
-
- private int globalDelta;
-
- private int lineDelta;
-
- private int splitDelta;
-
- private int beginningOfLineIndex;
+ public FormatterOptions options;
+
+ /**
+ * Represents a block in the <code>constructions</code> stack.
+ */
+ public static final int BLOCK = TerminalSymbols.TokenNameLBRACE;
+ /**
+ * Represents a block following a control statement in the <code>constructions</code> stack.
+ */
+ public static final int NONINDENT_BLOCK = -100;
+ /**
+ * Contains the formatted output.
+ */
+ StringBuffer formattedSource;
+ /**
+ * Contains the current line.<br>
+ * Will be dumped at the next "newline"
+ */
+ StringBuffer currentLineBuffer;
+
+ /**
+ * Used during the formatting to get each token.
+ */
+ Scanner scanner;
+
+ /**
+ * Contains the tokens responsible for the current indentation level
+ * and the blocks not closed yet.
+ */
+ private int[] constructions;
+ /**
+ * Index in the <code>constructions</code> array.
+ */
+ private int constructionsCount;
+ /**
+ * Level of indentation of the current token (number of tab char put in front of it).
+ */
+ private int indentationLevel;
+
+ /**
+ * Regular level of indentation of all the lines
+ */
+ private int initialIndentationLevel;
+
+ /**
+ * Used to split a line.
+ */
+ Scanner splitScanner;
+ /**
+ * To remember the offset between the beginning of the line and the
+ * beginning of the comment.
+ */
+ int currentCommentOffset;
+ int currentLineIndentationLevel;
+ int maxLineSize = 30;
+ private boolean containsOpenCloseBraces;
+ private int indentationLevelForOpenCloseBraces;
+
+ /**
+ * Collections of positions to map
+ */
+ private int[] positionsToMap;
+
+ /**
+ * Collections of mapped positions
+ */
+ private int[] mappedPositions;
+
+ private int indexToMap;
+
+ private int indexInMap;
+
+ private int globalDelta;
+
+ private int lineDelta;
+
+ private int splitDelta;
+
+ private int beginningOfLineIndex;
/**
* Creates a new instance of Code Formatter using the FormattingOptions object
* given as argument
* @deprecated Use CodeFormatter(ConfigurableOption[]) instead
*/
public CodeFormatter() {
- this(null);
+ this(null);
}
/**
* Creates a new instance of Code Formatter using the given settings.
*/
public CodeFormatter(ConfigurableOption[] settings) {
- // initialize internal state
- constructionsCount = 0;
- constructions = new int[10];
- currentLineIndentationLevel = indentationLevel = initialIndentationLevel;
- currentCommentOffset = -1;
-
- // initialize primary and secondary scanners
- scanner = new Scanner(true,true); // regular scanner for forming lines
- scanner.recordLineSeparator = true; // to remind of the position of the beginning of the line.
- splitScanner = new Scanner(true,true); // secondary scanner to split long lines formed by primary scanning
-
- // initialize current line buffer
- currentLineBuffer = new StringBuffer();
- this.options = new FormatterOptions(settings);
+ // initialize internal state
+ constructionsCount = 0;
+ constructions = new int[10];
+ currentLineIndentationLevel = indentationLevel = initialIndentationLevel;
+ currentCommentOffset = -1;
+
+ // initialize primary and secondary scanners
+ scanner = new Scanner(true,true); // regular scanner for forming lines
+ scanner.recordLineSeparator = true; // to remind of the position of the beginning of the line.
+ splitScanner = new Scanner(true,true); // secondary scanner to split long lines formed by primary scanning
+
+ // initialize current line buffer
+ currentLineBuffer = new StringBuffer();
+ this.options = new FormatterOptions(settings);
}
/**
* Sets the behaviour of the formatter about the braces using the given flag.<br>
@@ -140,761 +136,754 @@ public CodeFormatter(ConfigurableOption[] settings) {
/** */
public void addNewLineOnOpeningBrace(boolean flag) {
- options.setNewLineBeforeOpeningBraceMode(flag);
+ options.setNewLineBeforeOpeningBraceMode(flag);
}
/**
* Returns true if a lineSeparator has to be inserted before <code>operator</code>
* false otherwise.
*/
private static boolean breakLineBeforeOperator(int operator) {
- switch (operator) {
- case TokenNameCOMMA :
- case TokenNameSEMICOLON :
- case TokenNameEQUAL :
- return false;
- default :
- return true;
- }
+ switch (operator) {
+ case TokenNameCOMMA :
+ case TokenNameSEMICOLON :
+ case TokenNameEQUAL :
+ return false;
+ default :
+ return true;
+ }
}
/**
* Returns the end of the source code.
*/
private final String copyRemainingSource() {
- char str[] = scanner.source;
- int startPosition = scanner.startPosition;
- int length = str.length - startPosition;
- StringBuffer bufr = new StringBuffer(length);
- if (startPosition < str.length) {
- bufr.append(str, startPosition, length);
- }
- return (bufr.toString());
+ char str[] = scanner.source;
+ int startPosition = scanner.startPosition;
+ int length = str.length - startPosition;
+ StringBuffer bufr = new StringBuffer(length);
+ if (startPosition < str.length) {
+ bufr.append(str, startPosition, length);
+ }
+ return (bufr.toString());
}
/**
* Inserts <code>tabCount</code> tab character or their equivalent number of spaces.
*/
private void dumpTab(int tabCount) {
- if (options.indentWithTab) {
- for (int j = 0; j < tabCount; j++) {
- formattedSource.append('\t');
- increaseSplitDelta(1);
- }
- } else {
- for (int i = 0, max = options.tabSize * tabCount; i < max; i++) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- }
+ if (options.indentWithTab) {
+ for (int j = 0; j < tabCount; j++) {
+ formattedSource.append('\t');
+ increaseSplitDelta(1);
+ }
+ } else {
+ for (int i = 0, max = options.tabSize * tabCount; i < max; i++) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ }
}
/**
* Dumps <code>currentLineBuffer</code> into the formatted string.
*/
private void flushBuffer() {
- String currentString = currentLineBuffer.toString();
- splitDelta = 0;
- beginningOfLineIndex = formattedSource.length();
- if (options.maxLineLength!=0){
- if (containsOpenCloseBraces) {
- containsOpenCloseBraces = false;
- outputLine(currentString,
- false,
- indentationLevelForOpenCloseBraces,
- 0,
- -1,
- null,
- 0);
- indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
- } else {
- outputLine(currentString,
- false,
- currentLineIndentationLevel,
- 0,
- -1,
- null,
- 0);
- }
- } else {
- formattedSource.append(currentString);
- }
+ String currentString = currentLineBuffer.toString();
+ splitDelta = 0;
+ beginningOfLineIndex = formattedSource.length();
+ if (options.maxLineLength!=0){
+ if (containsOpenCloseBraces) {
+ containsOpenCloseBraces = false;
+ outputLine(currentString,
+ false,
+ indentationLevelForOpenCloseBraces,
+ 0,
+ -1,
+ null,
+ 0);
+ indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
+ } else {
+ outputLine(currentString,
+ false,
+ currentLineIndentationLevel,
+ 0,
+ -1,
+ null,
+ 0);
+ }
+ } else {
+ formattedSource.append(currentString);
+ }
}
/**
* Formats the input string.
*/
private void format() {
- int token = 0;
- int previousToken = 0;
- int previousCompilableToken = 0;
-
- int indentationOffset = 0;
-
- int newLinesInWhitespace = 0;
- // number of new lines in the previous whitespace token
- // (used to leave blank lines before comments)
- int pendingNewLines = 0;
- boolean expectingOpenBrace = false;
- boolean clearNonBlockIndents = false;
- // true if all indentations till the 1st { (usefull after } or ;)
- boolean pendingSpace = true;
- boolean pendingNewlineAfterParen = false;
- // true when a cr is to be put after a ) (in conditional statements)
- boolean inAssignment = false;
- boolean inArrayAssignment = false;
- boolean inThrowsClause = false;
- boolean inClassOrInterfaceHeader = false;
-
- // openBracketCount is used to count the number of open brackets not closed yet.
- int openBracketCount = 0;
-
- int unarySignModifier = 0;
-
- // openParenthesis[0] is used to count the parenthesis not belonging to a condition
- // (eg foo();). parenthesis in for (...) are count elsewhere in the array.
- int openParenthesisCount = 1;
- int[] openParenthesis = new int[10];
-
- // tokenBeforeColon is used to know what token goes along with the current :
- // it can be case or ?
- int tokenBeforeColonCount = 0;
- int[] tokenBeforeColon = new int[10];
-
- constructionsCount = 0; // initializes the constructions count.
-
- // contains DO if in a DO..WHILE statement, UNITIALIZED otherwise.
- int nlicsToken = 0;
-
- // fix for 1FF17XY: LFCOM:ALL - Format problem on not matching } and else
- boolean specialElse = false;
-
- // OPTION (IndentationLevel): initial indentation level may be non-zero.
- currentLineIndentationLevel += constructionsCount;
-
-
- // An InvalidInputException exception might cause the termination of this loop.
- try {
- while (true) {
- // Get the next token. Catch invalid input and output it
- // with minimal formatting, also catch end of input and
- // exit the loop.
- try {
- token = scanner.getNextToken();
- } catch (InvalidInputException e) {
- if (!handleInvalidToken(e)) {
- throw e;
- }
- token = 0;
- }
- if (token == Scanner.TokenNameEOF)
- break;
-
- /* ## MODIFYING the indentation level before generating new lines
- and indentation in the output string
- */
-
- // Removes all the indentations made by statements not followed by a block
- // except if the current token is ELSE, CATCH or if we are in a switch/case
-
- if (clearNonBlockIndents && (token != Scanner.TokenNameWHITESPACE)) {
-
- switch (token) {
- case TokenNameelse :
- if (constructionsCount > 0 && constructions[constructionsCount-1] == TokenNameelse){
- pendingNewLines = 1;
- specialElse = true;
- }
- indentationLevel += popInclusiveUntil(TokenNameif);
- break;
- case TokenNamecatch :
- indentationLevel += popInclusiveUntil(TokenNamecatch);
- break;
- case TokenNamefinally :
- indentationLevel += popInclusiveUntil(TokenNamecatch);
- break;
- case TokenNamewhile :
- if (nlicsToken == TokenNamedo) {
- indentationLevel += pop(TokenNamedo);
- break;
- }
- default :
- indentationLevel += popExclusiveUntilBlockOrCase();
- // clear until a CASE, DEFAULT or BLOCK is encountered.
- // Thus, the indentationLevel is correctly cleared either
- // in a switch/case statement or in any other situation.
- }
- clearNonBlockIndents = false;
- }
-
- // returns to the indentation level created by the SWITCH keyword
- // if the current token is a CASE or a DEFAULT
-
- if (token == TokenNamecase || token == TokenNamedefault) {
- indentationLevel += pop(TokenNamecase);
- }
-
- if (token == Scanner.TokenNamethrows) {
- inThrowsClause = true;
- }
-
- if (token == Scanner.TokenNameclass || token == Scanner.TokenNameinterface) {
- inClassOrInterfaceHeader = true;
- }
- /* ## APPEND newlines and indentations to the output string
- */
-
- // Do not add a new line between ELSE and IF, if the option elseIfOnSameLine is true.
- // Fix for 1ETLWPZ: IVJCOM:ALL - incorrect "else if" formatting
- if (pendingNewlineAfterParen && previousCompilableToken == TokenNameelse && token == TokenNameif && options.compactElseIfMode){
- pendingNewlineAfterParen = false;
- pendingNewLines = 0;
- indentationLevel += pop(TokenNameelse);
- // because else if is now one single statement,
- // the indentation level after it is increased by one and not by 2
- // (else = 1 indent, if = 1 indent, but else if = 1 indent, not 2).
- }
-
- // Add a newline & indent to the formatted source string if
- // a for/if-else/while statement was scanned and there is no block
- // following it.
-
- pendingNewlineAfterParen = pendingNewlineAfterParen || (previousCompilableToken == TokenNameRPAREN && token == TokenNameLBRACE);
- if (pendingNewlineAfterParen && token != Scanner.TokenNameWHITESPACE) {
- pendingNewlineAfterParen = false;
-
- // Do to add a newline & indent sequence if the current token is an
- // open brace or a period or if the current token is a semi-colon and the
- // previous token is a close paren.
- // add a new line if a parenthesis belonging to a for() statement
- // has been closed and the current token is not an opening brace
-
- if (token != TokenNameLBRACE && !isComment(token)
- // to avoid adding new line between else and a comment
- && token != TokenNameDOT
- && ! (previousCompilableToken == TokenNameRPAREN
- && token == TokenNameSEMICOLON)) {
- newLine(1);
- currentLineIndentationLevel = indentationLevel;
- pendingNewLines = 0;
- pendingSpace = false;
- } else {
- if (token == TokenNameLBRACE && options.newLineBeforeOpeningBraceMode) {
- newLine(1);
- if (constructionsCount > 0
- && constructions[constructionsCount - 1] != BLOCK
- && constructions[constructionsCount - 1] != NONINDENT_BLOCK) {
- currentLineIndentationLevel = indentationLevel - 1;
- } else {
- currentLineIndentationLevel = indentationLevel;
- }
- pendingNewLines = 0;
- pendingSpace = false;
- }
- }
- }
-
- if (token == TokenNameLBRACE
- && options.newLineBeforeOpeningBraceMode
- && constructionsCount > 0
- && constructions[constructionsCount - 1] == TokenNamedo) {
- newLine(1);
- currentLineIndentationLevel = indentationLevel - 1;
- pendingNewLines = 0;
- pendingSpace = false;
- }
-
- // see PR 1G5G8EC
- if (token == TokenNameLBRACE && inThrowsClause) {
- inThrowsClause = false;
- if (options.newLineBeforeOpeningBraceMode) {
- newLine(1);
- currentLineIndentationLevel = indentationLevel;
- pendingNewLines = 0;
- pendingSpace = false;
- }
- }
-
- // see PR 1G5G82G
- if (token == TokenNameLBRACE && inClassOrInterfaceHeader) {
- inClassOrInterfaceHeader = false;
- if (options.newLineBeforeOpeningBraceMode) {
- newLine(1);
- currentLineIndentationLevel = indentationLevel;
- pendingNewLines = 0;
- pendingSpace = false;
- }
- }
- // Add pending new lines to the formatted source string.
- // Note: pending new lines are not added if the current token
- // is a single line comment or whitespace.
- // if the comment is between parenthesis, there is no blank line preservation
- // (if it's a one-line comment, a blank line is added after it).
-
- if (((pendingNewLines > 0 && (!isComment(token)))
- || (newLinesInWhitespace > 0
- && (openParenthesisCount <= 1 && isComment(token)))
- || (previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE))
- && token != Scanner.TokenNameWHITESPACE) {
-
- // Do not add newline & indent between an adjoining close brace and
- // close paren. Anonymous inner classes may use this form.
-
- boolean closeBraceAndCloseParen =
- previousToken == TokenNameRBRACE && token == TokenNameRPAREN;
-
- // OPTION (NewLineInCompoundStatement): do not add newline & indent
- // between close brace and else, (do) while, catch, and finally if
- // newlineInCompoundStatement is true.
-
-
- boolean nlicsOption =
- previousToken == TokenNameRBRACE
- && !options.newlineInControlStatementMode
- && (token == TokenNameelse
- || (token == TokenNamewhile && nlicsToken == TokenNamedo)
- || token == TokenNamecatch
- || token == TokenNamefinally);
-
- // Do not add a newline & indent between a close brace and semi-colon.
-
- boolean semiColonAndCloseBrace =
- previousToken == TokenNameRBRACE && token == TokenNameSEMICOLON;
-
- // Do not add a new line & indent between a multiline comment and a opening brace
-
- boolean commentAndOpenBrace = previousToken == Scanner.TokenNameCOMMENT_BLOCK && token == TokenNameLBRACE;
-
- // Do not add a newline & indent between a close brace and a colon (in array assignments, for example).
-
- boolean commaAndCloseBrace =
- previousToken == TokenNameRBRACE && token == TokenNameCOMMA;
-
- // Add a newline and indent, if appropriate.
-
- if (specialElse || (!commentAndOpenBrace && !closeBraceAndCloseParen && !nlicsOption && !semiColonAndCloseBrace && !commaAndCloseBrace)) {
- // if clearAllBlankLinesMode=false, leaves the blank lines
- // inserted by the user
- // if clearAllBlankLinesMode=true, removes all of then
- // and insert only blank lines required by the formatting.
- if (!options.clearAllBlankLinesMode) {
- pendingNewLines =
- (pendingNewLines < newLinesInWhitespace)
+ int token = 0;
+ int previousToken = 0;
+ int previousCompilableToken = 0;
+
+ int indentationOffset = 0;
+
+ int newLinesInWhitespace = 0;
+ // number of new lines in the previous whitespace token
+ // (used to leave blank lines before comments)
+ int pendingNewLines = 0;
+ boolean expectingOpenBrace = false;
+ boolean clearNonBlockIndents = false;
+ // true if all indentations till the 1st { (usefull after } or ;)
+ boolean pendingSpace = true;
+ boolean pendingNewlineAfterParen = false;
+ // true when a cr is to be put after a ) (in conditional statements)
+ boolean inAssignment = false;
+ boolean inArrayAssignment = false;
+ boolean inThrowsClause = false;
+ boolean inClassOrInterfaceHeader = false;
+
+ // openBracketCount is used to count the number of open brackets not closed yet.
+ int openBracketCount = 0;
+
+ int unarySignModifier = 0;
+
+ // openParenthesis[0] is used to count the parenthesis not belonging to a condition
+ // (eg foo();). parenthesis in for (...) are count elsewhere in the array.
+ int openParenthesisCount = 1;
+ int[] openParenthesis = new int[10];
+
+ // tokenBeforeColon is used to know what token goes along with the current :
+ // it can be case or ?
+ int tokenBeforeColonCount = 0;
+ int[] tokenBeforeColon = new int[10];
+
+ constructionsCount = 0; // initializes the constructions count.
+
+ // contains DO if in a DO..WHILE statement, UNITIALIZED otherwise.
+ int nlicsToken = 0;
+
+ // fix for 1FF17XY: LFCOM:ALL - Format problem on not matching } and else
+ boolean specialElse = false;
+
+ // OPTION (IndentationLevel): initial indentation level may be non-zero.
+ currentLineIndentationLevel += constructionsCount;
+
+
+ // An InvalidInputException exception might cause the termination of this loop.
+ try {
+ while (true) {
+ // Get the next token. Catch invalid input and output it
+ // with minimal formatting, also catch end of input and
+ // exit the loop.
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ if (!handleInvalidToken(e)) {
+ throw e;
+ }
+ token = 0;
+ }
+ if (token == Scanner.TokenNameEOF)
+ break;
+
+ /* ## MODIFYING the indentation level before generating new lines
+ and indentation in the output string
+ */
+
+ // Removes all the indentations made by statements not followed by a block
+ // except if the current token is ELSE, CATCH or if we are in a switch/case
+
+ if (clearNonBlockIndents && (token != Scanner.TokenNameWHITESPACE)) {
+
+ switch (token) {
+ case TokenNameelse :
+ if (constructionsCount > 0 && constructions[constructionsCount-1] == TokenNameelse){
+ pendingNewLines = 1;
+ specialElse = true;
+ }
+ indentationLevel += popInclusiveUntil(TokenNameif);
+ break;
+ case TokenNamecatch :
+ indentationLevel += popInclusiveUntil(TokenNamecatch);
+ break;
+ case TokenNamefinally :
+ indentationLevel += popInclusiveUntil(TokenNamecatch);
+ break;
+ case TokenNamewhile :
+ if (nlicsToken == TokenNamedo) {
+ indentationLevel += pop(TokenNamedo);
+ break;
+ }
+ default :
+ indentationLevel += popExclusiveUntilBlockOrCase();
+ // clear until a CASE, DEFAULT or BLOCK is encountered.
+ // Thus, the indentationLevel is correctly cleared either
+ // in a switch/case statement or in any other situation.
+ }
+ clearNonBlockIndents = false;
+ }
+
+ // returns to the indentation level created by the SWITCH keyword
+ // if the current token is a CASE or a DEFAULT
+
+ if (token == TokenNamecase || token == TokenNamedefault) {
+ indentationLevel += pop(TokenNamecase);
+ }
+
+ if (token == Scanner.TokenNamethrows) {
+ inThrowsClause = true;
+ }
+
+ if (token == Scanner.TokenNameclass || token == Scanner.TokenNameinterface) {
+ inClassOrInterfaceHeader = true;
+ }
+ /* ## APPEND newlines and indentations to the output string
+ */
+
+ // Do not add a new line between ELSE and IF, if the option elseIfOnSameLine is true.
+ // Fix for 1ETLWPZ: IVJCOM:ALL - incorrect "else if" formatting
+ if (pendingNewlineAfterParen && previousCompilableToken == TokenNameelse && token == TokenNameif && options.compactElseIfMode){
+ pendingNewlineAfterParen = false;
+ pendingNewLines = 0;
+ indentationLevel += pop(TokenNameelse);
+ // because else if is now one single statement,
+ // the indentation level after it is increased by one and not by 2
+ // (else = 1 indent, if = 1 indent, but else if = 1 indent, not 2).
+ }
+
+ // Add a newline & indent to the formatted source string if
+ // a for/if-else/while statement was scanned and there is no block
+ // following it.
+
+ pendingNewlineAfterParen = pendingNewlineAfterParen || (previousCompilableToken == TokenNameRPAREN && token == TokenNameLBRACE);
+ if (pendingNewlineAfterParen && token != Scanner.TokenNameWHITESPACE) {
+ pendingNewlineAfterParen = false;
+
+ // Do to add a newline & indent sequence if the current token is an
+ // open brace or a period or if the current token is a semi-colon and the
+ // previous token is a close paren.
+ // add a new line if a parenthesis belonging to a for() statement
+ // has been closed and the current token is not an opening brace
+
+ if (token != TokenNameLBRACE && !isComment(token)
+ // to avoid adding new line between else and a comment
+ && token != TokenNameDOT
+ && ! (previousCompilableToken == TokenNameRPAREN
+ && token == TokenNameSEMICOLON)) {
+ newLine(1);
+ currentLineIndentationLevel += indentationLevel;
+ pendingNewLines = 0;
+ pendingSpace = false;
+ } else {
+ if (token == TokenNameLBRACE && options.newLineBeforeOpeningBraceMode) {
+ newLine(1);
+ currentLineIndentationLevel = indentationLevel;
+ pendingNewLines = 0;
+ pendingSpace = false;
+ }
+ }
+ }
+
+ // see PR 1G5G8EC
+ if (token == TokenNameLBRACE && inThrowsClause) {
+ inThrowsClause = false;
+ if (options.newLineBeforeOpeningBraceMode) {
+ newLine(1);
+ currentLineIndentationLevel = indentationLevel;
+ pendingNewLines = 0;
+ pendingSpace = false;
+ }
+ }
+
+ // see PR 1G5G82G
+ if (token == TokenNameLBRACE && inClassOrInterfaceHeader) {
+ inClassOrInterfaceHeader = false;
+ if (options.newLineBeforeOpeningBraceMode) {
+ newLine(1);
+ currentLineIndentationLevel = indentationLevel;
+ pendingNewLines = 0;
+ pendingSpace = false;
+ }
+ }
+ // Add pending new lines to the formatted source string.
+ // Note: pending new lines are not added if the current token
+ // is a single line comment or whitespace.
+ // if the comment is between parenthesis, there is no blank line preservation
+ // (if it's a one-line comment, a blank line is added after it).
+
+ if (((pendingNewLines > 0 && (!isComment(token)))
+ || (newLinesInWhitespace > 0
+ && (openParenthesisCount <= 1 && isComment(token)))
+ || (previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE))
+ && token != Scanner.TokenNameWHITESPACE) {
+
+ // Do not add newline & indent between an adjoining close brace and
+ // close paren. Anonymous inner classes may use this form.
+
+ boolean closeBraceAndCloseParen =
+ previousToken == TokenNameRBRACE && token == TokenNameRPAREN;
+
+ // OPTION (NewLineInCompoundStatement): do not add newline & indent
+ // between close brace and else, (do) while, catch, and finally if
+ // newlineInCompoundStatement is true.
+
+ boolean nlicsOption =
+ previousToken == TokenNameRBRACE
+ && !options.newlineInControlStatementMode
+ && (token == TokenNameelse
+ || (token == TokenNamewhile && nlicsToken == TokenNamedo)
+ || token == TokenNamecatch
+ || token == TokenNamefinally);
+
+ // Do not add a newline & indent between a close brace and semi-colon.
+
+ boolean semiColonAndCloseBrace =
+ previousToken == TokenNameRBRACE && token == TokenNameSEMICOLON;
+
+ // Do not add a new line & indent between a multiline comment and a opening brace
+
+ boolean commentAndOpenBrace = previousToken == Scanner.TokenNameCOMMENT_BLOCK && token == TokenNameLBRACE;
+
+ // Do not add a newline & indent between a close brace and a colon (in array assignments, for example).
+
+ boolean commaAndCloseBrace =
+ previousToken == TokenNameRBRACE && token == TokenNameCOMMA;
+
+ // Add a newline and indent, if appropriate.
+
+ if (specialElse || (!commentAndOpenBrace && !closeBraceAndCloseParen && !nlicsOption && !semiColonAndCloseBrace && !commaAndCloseBrace)) {
+ // if clearAllBlankLinesMode=false, leaves the blank lines
+ // inserted by the user
+ // if clearAllBlankLinesMode=true, removes all of then
+ // and insert only blank lines required by the formatting.
+ if (!options.clearAllBlankLinesMode) {
+ pendingNewLines =
+ (pendingNewLines < newLinesInWhitespace)
// (isComment(token))
- ? newLinesInWhitespace
- : pendingNewLines;
- pendingNewLines = (pendingNewLines > 2) ? 2 : pendingNewLines;
- }
-
- if (previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE) {
- containsOpenCloseBraces = true;
- indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
- if (isComment(previousToken)) {
- newLine(pendingNewLines);
- } else {
+ ? newLinesInWhitespace
+ : pendingNewLines;
+ pendingNewLines = (pendingNewLines > 2) ? 2 : pendingNewLines;
+ }
+
+ if (previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE) {
+ containsOpenCloseBraces = true;
+ indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
+ if (isComment(previousToken)) {
+ newLine(pendingNewLines);
+ } else {
/* if (!(constructionsCount > 1
- && constructions[constructionsCount-1] == NONINDENT_BLOCK
- && (constructions[constructionsCount-2] == TokenNamefor
- || constructions[constructionsCount-2] == TokenNamewhile))) {*/
- if (options.newLineInEmptyBlockMode) {
- if (inArrayAssignment) {
- newLine(1); // array assigment with an empty block
- } else {
- newLine(pendingNewLines);
- }
- }
+ && constructions[constructionsCount-1] == NONINDENT_BLOCK
+ && (constructions[constructionsCount-2] == TokenNamefor
+ || constructions[constructionsCount-2] == TokenNamewhile))) {*/
+ if (options.newLineInEmptyBlockMode) {
+ if (inArrayAssignment) {
+ newLine(1); // array assigment with an empty block
+ } else {
+ newLine(pendingNewLines);
+ }
+ }
// }
- }
- } else {
- // see PR 1FKKC3U: LFCOM:WINNT - Format problem with a comment before the ';'
- if (!((previousToken == Scanner.TokenNameCOMMENT_BLOCK || previousToken == Scanner.TokenNameCOMMENT_JAVADOC) && token == TokenNameSEMICOLON)) {
- newLine(pendingNewLines);
- }
- }
- if (((previousCompilableToken == TokenNameSEMICOLON)
- || (previousCompilableToken == TokenNameLBRACE)
- || (previousCompilableToken == TokenNameRBRACE)
- || (isComment(previousToken)))
- && (token == TokenNameRBRACE)) {
- indentationOffset = -1;
- indentationLevel += popExclusiveUntilBlock();
- }
-
- if (previousToken == Scanner.TokenNameCOMMENT_LINE && inAssignment) {
- // PR 1FI5IPO
- currentLineIndentationLevel++;
- } else {
- currentLineIndentationLevel = indentationLevel + indentationOffset;
- }
-
- pendingSpace = false;
- indentationOffset = 0;
- }
- pendingNewLines = 0;
- newLinesInWhitespace = 0;
- specialElse = false;
-
- if (nlicsToken == TokenNamedo && token == TokenNamewhile) {
- nlicsToken = 0;
- }
- }
-
- switch (token) {
- case TokenNameelse :
- case TokenNamefinally :
- expectingOpenBrace = true;
- pendingNewlineAfterParen = true;
- indentationLevel += pushControlStatement(token);
- break;
- case TokenNamecase :
- case TokenNamedefault :
- if (tokenBeforeColonCount == tokenBeforeColon.length) {
- System.arraycopy(
- tokenBeforeColon,
- 0,
- (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
- 0,
- tokenBeforeColonCount);
- }
- tokenBeforeColon[tokenBeforeColonCount++] = TokenNamecase;
- indentationLevel += pushControlStatement(TokenNamecase);
- break;
- case TokenNameQUESTION :
- if (tokenBeforeColonCount == tokenBeforeColon.length) {
- System.arraycopy(
- tokenBeforeColon,
- 0,
- (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
- 0,
- tokenBeforeColonCount);
- }
- tokenBeforeColon[tokenBeforeColonCount++] = token;
- break;
- case TokenNameswitch :
- case TokenNamefor :
- case TokenNameif :
- case TokenNamewhile :
- if (openParenthesisCount == openParenthesis.length) {
- System.arraycopy(
- openParenthesis,
- 0,
- (openParenthesis = new int[openParenthesisCount * 2]),
- 0,
- openParenthesisCount);
- }
- openParenthesis[openParenthesisCount++] = 0;
- expectingOpenBrace = true;
-
- indentationLevel += pushControlStatement(token);
- break;
- case TokenNametry :
- pendingNewlineAfterParen = true;
- case TokenNamecatch :
- // several CATCH statements can be contiguous.
- // a CATCH is encountered pop until first CATCH (if a CATCH follows a TRY it works the same way,
- // as CATCH and TRY are the same token in the stack).
- expectingOpenBrace = true;
- indentationLevel += pushControlStatement(TokenNamecatch);
- break;
-
- case TokenNamedo :
- expectingOpenBrace = true;
- indentationLevel += pushControlStatement(token);
- nlicsToken = token;
- break;
- case TokenNamenew :
- break;
- case TokenNameLPAREN :
-
- // Put a space between the previous and current token if the
- // previous token was not a keyword, open paren, logical
- // compliment (eg: !), semi-colon, open brace, close brace,
- // super, or this.
-
- if (previousCompilableToken != TokenNameLBRACKET
- && previousToken != TokenNameIdentifier
- && previousToken != 0
- && previousToken != TokenNameNOT
- && previousToken != TokenNameLPAREN
- && previousToken != TokenNameTWIDDLE
- && previousToken != TokenNameSEMICOLON
- && previousToken != TokenNameLBRACE
- && previousToken != TokenNameRBRACE
- && previousToken != TokenNamesuper
- && previousToken != TokenNamethis) {
- space();
- }
-
- // If in a for/if/while statement, increase the parenthesis count
- // for the current openParenthesisCount
- // else increase the count for stand alone parenthesis.
- if (openParenthesisCount > 0)
- openParenthesis[openParenthesisCount - 1]++;
- else
- openParenthesis[0]++;
-
- pendingSpace = false;
- break;
- case TokenNameRPAREN :
-
- // Decrease the parenthesis count
- // if there is no more unclosed parenthesis,
- // a new line and indent may be append (depending on the next token).
-
- if ((openParenthesisCount > 1)
- && (openParenthesis[openParenthesisCount - 1] > 0)) {
- openParenthesis[openParenthesisCount - 1]--;
- if (openParenthesis[openParenthesisCount - 1] <= 0) {
- pendingNewlineAfterParen = true;
- inAssignment = false;
- openParenthesisCount--;
-
- }
- } else {
- openParenthesis[0]--;
- }
-
- pendingSpace = false;
- break;
- case TokenNameLBRACE :
- if ((previousCompilableToken == TokenNameRBRACKET) || (previousCompilableToken == TokenNameEQUAL)) {
+ }
+ } else {
+ // see PR 1FKKC3U: LFCOM:WINNT - Format problem with a comment before the ';'
+ if (!((previousToken == Scanner.TokenNameCOMMENT_BLOCK || previousToken == Scanner.TokenNameCOMMENT_JAVADOC) && token == TokenNameSEMICOLON)) {
+ newLine(pendingNewLines);
+ }
+ }
+ if (((previousCompilableToken == TokenNameSEMICOLON)
+ || (previousCompilableToken == TokenNameLBRACE)
+ || (previousCompilableToken == TokenNameRBRACE)
+ || (isComment(previousToken)))
+ && (token == TokenNameRBRACE)) {
+ indentationOffset = -1;
+ indentationLevel += popExclusiveUntilBlock();
+ }
+
+ if (previousToken == Scanner.TokenNameCOMMENT_LINE && inAssignment) {
+ // PR 1FI5IPO
+ currentLineIndentationLevel++;
+ } else {
+ currentLineIndentationLevel = indentationLevel + indentationOffset;
+ }
+
+ pendingSpace = false;
+ indentationOffset = 0;
+ }
+ pendingNewLines = 0;
+ newLinesInWhitespace = 0;
+ specialElse = false;
+
+ if (nlicsToken == TokenNamedo && token == TokenNamewhile) {
+ nlicsToken = 0;
+ }
+ }
+
+ switch (token) {
+ case TokenNameelse :
+ case TokenNamefinally :
+ expectingOpenBrace = true;
+ pendingNewlineAfterParen = true;
+ indentationLevel += pushControlStatement(token);
+ break;
+ case TokenNamecase :
+ case TokenNamedefault :
+ if (tokenBeforeColonCount == tokenBeforeColon.length) {
+ System.arraycopy(
+ tokenBeforeColon,
+ 0,
+ (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
+ 0,
+ tokenBeforeColonCount);
+ }
+ tokenBeforeColon[tokenBeforeColonCount++] = TokenNamecase;
+ indentationLevel += pushControlStatement(TokenNamecase);
+ break;
+ case TokenNameQUESTION :
+ if (tokenBeforeColonCount == tokenBeforeColon.length) {
+ System.arraycopy(
+ tokenBeforeColon,
+ 0,
+ (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
+ 0,
+ tokenBeforeColonCount);
+ }
+ tokenBeforeColon[tokenBeforeColonCount++] = token;
+ break;
+ case TokenNameswitch :
+ case TokenNamefor :
+ case TokenNameif :
+ case TokenNamewhile :
+ if (openParenthesisCount == openParenthesis.length) {
+ System.arraycopy(
+ openParenthesis,
+ 0,
+ (openParenthesis = new int[openParenthesisCount * 2]),
+ 0,
+ openParenthesisCount);
+ }
+ openParenthesis[openParenthesisCount++] = 0;
+ expectingOpenBrace = true;
+
+ indentationLevel += pushControlStatement(token);
+ break;
+ case TokenNametry :
+ pendingNewlineAfterParen = true;
+ case TokenNamecatch :
+ // several CATCH statements can be contiguous.
+ // a CATCH is encountered pop until first CATCH (if a CATCH follows a TRY it works the same way,
+ // as CATCH and TRY are the same token in the stack).
+ expectingOpenBrace = true;
+ indentationLevel += pushControlStatement(TokenNamecatch);
+ break;
+
+ case TokenNamedo :
+ expectingOpenBrace = true;
+ indentationLevel += pushControlStatement(token);
+ nlicsToken = token;
+ break;
+ case TokenNamenew :
+
+ // The flag inAssigment is used to properly format
+ // array assignments, and if a non-array assignment
+ // statement is in progress, it is no longer
+ // beneficial to know this, so set the flag to false.
+
+/* if (!inArrayAssignment) {
+ inAssignment = false;
+ }*/
+ break;
+ case TokenNameLPAREN :
+
+ // Put a space between the previous and current token if the
+ // previous token was not a keyword, open paren, logical
+ // compliment (eg: !), semi-colon, open brace, close brace,
+ // super, or this.
+
+ if (previousCompilableToken != TokenNameLBRACKET
+ && previousToken != TokenNameIdentifier
+ && previousToken != 0
+ && previousToken != TokenNameNOT
+ && previousToken != TokenNameLPAREN
+ && previousToken != TokenNameTWIDDLE
+ && previousToken != TokenNameSEMICOLON
+ && previousToken != TokenNameLBRACE
+ && previousToken != TokenNameRBRACE
+ && previousToken != TokenNamesuper
+ && previousToken != TokenNamethis) {
+ space();
+ }
+
+ // If in a for/if/while statement, increase the parenthesis count
+ // for the current openParenthesisCount
+ // else increase the count for stand alone parenthesis.
+ if (openParenthesisCount > 0)
+ openParenthesis[openParenthesisCount - 1]++;
+ else
+ openParenthesis[0]++;
+
+ pendingSpace = false;
+ break;
+ case TokenNameRPAREN :
+
+ // Decrease the parenthesis count
+ // if there is no more unclosed parenthesis,
+ // a new line and indent may be append (depending on the next token).
+
+ if ((openParenthesisCount > 1)
+ && (openParenthesis[openParenthesisCount - 1] > 0)) {
+ openParenthesis[openParenthesisCount - 1]--;
+ if (openParenthesis[openParenthesisCount - 1] <= 0) {
+ pendingNewlineAfterParen = true;
+ inAssignment = false;
+ openParenthesisCount--;
+
+ }
+ } else {
+ openParenthesis[0]--;
+ }
+
+ pendingSpace = false;
+ break;
+ case TokenNameLBRACE :
+ if ((previousCompilableToken == TokenNameRBRACKET) || (previousCompilableToken == TokenNameEQUAL)) {
// if (previousCompilableToken == TokenNameRBRACKET) {
- inArrayAssignment = true;
- inAssignment = false;
- }
- if (inArrayAssignment) {
- indentationLevel += pushBlock();
- } else {
- // Add new line and increase indentation level after open brace.
- pendingNewLines = 1;
- indentationLevel += pushBlock();
- }
- break;
- case TokenNameRBRACE :
- if (previousCompilableToken == TokenNameRPAREN) {
- pendingSpace = false;
- }
- if (inArrayAssignment) {
- inArrayAssignment = false;
- pendingNewLines = 1;
- indentationLevel += popInclusiveUntilBlock();
- } else {
- pendingNewLines = 1;
- indentationLevel += popInclusiveUntilBlock();
-
- if (previousCompilableToken == TokenNameRPAREN){
- // fix for 1FGDDV6: LFCOM:WIN98 - Weird splitting on message expression
- currentLineBuffer.append(options.lineSeparatorSequence);
- increaseLineDelta(options.lineSeparatorSequence.length);
- }
-
- if (constructionsCount > 0) {
- switch (constructions[constructionsCount - 1]) {
- case TokenNamefor :
- //indentationLevel += popExclusiveUntilBlock();
- //break;
- case TokenNameswitch :
- case TokenNameif :
- case TokenNameelse :
- case TokenNametry :
- case TokenNamecatch :
- case TokenNamefinally :
- case TokenNamewhile :
- case TokenNamedo :
- clearNonBlockIndents = true;
- default :
- break;
- }
- }
-
- }
- break;
- case TokenNameLBRACKET :
- openBracketCount++;
- pendingSpace = false;
- break;
- case TokenNameRBRACKET :
- openBracketCount-=(openBracketCount>0)?1:0;
- // if there is no left bracket to close, the right bracket is ignored.
- pendingSpace = false;
- break;
- case TokenNameCOMMA :
- case TokenNameDOT :
- pendingSpace = false;
- break;
- case TokenNameSEMICOLON :
-
- // Do not generate line terminators in the definition of
- // the for statement.
- // if not in this case, jump a line and reduce indentation after the brace
- // if the block it closes belongs to a conditional statement (if, while, do...).
-
- if (openParenthesisCount <= 1) {
- pendingNewLines = 1;
- if (expectingOpenBrace) {
- clearNonBlockIndents = true;
- expectingOpenBrace = false;
- }
- }
- inAssignment = false;
- pendingSpace = false;
- break;
- case TokenNamePLUS_PLUS :
- case TokenNameMINUS_MINUS :
-
- // Do not put a space between a post-increment/decrement
- // and the identifier being modified.
-
- if (previousToken == TokenNameIdentifier
- || previousToken == TokenNameRBRACKET) {
- pendingSpace = false;
- }
- break;
- case TokenNamePLUS : // previously ADDITION
- case TokenNameMINUS :
-
- // Handle the unary operators plus and minus via a flag
-
- if (!isLiteralToken(previousToken)
- && previousToken != TokenNameIdentifier
- && previousToken != TokenNameRPAREN
- && previousToken != TokenNameRBRACKET) {
- unarySignModifier = 1;
- }
- break;
- case TokenNameCOLON :
- // In a switch/case statement, add a newline & indent
- // when a colon is encountered.
- if (tokenBeforeColonCount > 0) {
- if (tokenBeforeColon[tokenBeforeColonCount - 1] == TokenNamecase) {
- pendingNewLines = 1;
- }
- tokenBeforeColonCount--;
- }
- break;
- case TokenNameEQUAL :
- inAssignment = true;
- break;
- case Scanner.TokenNameCOMMENT_LINE :
- pendingNewLines = 1;
- if (inAssignment) {
- currentLineIndentationLevel++;
- }
- break; // a line is always inserted after a one-line comment
- case Scanner.TokenNameCOMMENT_JAVADOC :
- case Scanner.TokenNameCOMMENT_BLOCK :
- currentCommentOffset = getCurrentCommentOffset();
- if (openParenthesis[0]==0 && openBracketCount < 1){
- pendingNewLines = 1;
- // a new line is inserted only if the comment is not between parenthesis.
- }
- break;
- case Scanner.TokenNameWHITESPACE :
-
- // Count the number of line terminators in the whitespace so
- // line spacing can be preserved near comments.
-
- char[] source = scanner.source;
- newLinesInWhitespace = 0;
- for (
- int i = scanner.startPosition, max = scanner.currentPosition;
- i < max;
- i++) {
- if (source[i] == '\n') {
- newLinesInWhitespace++;
- }
- }
- increaseLineDelta(scanner.startPosition - scanner.currentPosition);
- break;
- default :
- if ((token == TokenNameIdentifier)
- || isLiteralToken(token)
- || token == TokenNamesuper
- || token == TokenNamethis) {
-
- // Do not put a space between a unary operator
- // (eg: ++, --, +, -) and the identifier being modified.
- if (previousToken == TokenNamePLUS_PLUS
- || previousToken == TokenNameMINUS_MINUS
- || (previousToken == TokenNamePLUS && unarySignModifier > 0)
- || (previousToken == TokenNameMINUS && unarySignModifier > 0)) {
- pendingSpace = false;
- }
- unarySignModifier = 0;
- }
- break;
- }
-
- // Do not output whitespace tokens.
-
- if (token != Scanner.TokenNameWHITESPACE) {
-
- /* Add pending space to the formatted source string.
- Do not output a space under the following circumstances:
- 1) this is the first pass
- 2) previous token is an open paren
- 3) previous token is a period
- 4) previous token is the logical compliment (eg: !)
- 5) previous token is the bitwise compliment (eg: ~)
- 6) previous token is the open bracket (eg: [)
- 7) in an assignment statement, if the previous token is an
- open brace or the current token is a close brace
- 8) previous token is a single line comment
- */
-
- boolean openAndCloseBrace = previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE;
-
- // to be replaced by a nicer condition.
-
- if (pendingSpace
- && insertSpaceAfter(previousToken)
- && ! (inAssignment
- && (previousToken == TokenNameLBRACE || token == TokenNameRBRACE))
- && previousToken != Scanner.TokenNameCOMMENT_LINE) {
- if ((! (options.compactAssignmentMode && token == TokenNameEQUAL)) && !openAndCloseBrace)
- space();
- }
-
- // Add the next token to the formatted source string.
-
- outputCurrentToken(token);
- if (token == Scanner.TokenNameCOMMENT_LINE && openParenthesisCount > 1){
- pendingNewLines = 0;
- currentLineBuffer.append(options.lineSeparatorSequence);
- increaseLineDelta(options.lineSeparatorSequence.length);
- }
- pendingSpace = true;
- }
-
- // Whitespace tokens do not need to be remembered.
-
- if (token != Scanner.TokenNameWHITESPACE) {
- previousToken = token;
- if (token != Scanner.TokenNameCOMMENT_BLOCK
- && token != Scanner.TokenNameCOMMENT_LINE
- && token != Scanner.TokenNameCOMMENT_JAVADOC) {
- previousCompilableToken = token;
- }
- }
-
- }
- output(copyRemainingSource());
- flushBuffer(); // dump the last token of the source in the formatted output.
- } catch (InvalidInputException e) {
- output(copyRemainingSource());
- flushBuffer(); // dump the last token of the source in the formatted output.
- }
+ inArrayAssignment = true;
+ inAssignment = false;
+ }
+ if (inArrayAssignment) {
+ indentationLevel += pushBlock();
+ } else {
+ // Add new line and increase indentation level after open brace.
+ pendingNewLines = 1;
+ indentationLevel += pushBlock();
+ }
+ break;
+ case TokenNameRBRACE :
+ if (previousCompilableToken == TokenNameRPAREN) {
+ pendingSpace = false;
+ }
+ if (inArrayAssignment) {
+ inArrayAssignment = false;
+ pendingNewLines = 1;
+ indentationLevel += popInclusiveUntilBlock();
+ } else {
+ pendingNewLines = 1;
+ indentationLevel += popInclusiveUntilBlock();
+
+ if (previousCompilableToken == TokenNameRPAREN){
+ // fix for 1FGDDV6: LFCOM:WIN98 - Weird splitting on message expression
+ currentLineBuffer.append(options.lineSeparatorSequence);
+ increaseLineDelta(options.lineSeparatorSequence.length);
+ }
+
+ if (constructionsCount > 0) {
+ switch (constructions[constructionsCount - 1]) {
+ case TokenNamefor :
+ //indentationLevel += popExclusiveUntilBlock();
+ //break;
+ case TokenNameswitch :
+ case TokenNameif :
+ case TokenNameelse :
+ case TokenNametry :
+ case TokenNamecatch :
+ case TokenNamefinally :
+ case TokenNamewhile :
+ case TokenNamedo :
+ clearNonBlockIndents = true;
+ default :
+ break;
+ }
+ }
+
+ }
+ break;
+ case TokenNameLBRACKET :
+ openBracketCount++;
+ pendingSpace = false;
+ break;
+ case TokenNameRBRACKET :
+ openBracketCount-=(openBracketCount>0)?1:0;
+ // if there is no left bracket to close, the right bracket is ignored.
+ pendingSpace = false;
+ break;
+ case TokenNameCOMMA :
+ case TokenNameDOT :
+ pendingSpace = false;
+ break;
+ case TokenNameSEMICOLON :
+
+ // Do not generate line terminators in the definition of
+ // the for statement.
+ // if not in this case, jump a line and reduce indentation after the brace
+ // if the block it closes belongs to a conditional statement (if, while, do...).
+
+ if (openParenthesisCount <= 1) {
+ pendingNewLines = 1;
+ if (expectingOpenBrace) {
+ clearNonBlockIndents = true;
+ expectingOpenBrace = false;
+ }
+ }
+ inAssignment = false;
+ pendingSpace = false;
+ break;
+ case TokenNamePLUS_PLUS :
+ case TokenNameMINUS_MINUS :
+
+ // Do not put a space between a post-increment/decrement
+ // and the identifier being modified.
+
+ if (previousToken == TokenNameIdentifier
+ || previousToken == TokenNameRBRACKET) {
+ pendingSpace = false;
+ }
+ break;
+ case TokenNamePLUS : // previously ADDITION
+ case TokenNameMINUS :
+
+ // Handle the unary operators plus and minus via a 3-state flag.
+
+ if (!isLiteralToken(previousToken)
+ && previousToken != TokenNameIdentifier
+ && previousToken != TokenNameRPAREN
+ && previousToken != TokenNameRBRACKET) {
+ unarySignModifier = 2;
+ }
+ break;
+ case TokenNameCOLON :
+
+ // In a switch/case statement, add a newline & indent
+ // when a colon is encountered.
+ if (tokenBeforeColonCount > 0) {
+ if (tokenBeforeColon[tokenBeforeColonCount - 1] == TokenNamecase) {
+ pendingNewLines = 1;
+ }
+ tokenBeforeColonCount--;
+ }
+ break;
+ case TokenNameEQUAL :
+ inAssignment = true;
+ break;
+ case Scanner.TokenNameCOMMENT_LINE :
+ pendingNewLines = 1;
+ if (inAssignment) {
+ currentLineIndentationLevel++;
+ }
+ break; // a line is always inserted after a one-line comment
+ case Scanner.TokenNameCOMMENT_JAVADOC :
+ case Scanner.TokenNameCOMMENT_BLOCK :
+ currentCommentOffset = getCurrentCommentOffset();
+ if (openParenthesis[0]==0 && openBracketCount < 1){
+ pendingNewLines = 1;
+ // a new line is inserted only if the comment is not between parenthesis.
+ }
+ break;
+ case Scanner.TokenNameWHITESPACE :
+
+ // Count the number of line terminators in the whitespace so
+ // line spacing can be preserved near comments.
+
+ char[] source = scanner.source;
+ newLinesInWhitespace = 0;
+ for (
+ int i = scanner.startPosition, max = scanner.currentPosition;
+ i < max;
+ i++) {
+ if (source[i] == '\n') {
+ newLinesInWhitespace++;
+ }
+ }
+ increaseLineDelta(scanner.startPosition - scanner.currentPosition);
+ break;
+ default :
+ if ((token == TokenNameIdentifier)
+ || isLiteralToken(token)
+ || token == TokenNamesuper
+ || token == TokenNamethis) {
+
+ // Do not put a space between a unary operator
+ // (eg: ++, --, +, -) and the identifier being modified.
+
+ unarySignModifier -= (unarySignModifier > 0) ? 1 : 0;
+ if (previousToken == TokenNamePLUS_PLUS
+ || previousToken == TokenNameMINUS_MINUS
+ || (unarySignModifier > 0)) {
+ pendingSpace = false;
+ }
+ }
+ break;
+ }
+
+ // Do not output whitespace tokens.
+
+ if (token != Scanner.TokenNameWHITESPACE) {
+
+ /* Add pending space to the formatted source string.
+ Do not output a space under the following circumstances:
+ 1) this is the first pass
+ 2) previous token is an open paren
+ 3) previous token is a period
+ 4) previous token is the logical compliment (eg: !)
+ 5) previous token is the bitwise compliment (eg: ~)
+ 6) previous token is the open bracket (eg: [)
+ 7) in an assignment statement, if the previous token is an
+ open brace or the current token is a close brace
+ 8) previous token is a single line comment
+ */
+
+ boolean openAndCloseBrace = previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE;
+
+ // to be replaced by a nicer condition.
+
+ if (pendingSpace
+ && insertSpaceAfter(previousToken)
+ && ! (inAssignment
+ && (previousToken == TokenNameLBRACE || token == TokenNameRBRACE))
+ && previousToken != Scanner.TokenNameCOMMENT_LINE) {
+ if ((! (options.compactAssignmentMode && token == TokenNameEQUAL)) && !openAndCloseBrace)
+ space();
+ }
+
+ // Add the next token to the formatted source string.
+
+ outputCurrentToken(token);
+ if (token == Scanner.TokenNameCOMMENT_LINE && openParenthesisCount > 1){
+ pendingNewLines = 0;
+ currentLineBuffer.append(options.lineSeparatorSequence);
+ increaseLineDelta(options.lineSeparatorSequence.length);
+ }
+ pendingSpace = true;
+ }
+
+ // Whitespace tokens do not need to be remembered.
+
+ if (token != Scanner.TokenNameWHITESPACE) {
+ previousToken = token;
+ if (token != Scanner.TokenNameCOMMENT_BLOCK
+ && token != Scanner.TokenNameCOMMENT_LINE
+ && token != Scanner.TokenNameCOMMENT_JAVADOC) {
+ previousCompilableToken = token;
+ }
+ }
+
+ }
+ output(copyRemainingSource());
+ flushBuffer(); // dump the last token of the source in the formatted output.
+ } catch (InvalidInputException e) {
+ output(copyRemainingSource());
+ flushBuffer(); // dump the last token of the source in the formatted output.
+ }
}
/**
* Formats a given source string, starting indenting it at depth 0
* using default options.
*/
public static String format(String sourceString) {
- return format(sourceString, 0, null);
+ return format(sourceString, 0, null);
}
/**
* Formats a given source string, starting indenting it at a particular
* depth and using the given options
*/
public static String format(String sourceString, int initialIndentationLevel, ConfigurableOption[] options) {
- CodeFormatter formatter = new CodeFormatter(options);
- formatter.setInitialIndentationLevel(initialIndentationLevel);
- return formatter.formatSourceString(sourceString);
+ CodeFormatter formatter = new CodeFormatter(options);
+ formatter.setInitialIndentationLevel(initialIndentationLevel);
+ return formatter.formatSourceString(sourceString);
}
/**
* Formats the char array <code>sourceString</code>,
@@ -902,66 +891,58 @@ public static String format(String sourceString, int initialIndentationLevel, Co
* @return the formatted ouput.
*/
public String formatSourceString(String sourceString) {
- char[] sourceChars = sourceString.toCharArray();
- formattedSource = new StringBuffer(sourceChars.length);
- scanner.setSourceBuffer(sourceChars);
- format();
- return formattedSource.toString();
+ char[] sourceChars = sourceString.toCharArray();
+ formattedSource = new StringBuffer(sourceChars.length);
+ scanner.setSourceBuffer(sourceChars);
+ format();
+ return formattedSource.toString();
}
/**
* Returns the number of characters and tab char between the beginning of the line
* and the beginning of the comment.
*/
private int getCurrentCommentOffset() {
- int linePtr = scanner.linePtr;
- // if there is no beginning of line, return 0.
- if (linePtr < 0)
- return 0;
- int offset = 0;
- int beginningOfLine = scanner.lineEnds[linePtr];
- int currentStartPosition = scanner.startPosition;
- char[] source = scanner.source;
-
- // find the position of the beginning of the line containing the comment
- while (beginningOfLine > currentStartPosition) {
- if (linePtr > 0) {
- beginningOfLine = scanner.lineEnds[--linePtr];
- } else {
- beginningOfLine = 0;
- break;
- }
- }
-
- for (int i = beginningOfLine ; i < currentStartPosition ; i++){
- char currentCharacter = source[i];
- switch(currentCharacter){
- case '\t':
- offset += options.tabSize;
- case '\n':
- case '\r':
- break;
- default:
- offset++;
- }
- }
-
- return offset;
+ int linePtr = scanner.linePtr;
+ // if there is no beginning of line, return 0.
+ if (linePtr < 0)
+ return 0;
+ int offset = 0;
+ int beginningOfLine = scanner.lineEnds[linePtr];
+ int currentStartPosition = scanner.startPosition;
+ char[] source = scanner.source;
+
+ // find the position of the beginning of the line containing the comment
+ while (beginningOfLine > currentStartPosition) {
+ if (linePtr > 0) {
+ beginningOfLine = scanner.lineEnds[--linePtr];
+ } else {
+ beginningOfLine = 0;
+ break;
+ }
+ }
+
+ for (int i = beginningOfLine ; i < currentStartPosition ; i++){
+ char currentCharacter = source[i];
+ switch(currentCharacter){
+ case '\t':
+ offset += options.tabSize;
+ case '\n':
+ case '\r':
+ break;
+ default:
+ offset++;
+ }
+ }
+
+ return offset;
}
/**
- * Returns all the options of the Code Formatter to be shown by the UI
- *
- * @param locale java.util.Locale
- * @return org.eclipse.jdt.internal.compiler.java.ConfigurableOption[]
+ * Returns an array of descriptions for the configurable options.
+ * The descriptions may be changed and passed back to a different
+ * compiler.
*/
public static ConfigurableOption[] getDefaultOptions(Locale locale) {
- String[] ids = ConfigurableOption.getIDs(CodeFormatter.class.getName(),locale);
-
- ConfigurableOption[] result = new ConfigurableOption[ids.length];
- for(int i = 0 ; i < ids.length ; i++){
- result[i] = new ConfigurableOption(ids[i],locale);
- }
-
- return result;
+ return new FormatterOptions().getConfigurableOptions(locale);
}
/**
* Returns the array of mapped positions.
@@ -969,7 +950,7 @@ public static ConfigurableOption[] getDefaultOptions(Locale locale) {
* @return int[]
*/
public int[] getMappedPositions() {
- return mappedPositions;
+ return mappedPositions;
}
/**
* Returns the priority of the token given as argument<br>
@@ -978,104 +959,104 @@ public int[] getMappedPositions() {
* @param token the token of which the priority is requested
*/
private static int getTokenPriority(int token) {
- switch (token) {
- case TokenNameextends:
- case TokenNameimplements:
- case TokenNamethrows:
- return 10;
- case TokenNameSEMICOLON : // ;
- return 20;
- case TokenNameCOMMA : // ,
- return 25;
- case TokenNameEQUAL : // =
- return 30;
- case TokenNameAND_AND : // &&
- case TokenNameOR_OR : // ||
- return 40;
- case TokenNameQUESTION : // ?
- case TokenNameCOLON : // :
- return 50; // it's better cutting on ?: than on ;
- case TokenNameEQUAL_EQUAL : // ==
- case TokenNameNOT_EQUAL : // !=
- return 60;
- case TokenNameLESS : // <
- case TokenNameLESS_EQUAL : // <=
- case TokenNameGREATER : // >
- case TokenNameGREATER_EQUAL : // >=
- case TokenNameinstanceof : // instanceof
- return 70;
- case TokenNamePLUS : // +
- case TokenNameMINUS : // -
- return 80;
- case TokenNameMULTIPLY : // *
- case TokenNameDIVIDE : // /
- case TokenNameREMAINDER : // %
- return 90;
- case TokenNameLEFT_SHIFT : // <<
- case TokenNameRIGHT_SHIFT : // >>
- case TokenNameUNSIGNED_RIGHT_SHIFT : // >>>
- return 100;
- case TokenNameAND : // &
- case TokenNameOR : // |
- case TokenNameXOR : // ^
- return 110;
- case TokenNameMULTIPLY_EQUAL : // *=
- case TokenNameDIVIDE_EQUAL : // /=
- case TokenNameREMAINDER_EQUAL : // %=
- case TokenNamePLUS_EQUAL : // +=
- case TokenNameMINUS_EQUAL : // -=
- case TokenNameLEFT_SHIFT_EQUAL : // <<=
- case TokenNameRIGHT_SHIFT_EQUAL : // >>=
- case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>=
- case TokenNameAND_EQUAL : // &=
- case TokenNameXOR_EQUAL : // ^=
- case TokenNameOR_EQUAL : // |=
- return 120;
- case TokenNameDOT : // .
- return 130;
- default :
- return Integer.MAX_VALUE;
- }
+ switch (token) {
+ case TokenNameextends:
+ case TokenNameimplements:
+ case TokenNamethrows:
+ return 10;
+ case TokenNameSEMICOLON : // ;
+ return 20;
+ case TokenNameCOMMA : // ,
+ return 25;
+ case TokenNameEQUAL : // =
+ return 30;
+ case TokenNameAND_AND : // &&
+ case TokenNameOR_OR : // ||
+ return 40;
+ case TokenNameQUESTION : // ?
+ case TokenNameCOLON : // :
+ return 50; // it's better cutting on ?: than on ;
+ case TokenNameEQUAL_EQUAL : // ==
+ case TokenNameNOT_EQUAL : // !=
+ return 60;
+ case TokenNameLESS : // <
+ case TokenNameLESS_EQUAL : // <=
+ case TokenNameGREATER : // >
+ case TokenNameGREATER_EQUAL : // >=
+ case TokenNameinstanceof : // instanceof
+ return 70;
+ case TokenNamePLUS : // +
+ case TokenNameMINUS : // -
+ return 80;
+ case TokenNameMULTIPLY : // *
+ case TokenNameDIVIDE : // /
+ case TokenNameREMAINDER : // %
+ return 90;
+ case TokenNameLEFT_SHIFT : // <<
+ case TokenNameRIGHT_SHIFT : // >>
+ case TokenNameUNSIGNED_RIGHT_SHIFT : // >>>
+ return 100;
+ case TokenNameAND : // &
+ case TokenNameOR : // |
+ case TokenNameXOR : // ^
+ return 110;
+ case TokenNameMULTIPLY_EQUAL : // *=
+ case TokenNameDIVIDE_EQUAL : // /=
+ case TokenNameREMAINDER_EQUAL : // %=
+ case TokenNamePLUS_EQUAL : // +=
+ case TokenNameMINUS_EQUAL : // -=
+ case TokenNameLEFT_SHIFT_EQUAL : // <<=
+ case TokenNameRIGHT_SHIFT_EQUAL : // >>=
+ case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>=
+ case TokenNameAND_EQUAL : // &=
+ case TokenNameXOR_EQUAL : // ^=
+ case TokenNameOR_EQUAL : // |=
+ return 120;
+ case TokenNameDOT : // .
+ return 130;
+ default :
+ return Integer.MAX_VALUE;
+ }
}
/**
* Handles the exception raised when an invalid token is encountered.
* Returns true if the exception has been handled, false otherwise.
*/
private boolean handleInvalidToken(Exception e) {
- if (e.getMessage().equals(Scanner.INVALID_CHARACTER_CONSTANT)
- || e.getMessage().equals(Scanner.INVALID_CHAR_IN_STRING)
- || e.getMessage().equals(Scanner.INVALID_ESCAPE)) {
- return true;
- }
- return false;
+ if (e.getMessage().equals(Scanner.INVALID_CHARACTER_CONSTANT)
+ || e.getMessage().equals(Scanner.INVALID_CHAR_IN_STRING)
+ || e.getMessage().equals(Scanner.INVALID_ESCAPE)) {
+ return true;
+ }
+ return false;
}
private final void increaseGlobalDelta(int offset) {
- globalDelta += offset;
+ globalDelta += offset;
}
private final void increaseLineDelta(int offset) {
- lineDelta += offset;
+ lineDelta += offset;
}
private final void increaseSplitDelta(int offset) {
- splitDelta += offset;
+ splitDelta += offset;
}
/**
* Returns true if a space has to be inserted after <code>operator</code>
* false otherwise.
*/
private boolean insertSpaceAfter(int token) {
- switch (token){
- case TokenNameLPAREN:
- case TokenNameNOT:
- case TokenNameTWIDDLE:
- case TokenNameDOT :
- case 0: // no token
- case TokenNameLBRACKET:
- case Scanner.TokenNameCOMMENT_LINE:
- return false;
- default:
- return true;
- }
-
+ switch (token){
+ case TokenNameLPAREN:
+ case TokenNameNOT:
+ case TokenNameTWIDDLE:
+ case TokenNameDOT :
+ case 0: // no token
+ case TokenNameLBRACKET:
+ case Scanner.TokenNameCOMMENT_LINE:
+ return false;
+ default:
+ return true;
+ }
+
}
/**
* Returns true if a space has to be inserted before <code>operator</code>
@@ -1084,29 +1065,29 @@ private boolean insertSpaceAfter(int token) {
* (to know if the compact assignment mode is on).
*/
private boolean insertSpaceBefore(int token) {
- switch (token) {
- case TokenNameEQUAL:
- return (!options.compactAssignmentMode);
- default :
- return false;
- }
+ switch (token) {
+ case TokenNameEQUAL:
+ return (!options.compactAssignmentMode);
+ default :
+ return false;
+ }
}
private static boolean isComment(int token) {
- boolean result =
- token == Scanner.TokenNameCOMMENT_BLOCK ||
- token == Scanner.TokenNameCOMMENT_LINE ||
- token == Scanner.TokenNameCOMMENT_JAVADOC;
- return result;
+ boolean result =
+ token == Scanner.TokenNameCOMMENT_BLOCK ||
+ token == Scanner.TokenNameCOMMENT_LINE ||
+ token == Scanner.TokenNameCOMMENT_JAVADOC;
+ return result;
}
private static boolean isLiteralToken(int token) {
- boolean result =
- token == TokenNameIntegerLiteral ||
- token == TokenNameLongLiteral ||
- token == TokenNameFloatingPointLiteral ||
- token == TokenNameDoubleLiteral ||
- token == TokenNameCharacterLiteral ||
- token == TokenNameStringLiteral;
- return result;
+ boolean result =
+ token == TokenNameIntegerLiteral ||
+ token == TokenNameLongLiteral ||
+ token == TokenNameFloatingPointLiteral ||
+ token == TokenNameDoubleLiteral ||
+ token == TokenNameCharacterLiteral ||
+ token == TokenNameStringLiteral;
+ return result;
}
/**
* If the length of <code>oneLineBuffer</code> exceeds <code>maxLineLength</code>,
@@ -1115,241 +1096,241 @@ private static boolean isLiteralToken(int token) {
*/
private void newLine(int newLineCount) {
- // format current line
- splitDelta = 0;
- beginningOfLineIndex = formattedSource.length();
- String currentLine = currentLineBuffer.toString();
- if (containsOpenCloseBraces) {
- containsOpenCloseBraces = false;
- outputLine(currentLine,
- false,
- indentationLevelForOpenCloseBraces,
- 0,
- -1,
- null,
- 0);
- indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
- } else {
- outputLine(currentLine,
- false,
- currentLineIndentationLevel,
- 0,
- -1,
- null,
- 0);
- }
- // dump line break(s)
- for (int i = 0; i < newLineCount; i++) {
- formattedSource.append(options.lineSeparatorSequence);
- increaseSplitDelta(options.lineSeparatorSequence.length);
- }
- // reset formatter for next line
- int currentLength = currentLine.length();
- currentLineBuffer = new StringBuffer(
- currentLength > maxLineSize
- ? maxLineSize = currentLength
- : maxLineSize);
-
- increaseGlobalDelta(splitDelta);
- increaseGlobalDelta(lineDelta);
- lineDelta = 0;
- currentLineIndentationLevel = initialIndentationLevel;
+ // format current line
+ splitDelta = 0;
+ beginningOfLineIndex = formattedSource.length();
+ String currentLine = currentLineBuffer.toString();
+ if (containsOpenCloseBraces) {
+ containsOpenCloseBraces = false;
+ outputLine(currentLine,
+ false,
+ indentationLevelForOpenCloseBraces,
+ 0,
+ -1,
+ null,
+ 0);
+ indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
+ } else {
+ outputLine(currentLine,
+ false,
+ currentLineIndentationLevel,
+ 0,
+ -1,
+ null,
+ 0);
+ }
+ // dump line break(s)
+ for (int i = 0; i < newLineCount; i++) {
+ formattedSource.append(options.lineSeparatorSequence);
+ increaseSplitDelta(options.lineSeparatorSequence.length);
+ }
+ // reset formatter for next line
+ int currentLength = currentLine.length();
+ currentLineBuffer = new StringBuffer(
+ currentLength > maxLineSize
+ ? maxLineSize = currentLength
+ : maxLineSize);
+
+ increaseGlobalDelta(splitDelta);
+ increaseGlobalDelta(lineDelta);
+ lineDelta = 0;
+ currentLineIndentationLevel = initialIndentationLevel;
}
private String operatorString(int operator) {
- switch (operator) {
- case TokenNameextends :
- return "extends"; //$NON-NLS-1$
+ switch (operator) {
+ case TokenNameextends :
+ return "extends"/*nonNLS*/;
- case TokenNameimplements :
- return "implements"; //$NON-NLS-1$
+ case TokenNameimplements :
+ return "implements"/*nonNLS*/;
- case TokenNamethrows :
- return "throws"; //$NON-NLS-1$
+ case TokenNamethrows :
+ return "throws"/*nonNLS*/;
- case TokenNameSEMICOLON : // ;
- return ";"; //$NON-NLS-1$
+ case TokenNameSEMICOLON : // ;
+ return ";"/*nonNLS*/;
- case TokenNameCOMMA : // ,
- return ","; //$NON-NLS-1$
+ case TokenNameCOMMA : // ,
+ return ","/*nonNLS*/;
- case TokenNameEQUAL : // =
- return "="; //$NON-NLS-1$
+ case TokenNameEQUAL : // =
+ return "="/*nonNLS*/;
- case TokenNameAND_AND : // && (15.22)
- return "&&"; //$NON-NLS-1$
+ case TokenNameAND_AND : // && (15.22)
+ return "&&"/*nonNLS*/;
- case TokenNameOR_OR : // || (15.23)
- return "||"; //$NON-NLS-1$
+ case TokenNameOR_OR : // || (15.23)
+ return "||"/*nonNLS*/;
- case TokenNameQUESTION : // ? (15.24)
- return "?"; //$NON-NLS-1$
+ case TokenNameQUESTION : // ? (15.24)
+ return "?"/*nonNLS*/;
- case TokenNameCOLON : // : (15.24)
- return ":"; //$NON-NLS-1$
+ case TokenNameCOLON : // : (15.24)
+ return ":"/*nonNLS*/;
- case TokenNameEQUAL_EQUAL : // == (15.20, 15.20.1, 15.20.2, 15.20.3)
- return "=="; //$NON-NLS-1$
+ case TokenNameEQUAL_EQUAL : // == (15.20, 15.20.1, 15.20.2, 15.20.3)
+ return "=="/*nonNLS*/;
- case TokenNameNOT_EQUAL : // != (15.20, 15.20.1, 15.20.2, 15.20.3)
- return "!="; //$NON-NLS-1$
+ case TokenNameNOT_EQUAL : // != (15.20, 15.20.1, 15.20.2, 15.20.3)
+ return "!="/*nonNLS*/;
- case TokenNameLESS : // < (15.19.1)
- return "<"; //$NON-NLS-1$
+ case TokenNameLESS : // < (15.19.1)
+ return "<"/*nonNLS*/;
- case TokenNameLESS_EQUAL : // <= (15.19.1)
- return "<="; //$NON-NLS-1$
+ case TokenNameLESS_EQUAL : // <= (15.19.1)
+ return "<="/*nonNLS*/;
- case TokenNameGREATER : // > (15.19.1)
- return ">"; //$NON-NLS-1$
+ case TokenNameGREATER : // > (15.19.1)
+ return ">"/*nonNLS*/;
- case TokenNameGREATER_EQUAL : // >= (15.19.1)
- return ">="; //$NON-NLS-1$
+ case TokenNameGREATER_EQUAL : // >= (15.19.1)
+ return ">="/*nonNLS*/;
- case TokenNameinstanceof : // instanceof
- return "instanceof"; //$NON-NLS-1$
+ case TokenNameinstanceof : // instanceof
+ return "instanceof"/*nonNLS*/;
- case TokenNamePLUS : // + (15.17, 15.17.2)
- return "+"; //$NON-NLS-1$
+ case TokenNamePLUS : // + (15.17, 15.17.2)
+ return "+"/*nonNLS*/;
- case TokenNameMINUS : // - (15.17.2)
- return "-"; //$NON-NLS-1$
+ case TokenNameMINUS : // - (15.17.2)
+ return "-"/*nonNLS*/;
- case TokenNameMULTIPLY : // * (15.16.1)
- return "*"; //$NON-NLS-1$
+ case TokenNameMULTIPLY : // * (15.16.1)
+ return "*"/*nonNLS*/;
- case TokenNameDIVIDE : // / (15.16.2)
- return "/"; //$NON-NLS-1$
+ case TokenNameDIVIDE : // / (15.16.2)
+ return "/"/*nonNLS*/;
- case TokenNameREMAINDER : // % (15.16.3)
- return "%"; //$NON-NLS-1$
+ case TokenNameREMAINDER : // % (15.16.3)
+ return "%"/*nonNLS*/;
- case TokenNameLEFT_SHIFT : // << (15.18)
- return "<<"; //$NON-NLS-1$
+ case TokenNameLEFT_SHIFT : // << (15.18)
+ return "<<"/*nonNLS*/;
- case TokenNameRIGHT_SHIFT : // >> (15.18)
- return ">>"; //$NON-NLS-1$
+ case TokenNameRIGHT_SHIFT : // >> (15.18)
+ return ">>"/*nonNLS*/;
- case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
- return ">>>"; //$NON-NLS-1$
+ case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
+ return ">>>"/*nonNLS*/;
- case TokenNameAND : // & (15.21, 15.21.1, 15.21.2)
- return "&"; //$NON-NLS-1$
+ case TokenNameAND : // & (15.21, 15.21.1, 15.21.2)
+ return "&"/*nonNLS*/;
- case TokenNameOR : // | (15.21, 15.21.1, 15.21.2)
- return "|"; //$NON-NLS-1$
+ case TokenNameOR : // | (15.21, 15.21.1, 15.21.2)
+ return "|"/*nonNLS*/;
- case TokenNameXOR : // ^ (15.21, 15.21.1, 15.21.2)
- return "^"; //$NON-NLS-1$
+ case TokenNameXOR : // ^ (15.21, 15.21.1, 15.21.2)
+ return "^"/*nonNLS*/;
- case TokenNameMULTIPLY_EQUAL : // *= (15.25.2)
- return "*="; //$NON-NLS-1$
+ case TokenNameMULTIPLY_EQUAL : // *= (15.25.2)
+ return "*="/*nonNLS*/;
- case TokenNameDIVIDE_EQUAL : // /= (15.25.2)
- return "/="; //$NON-NLS-1$
+ case TokenNameDIVIDE_EQUAL : // /= (15.25.2)
+ return "/="/*nonNLS*/;
- case TokenNameREMAINDER_EQUAL : // %= (15.25.2)
- return "%="; //$NON-NLS-1$
+ case TokenNameREMAINDER_EQUAL : // %= (15.25.2)
+ return "%="/*nonNLS*/;
- case TokenNamePLUS_EQUAL : // += (15.25.2)
- return "+="; //$NON-NLS-1$
+ case TokenNamePLUS_EQUAL : // += (15.25.2)
+ return "+="/*nonNLS*/;
- case TokenNameMINUS_EQUAL : // -= (15.25.2)
- return "-="; //$NON-NLS-1$
+ case TokenNameMINUS_EQUAL : // -= (15.25.2)
+ return "-="/*nonNLS*/;
- case TokenNameLEFT_SHIFT_EQUAL : // <<= (15.25.2)
- return "<<="; //$NON-NLS-1$
+ case TokenNameLEFT_SHIFT_EQUAL : // <<= (15.25.2)
+ return "<<="/*nonNLS*/;
- case TokenNameRIGHT_SHIFT_EQUAL : // >>= (15.25.2)
- return ">>="; //$NON-NLS-1$
+ case TokenNameRIGHT_SHIFT_EQUAL : // >>= (15.25.2)
+ return ">>="/*nonNLS*/;
- case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
- return ">>>="; //$NON-NLS-1$
+ case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
+ return ">>>="/*nonNLS*/;
- case TokenNameAND_EQUAL : // &= (15.25.2)
- return "&="; //$NON-NLS-1$
+ case TokenNameAND_EQUAL : // &= (15.25.2)
+ return "&="/*nonNLS*/;
- case TokenNameXOR_EQUAL : // ^= (15.25.2)
- return "^="; //$NON-NLS-1$
+ case TokenNameXOR_EQUAL : // ^= (15.25.2)
+ return "^="/*nonNLS*/;
- case TokenNameOR_EQUAL : // |= (15.25.2)
- return "|="; //$NON-NLS-1$
+ case TokenNameOR_EQUAL : // |= (15.25.2)
+ return "|="/*nonNLS*/;
- case TokenNameDOT : // .
- return "."; //$NON-NLS-1$
+ case TokenNameDOT : // .
+ return "."/*nonNLS*/;
- default :
- return ""; //$NON-NLS-1$
- }
+ default :
+ return ""/*nonNLS*/;
+ }
}
/**
* Appends <code>stringToOutput</code> to the formatted output.<br>
* If it contains \n, append a LINE_SEPARATOR and indent after it.
*/
private void output(String stringToOutput) {
- char currentCharacter;
- for (int i = 0, max = stringToOutput.length(); i < max; i++) {
- currentCharacter = stringToOutput.charAt(i);
- if (currentCharacter != '\t') {
- currentLineBuffer.append(currentCharacter);
- }
- }
- updateMappedPositions(scanner.startPosition);
+ char currentCharacter;
+ for (int i = 0, max = stringToOutput.length(); i < max; i++) {
+ currentCharacter = stringToOutput.charAt(i);
+ if (currentCharacter != '\t') {
+ currentLineBuffer.append(currentCharacter);
+ }
+ }
+ updateMappedPositions(scanner.startPosition);
}
/**
* Appends <code>token</code> to the formatted output.<br>
* If it contains <code>\n</code>, append a LINE_SEPARATOR and indent after it.
*/
private void outputCurrentToken(int token) {
- char[] source = scanner.source;
- int startPosition = scanner.startPosition;
-
- switch(token) {
- case Scanner.TokenNameCOMMENT_JAVADOC :
- case Scanner.TokenNameCOMMENT_BLOCK :
- case Scanner.TokenNameCOMMENT_LINE :
- boolean endOfLine = false;
- int currentCommentOffset = getCurrentCommentOffset();
- int beginningOfLineSpaces = 0;
- for (int i = startPosition, max = scanner.currentPosition; i < max; i++) {
- char currentCharacter = source[i];
- switch(currentCharacter) {
- case '\r' :
- case '\n' :
- endOfLine = true;
- currentLineBuffer.append(currentCharacter);
- beginningOfLineSpaces = 0;
- break;
- case '\t' :
- if (endOfLine) {
- // we remove a maximum of currentCommentOffset characters (tabs are converted to space numbers).
- beginningOfLineSpaces+=options.tabSize;
- if (beginningOfLineSpaces > currentCommentOffset)
- currentLineBuffer.append(currentCharacter);
- } else {
- currentLineBuffer.append(currentCharacter);
- }
- break;
- case ' ' :
- if (endOfLine) {
- // we remove a maximum of currentCommentOffset characters (tabs are converted to space numbers).
- beginningOfLineSpaces++;
- if (beginningOfLineSpaces > currentCommentOffset)
- currentLineBuffer.append(currentCharacter);
- } else {
- currentLineBuffer.append(currentCharacter);
- }
- break;
- default:
- beginningOfLineSpaces = 0;
- currentLineBuffer.append(currentCharacter);
- endOfLine = false;
- }
- }
- break;
- default:
- currentLineBuffer.append(source, startPosition, scanner.currentPosition - startPosition);
- }
- updateMappedPositions(startPosition);
+ char[] source = scanner.source;
+ int startPosition = scanner.startPosition;
+
+ switch(token) {
+ case Scanner.TokenNameCOMMENT_JAVADOC :
+ case Scanner.TokenNameCOMMENT_BLOCK :
+ case Scanner.TokenNameCOMMENT_LINE :
+ boolean endOfLine = false;
+ int currentCommentOffset = getCurrentCommentOffset();
+ int beginningOfLineSpaces = 0;
+ for (int i = startPosition, max = scanner.currentPosition; i < max; i++) {
+ char currentCharacter = source[i];
+ switch(currentCharacter) {
+ case '\r' :
+ case '\n' :
+ endOfLine = true;
+ currentLineBuffer.append(currentCharacter);
+ beginningOfLineSpaces = 0;
+ break;
+ case '\t' :
+ if (endOfLine) {
+ // we remove a maximum of currentCommentOffset characters (tabs are converted to space numbers).
+ beginningOfLineSpaces+=options.tabSize;
+ if (beginningOfLineSpaces > currentCommentOffset)
+ currentLineBuffer.append(currentCharacter);
+ } else {
+ currentLineBuffer.append(currentCharacter);
+ }
+ break;
+ case ' ' :
+ if (endOfLine) {
+ // we remove a maximum of currentCommentOffset characters (tabs are converted to space numbers).
+ beginningOfLineSpaces++;
+ if (beginningOfLineSpaces > currentCommentOffset)
+ currentLineBuffer.append(currentCharacter);
+ } else {
+ currentLineBuffer.append(currentCharacter);
+ }
+ break;
+ default:
+ beginningOfLineSpaces = 0;
+ currentLineBuffer.append(currentCharacter);
+ endOfLine = false;
+ }
+ }
+ break;
+ default:
+ currentLineBuffer.append(source, startPosition, scanner.currentPosition - startPosition);
+ }
+ updateMappedPositions(startPosition);
}
/**
* Outputs <code>currentString</code>:<br>
@@ -1361,244 +1342,244 @@ private void outputCurrentToken(int token) {
* @param operator value of the operator belonging to <code>currentString</code>.
*/
private void outputLine(
- String currentString,
- boolean preIndented,
- int depth,
- int operator,
- int substringIndex,
- int[] startSubstringIndexes,
- int offsetInGlobalLine) {
-
- boolean emptyFirstSubString = false;
- String operatorString = operatorString(operator);
- boolean placeOperatorBehind = !breakLineBeforeOperator(operator);
- boolean placeOperatorAhead = !placeOperatorBehind;
-
- // dump prefix operator?
- if (placeOperatorAhead) {
- if (!preIndented) {
- dumpTab(depth);
- preIndented = true;
- }
- if (operator != 0) {
- if (insertSpaceBefore(operator)) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- formattedSource.append(operatorString);
- increaseSplitDelta(operatorString.length());
-
- if (insertSpaceAfter(operator)
- && operator != TokenNameimplements
- && operator != TokenNameextends
- && operator != TokenNamethrows) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- }
- }
- SplitLine splitLine = null;
- if (options.maxLineLength == 0
- || currentString.length() < options.maxLineLength
- || (splitLine = split(currentString, offsetInGlobalLine)) == null) {
- // depending on the type of operator, outputs new line before of after dumping it
- // indent before postfix operator
- // indent also when the line cannot be split
-
- if (operator == TokenNameextends
- || operator == TokenNameimplements
- || operator == TokenNamethrows) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
-
- if (placeOperatorBehind) {
- if (!preIndented) {
- dumpTab(depth);
- }
- }
-
- boolean containsMultiLineComment = currentString.lastIndexOf("/*") != -1; //$NON-NLS-1$
- int numberOfSpaces = 0;
- int max = currentString.length();
- updateMappedPositionsWhileSplitting(
- beginningOfLineIndex,
- beginningOfLineIndex + max);
- for (int i = 0; i < max; i++) {
- char currentChar = currentString.charAt(i);
- switch (currentChar) {
- case '\r' :
- break;
- case '\n' :
- if (i != max - 1) {
- // fix for 1FFYL5C: LFCOM:ALL - Incorrect indentation when split with a comment inside a condition
- // a substring cannot end with a lineSeparatorSequence,
- // except if it has been added by format() after a one-line comment
- formattedSource.append(options.lineSeparatorSequence);
- increaseSplitDelta(options.lineSeparatorSequence.length);
-
- if (containsMultiLineComment) {
- // fix for 1FGGQCN: LFCOM:ALL - Space management in comments for the formatter
- dumpTab(currentLineIndentationLevel);
- } else {
- // 1FGDDV6: LFCOM:WIN98 - Weird splitting on message expression
- dumpTab(depth - 1);
- }
- }
- break;
- default :
- formattedSource.append(currentChar);
- }
- }
-
- // update positions inside the mappedPositions table
- if (substringIndex != -1) {
- int startPosition =
- beginningOfLineIndex + startSubstringIndexes[substringIndex];
- updateMappedPositionsWhileSplitting(startPosition, startPosition + max);
-
- // compute the splitDelta resulting with the operator and blank removal
- if (substringIndex + 1 != startSubstringIndexes.length) {
- increaseSplitDelta(
- startSubstringIndexes[substringIndex]
- + max
- - startSubstringIndexes[substringIndex
- + 1]);
- }
- }
- // dump postfix operator?
- if (placeOperatorBehind) {
- if (insertSpaceBefore(operator)) {
- formattedSource.append(' ');
- if (operator != 0) {
- increaseSplitDelta(1);
- }
- }
- formattedSource.append(operatorString);
- if (operator != 0) {
- increaseSplitDelta(operatorString.length());
- }
- }
- return;
- }
-
- // fix for 1FG0BA3: LFCOM:WIN98 - Weird splitting on interfaces
- // extends has to stand alone on a line when currentString has been split.
- if (options.maxLineLength != 0
- && splitLine != null
- && (operator == TokenNameextends
- || operator == TokenNameimplements
- || operator == TokenNamethrows)) {
- formattedSource.append(options.lineSeparatorSequence);
- increaseSplitDelta(options.lineSeparatorSequence.length);
-
- dumpTab(depth + 1);
- } else {
- if (operator == TokenNameextends
- || operator == TokenNameimplements
- || operator == TokenNamethrows) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- }
-
- // perform actual splitting
- String result[] = splitLine.substrings;
- int[] splitOperators = splitLine.operators;
- int[] splitLineStartIndexes = splitLine.startSubstringsIndexes;
-
- if (result[0].length() == 0) {
- // when the substring 0 is null, the substring 1 is correctly indented.
- depth--;
- emptyFirstSubString = true;
- }
- // the operator going in front of the result[0] string is the operator parameter
-
- for (int i = 0, max = result.length; i < max; i++) {
- // the new depth is the current one if this is the first substring,
- // the current one + 1 otherwise.
-
- // if the substring is a comment, use the current indentation Level instead of the depth
- // (-1 because the ouputline increases depth).
- // (fix for 1FFC72R: LFCOM:ALL - Incorrect line split in presence of line comments)
- String currentResult = result[i];
-
- if (currentResult.length() != 0 || splitOperators[i] != 0) {
- int newDepth =
- (currentResult.startsWith("/*") || currentResult.startsWith("//")) //$NON-NLS-2$ //$NON-NLS-1$
- ? indentationLevel - 1
- : depth;
- outputLine(
- currentResult,
- i == 0 || (i == 1 && emptyFirstSubString) ? preIndented : false,
- i == 0 ? newDepth : newDepth + 1,
- splitOperators[i],
- i,
- splitLine.startSubstringsIndexes,
- currentString.indexOf(currentResult));
- if (i != max - 1) {
- formattedSource.append(options.lineSeparatorSequence);
- increaseSplitDelta(options.lineSeparatorSequence.length);
- }
- }
- }
- if (result.length == splitOperators.length - 1) {
- int lastOperator = splitOperators[result.length];
- String lastOperatorString = operatorString(lastOperator);
- formattedSource.append(options.lineSeparatorSequence);
- increaseSplitDelta(options.lineSeparatorSequence.length);
-
- if (breakLineBeforeOperator(lastOperator)) {
- dumpTab(depth + 1);
- if (lastOperator != 0) {
- if (insertSpaceBefore(lastOperator)) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- formattedSource.append(lastOperatorString);
- increaseSplitDelta(lastOperatorString.length());
-
- if (insertSpaceAfter(lastOperator)
- && lastOperator != TokenNameimplements
- && lastOperator != TokenNameextends
- && lastOperator != TokenNamethrows) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- }
- }
- }
- if (placeOperatorBehind) {
- if (insertSpaceBefore(operator)) {
- formattedSource.append(' ');
- increaseSplitDelta(1);
- }
- formattedSource.append(operatorString);
- //increaseSplitDelta(operatorString.length());
- }
+ String currentString,
+ boolean preIndented,
+ int depth,
+ int operator,
+ int substringIndex,
+ int[] startSubstringIndexes,
+ int offsetInGlobalLine) {
+
+ boolean emptyFirstSubString = false;
+ String operatorString = operatorString(operator);
+ boolean placeOperatorBehind = !breakLineBeforeOperator(operator);
+ boolean placeOperatorAhead = !placeOperatorBehind;
+
+ // dump prefix operator?
+ if (placeOperatorAhead) {
+ if (!preIndented) {
+ dumpTab(depth);
+ preIndented = true;
+ }
+ if (operator != 0) {
+ if (insertSpaceBefore(operator)) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ formattedSource.append(operatorString);
+ increaseSplitDelta(operatorString.length());
+
+ if (insertSpaceAfter(operator)
+ && operator != TokenNameimplements
+ && operator != TokenNameextends
+ && operator != TokenNamethrows) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ }
+ }
+ SplitLine splitLine = null;
+ if (options.maxLineLength == 0
+ || currentString.length() < options.maxLineLength
+ || (splitLine = split(currentString, offsetInGlobalLine)) == null) {
+ // depending on the type of operator, outputs new line before of after dumping it
+ // indent before postfix operator
+ // indent also when the line cannot be split
+
+ if (operator == TokenNameextends
+ || operator == TokenNameimplements
+ || operator == TokenNamethrows) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+
+ if (placeOperatorBehind) {
+ if (!preIndented) {
+ dumpTab(depth);
+ }
+ }
+
+ boolean containsMultiLineComment = currentString.lastIndexOf("/*"/*nonNLS*/) != -1;
+ int numberOfSpaces = 0;
+ int max = currentString.length();
+ updateMappedPositionsWhileSplitting(
+ beginningOfLineIndex,
+ beginningOfLineIndex + max);
+ for (int i = 0; i < max; i++) {
+ char currentChar = currentString.charAt(i);
+ switch (currentChar) {
+ case '\r' :
+ break;
+ case '\n' :
+ if (i != max - 1) {
+ // fix for 1FFYL5C: LFCOM:ALL - Incorrect indentation when split with a comment inside a condition
+ // a substring cannot end with a lineSeparatorSequence,
+ // except if it has been added by format() after a one-line comment
+ formattedSource.append(options.lineSeparatorSequence);
+ increaseSplitDelta(options.lineSeparatorSequence.length);
+
+ if (containsMultiLineComment) {
+ // fix for 1FGGQCN: LFCOM:ALL - Space management in comments for the formatter
+ dumpTab(currentLineIndentationLevel);
+ } else {
+ // 1FGDDV6: LFCOM:WIN98 - Weird splitting on message expression
+ dumpTab(depth - 1);
+ }
+ }
+ break;
+ default :
+ formattedSource.append(currentChar);
+ }
+ }
+
+ // update positions inside the mappedPositions table
+ if (substringIndex != -1) {
+ int startPosition =
+ beginningOfLineIndex + startSubstringIndexes[substringIndex];
+ updateMappedPositionsWhileSplitting(startPosition, startPosition + max);
+
+ // compute the splitDelta resulting with the operator and blank removal
+ if (substringIndex + 1 != startSubstringIndexes.length) {
+ increaseSplitDelta(
+ startSubstringIndexes[substringIndex]
+ + max
+ - startSubstringIndexes[substringIndex
+ + 1]);
+ }
+ }
+ // dump postfix operator?
+ if (placeOperatorBehind) {
+ if (insertSpaceBefore(operator)) {
+ formattedSource.append(' ');
+ if (operator != 0) {
+ increaseSplitDelta(1);
+ }
+ }
+ formattedSource.append(operatorString);
+ if (operator != 0) {
+ increaseSplitDelta(operatorString.length());
+ }
+ }
+ return;
+ }
+
+ // fix for 1FG0BA3: LFCOM:WIN98 - Weird splitting on interfaces
+ // extends has to stand alone on a line when currentString has been split.
+ if (options.maxLineLength != 0
+ && splitLine != null
+ && (operator == TokenNameextends
+ || operator == TokenNameimplements
+ || operator == TokenNamethrows)) {
+ formattedSource.append(options.lineSeparatorSequence);
+ increaseSplitDelta(options.lineSeparatorSequence.length);
+
+ dumpTab(depth + 1);
+ } else {
+ if (operator == TokenNameextends
+ || operator == TokenNameimplements
+ || operator == TokenNamethrows) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ }
+
+ // perform actual splitting
+ String result[] = splitLine.substrings;
+ int[] splitOperators = splitLine.operators;
+ int[] splitLineStartIndexes = splitLine.startSubstringsIndexes;
+
+ if (result[0].length() == 0) {
+ // when the substring 0 is null, the substring 1 is correctly indented.
+ depth--;
+ emptyFirstSubString = true;
+ }
+ // the operator going in front of the result[0] string is the operator parameter
+
+ for (int i = 0, max = result.length; i < max; i++) {
+ // the new depth is the current one if this is the first substring,
+ // the current one + 1 otherwise.
+
+ // if the substring is a comment, use the current indentation Level instead of the depth
+ // (-1 because the ouputline increases depth).
+ // (fix for 1FFC72R: LFCOM:ALL - Incorrect line split in presence of line comments)
+ String currentResult = result[i];
+
+ if (currentResult.length() != 0 || splitOperators[i] != 0) {
+ int newDepth =
+ (currentResult.startsWith("/*"/*nonNLS*/) || currentResult.startsWith("//"/*nonNLS*/))
+ ? indentationLevel - 1
+ : depth;
+ outputLine(
+ currentResult,
+ i == 0 || (i == 1 && emptyFirstSubString) ? preIndented : false,
+ i == 0 ? newDepth : newDepth + 1,
+ splitOperators[i],
+ i,
+ splitLine.startSubstringsIndexes,
+ currentString.indexOf(currentResult));
+ if (i != max - 1) {
+ formattedSource.append(options.lineSeparatorSequence);
+ increaseSplitDelta(options.lineSeparatorSequence.length);
+ }
+ }
+ }
+ if (result.length == splitOperators.length - 1) {
+ int lastOperator = splitOperators[result.length];
+ String lastOperatorString = operatorString(lastOperator);
+ formattedSource.append(options.lineSeparatorSequence);
+ increaseSplitDelta(options.lineSeparatorSequence.length);
+
+ if (breakLineBeforeOperator(lastOperator)) {
+ dumpTab(depth + 1);
+ if (lastOperator != 0) {
+ if (insertSpaceBefore(lastOperator)) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ formattedSource.append(lastOperatorString);
+ increaseSplitDelta(lastOperatorString.length());
+
+ if (insertSpaceAfter(lastOperator)
+ && lastOperator != TokenNameimplements
+ && lastOperator != TokenNameextends
+ && lastOperator != TokenNamethrows) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ }
+ }
+ }
+ if (placeOperatorBehind) {
+ if (insertSpaceBefore(operator)) {
+ formattedSource.append(' ');
+ increaseSplitDelta(1);
+ }
+ formattedSource.append(operatorString);
+ //increaseSplitDelta(operatorString.length());
+ }
}
/**
* Pops the top statement of the stack if it is <code>token</code>
*/
private int pop(int token) {
- int delta=0;
- if ((constructionsCount>0) && (constructions[constructionsCount-1]==token)){
- delta--;
- constructionsCount--;
- }
- return delta;
+ int delta=0;
+ if ((constructionsCount>0) && (constructions[constructionsCount-1]==token)){
+ delta--;
+ constructionsCount--;
+ }
+ return delta;
}
/**
* Pops the top statement of the stack if it is a <code>BLOCK</code> or a <code>NONINDENT_BLOCK</code>.
*/
private int popBlock() {
- int delta=0;
- if ((constructionsCount>0) && ((constructions[constructionsCount-1]==BLOCK) || (constructions[constructionsCount-1]==NONINDENT_BLOCK))){
- if (constructions[constructionsCount-1]==BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
+ int delta=0;
+ if ((constructionsCount>0) && ((constructions[constructionsCount-1]==BLOCK) || (constructions[constructionsCount-1]==NONINDENT_BLOCK))){
+ if (constructions[constructionsCount-1]==BLOCK)
+ delta--;
+ constructionsCount--;
+ }
+ return delta;
}
/**
* Pops elements until the stack is empty or the top element is <code>token</code>.<br>
@@ -1606,14 +1587,14 @@ private int popBlock() {
* @param token the token to be left as the top of the stack
*/
private int popExclusiveUntil(int token) {
- int delta=0;
- int startCount=constructionsCount;
- for (int i = startCount-1; i >= 0 && constructions[i] != token; i--){
- if (constructions[i]!=NONINDENT_BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
+ int delta=0;
+ int startCount=constructionsCount;
+ for (int i = startCount-1; i >= 0 && constructions[i] != token; i--){
+ if (constructions[i]!=NONINDENT_BLOCK)
+ delta--;
+ constructionsCount--;
+ }
+ return delta;
}
/**
* Pops elements until the stack is empty or the top element is
@@ -1621,13 +1602,13 @@ private int popExclusiveUntil(int token) {
* Does not remove it from the stack.
*/
private int popExclusiveUntilBlock(){
- int startCount=constructionsCount;
- int delta=0;
- for (int i = startCount-1; i >= 0 && constructions[i] != BLOCK && constructions[i] != NONINDENT_BLOCK; i--){
- constructionsCount--;
- delta--;
- }
- return delta;
+ int startCount=constructionsCount;
+ int delta=0;
+ for (int i = startCount-1; i >= 0 && constructions[i] != BLOCK && constructions[i] != NONINDENT_BLOCK; i--){
+ constructionsCount--;
+ delta--;
+ }
+ return delta;
}
/**
* Pops elements until the stack is empty or the top element is
@@ -1635,13 +1616,13 @@ private int popExclusiveUntilBlock(){
* Does not remove it from the stack.
*/
private int popExclusiveUntilBlockOrCase(){
- int startCount=constructionsCount;
- int delta=0;
- for (int i = startCount-1; i >= 0 && constructions[i] != BLOCK && constructions[i] != NONINDENT_BLOCK && constructions[i]!=TokenNamecase; i--){
- constructionsCount--;
- delta--;
- }
- return delta;
+ int startCount=constructionsCount;
+ int delta=0;
+ for (int i = startCount-1; i >= 0 && constructions[i] != BLOCK && constructions[i] != NONINDENT_BLOCK && constructions[i]!=TokenNamecase; i--){
+ constructionsCount--;
+ delta--;
+ }
+ return delta;
}
/**
* Pops elements until the stack is empty or the top element is <code>token</code>.<br>
@@ -1649,19 +1630,19 @@ private int popExclusiveUntilBlockOrCase(){
* @param token the token to remove from the stack
*/
private int popInclusiveUntil(int token) {
- int startCount=constructionsCount;
- int delta=0;
- for (int i = startCount-1; i >= 0 && constructions[i] != token; i--){
- if (constructions[i]!=NONINDENT_BLOCK)
- delta--;
- constructionsCount--;
- }
- if (constructionsCount>0){
- if (constructions[constructionsCount-1]!=NONINDENT_BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
+ int startCount=constructionsCount;
+ int delta=0;
+ for (int i = startCount-1; i >= 0 && constructions[i] != token; i--){
+ if (constructions[i]!=NONINDENT_BLOCK)
+ delta--;
+ constructionsCount--;
+ }
+ if (constructionsCount>0){
+ if (constructions[constructionsCount-1]!=NONINDENT_BLOCK)
+ delta--;
+ constructionsCount--;
+ }
+ return delta;
}
/**
* Pops elements until the stack is empty or the top element is
@@ -1669,18 +1650,18 @@ private int popInclusiveUntil(int token) {
* Does not remove it from the stack.
*/
private int popInclusiveUntilBlock() {
- int startCount=constructionsCount;
- int delta=0;
- for (int i = startCount-1; i >= 0 && (constructions[i] != BLOCK && constructions[i]!=NONINDENT_BLOCK); i--){
- delta--;
- constructionsCount--;
- }
- if (constructionsCount>0){
- if (constructions[constructionsCount-1]==BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
+ int startCount=constructionsCount;
+ int delta=0;
+ for (int i = startCount-1; i >= 0 && (constructions[i] != BLOCK && constructions[i]!=NONINDENT_BLOCK); i--){
+ delta--;
+ constructionsCount--;
+ }
+ if (constructionsCount>0){
+ if (constructions[constructionsCount-1]==BLOCK)
+ delta--;
+ constructionsCount--;
+ }
+ return delta;
}
/**
* Pushes a block in the stack.<br>
@@ -1689,45 +1670,45 @@ private int popInclusiveUntilBlock() {
* Creates a new bigger array if the current one is full.
*/
private int pushBlock() {
- int delta = 0;
- if (constructionsCount == constructions.length)
- System
- .arraycopy(constructions,
- 0,
- (constructions = new int[constructionsCount * 2]),
- 0,
- constructionsCount);
-
- if ((constructionsCount == 0)
- || (constructions[constructionsCount - 1] == BLOCK)
- || (constructions[constructionsCount - 1] == NONINDENT_BLOCK)
- || (constructions[constructionsCount - 1] == TokenNamecase)) {
- delta++;
- constructions[constructionsCount++] = BLOCK;
- }
- else {
- constructions[constructionsCount++] = NONINDENT_BLOCK;
- }
- return delta;
+ int delta = 0;
+ if (constructionsCount == constructions.length)
+ System
+ .arraycopy(constructions,
+ 0,
+ (constructions = new int[constructionsCount * 2]),
+ 0,
+ constructionsCount);
+
+ if ((constructionsCount == 0)
+ || (constructions[constructionsCount - 1] == BLOCK)
+ || (constructions[constructionsCount - 1] == NONINDENT_BLOCK)
+ || (constructions[constructionsCount - 1] == TokenNamecase)) {
+ delta++;
+ constructions[constructionsCount++] = BLOCK;
+ }
+ else {
+ constructions[constructionsCount++] = NONINDENT_BLOCK;
+ }
+ return delta;
}
/**
* Pushes <code>token</code>.<br>
* Creates a new bigger array if the current one is full.
*/
private int pushControlStatement(int token) {
- if (constructionsCount == constructions.length)
- System.arraycopy(constructions, 0, (constructions = new int[constructionsCount * 2]), 0, constructionsCount);
- constructions[constructionsCount++] = token;
- return 1;
+ if (constructionsCount == constructions.length)
+ System.arraycopy(constructions, 0, (constructions = new int[constructionsCount * 2]), 0, constructionsCount);
+ constructions[constructionsCount++] = token;
+ return 1;
}
private static boolean separateFirstArgumentOn(int currentToken) {
- //return (currentToken == TokenNameCOMMA || currentToken == TokenNameSEMICOLON);
- return currentToken != TokenNameif
- && currentToken != TokenNameLPAREN
- && currentToken != TokenNameNOT
- && currentToken != TokenNamewhile
- && currentToken != TokenNamefor
- && currentToken != TokenNameswitch;
+ //return (currentToken == TokenNameCOMMA || currentToken == TokenNameSEMICOLON);
+ return currentToken != TokenNameif
+ && currentToken != TokenNameLPAREN
+ && currentToken != TokenNameNOT
+ && currentToken != TokenNamewhile
+ && currentToken != TokenNamefor
+ && currentToken != TokenNameswitch;
}
/**
* Sets the behaviour of the formatter about the braces
@@ -1743,7 +1724,7 @@ private static boolean separateFirstArgumentOn(int currentToken) {
* @see addNewLineOnOpeningBrace(boolean)
*/
public void setBraceIndentationLevel(int newBraceIndentationLevel) {
- options.setNewLineBeforeOpeningBraceMode(newBraceIndentationLevel==0);
+ options.setNewLineBeforeOpeningBraceMode(newBraceIndentationLevel==0);
}
/**
* Sets the behaviour of the formatter regarding the whitespaces
@@ -1754,7 +1735,7 @@ public void setBraceIndentationLevel(int newBraceIndentationLevel) {
* @deprecated backward compatibility with VAJ
*/
public void setClearBlankLines(boolean newClearBlankLines) {
- options.setClearAllBlankLinesMode(newClearBlankLines);
+ options.setClearAllBlankLinesMode(newClearBlankLines);
}
/**
* Sets the number of consecutive spaces used to replace the tab char
@@ -1764,7 +1745,7 @@ public void setClearBlankLines(boolean newClearBlankLines) {
* @deprecated backward compatibility with VAJ
*/
public void setIndentationLength(int newIndentationLength) {
- options.setTabSize(newIndentationLength);
+ options.setTabSize(newIndentationLength);
}
/**
* Sets the initial indentation level
@@ -1773,7 +1754,7 @@ public void setIndentationLength(int newIndentationLength) {
* @deprecated
*/
public void setInitialIndentationLevel(int newIndentationLevel) {
- this.initialIndentationLevel = currentLineIndentationLevel = indentationLevel = newIndentationLevel;
+ this.initialIndentationLevel = currentLineIndentationLevel = indentationLevel = newIndentationLevel;
}
/**
* Sets the behaviour of the scanner.<br>
@@ -1786,7 +1767,7 @@ public void setInitialIndentationLevel(int newIndentationLevel) {
* @deprecated backward compatibility with VAJ
*/
public void setNewlineInCompoundStatement(boolean flag) {
- options.setNewlineInControlStatementMode(flag);
+ options.setNewlineInControlStatementMode(flag);
}
/**
* Set the positions to map. The mapped positions should be retrieved using the
@@ -1795,17 +1776,17 @@ public void setNewlineInCompoundStatement(boolean flag) {
* @param positions int[]
*/
public void setPositionsToMap(int[] positions) {
- positionsToMap = positions;
- lineDelta = 0;
- globalDelta = 0;
- mappedPositions = new int[positions.length];
+ positionsToMap = positions;
+ lineDelta = 0;
+ globalDelta = 0;
+ mappedPositions = new int[positions.length];
}
/**
* Appends a space character to the current line buffer.
*/
private void space() {
- currentLineBuffer.append(' ');
- increaseLineDelta(1);
+ currentLineBuffer.append(' ');
+ increaseLineDelta(1);
}
/**
* Splits <code>stringToSplit</code> on the top level token<br>
@@ -1815,7 +1796,7 @@ private void space() {
* or null if the string cannot be split
*/
public SplitLine split(String stringToSplit) {
- return split(stringToSplit, 0);
+ return split(stringToSplit, 0);
}
/**
* Splits <code>stringToSplit</code> on the top level token<br>
@@ -1825,476 +1806,476 @@ public SplitLine split(String stringToSplit) {
* or null if the string cannot be split
*/
public SplitLine split(String stringToSplit, int offsetInGlobalLine) {
- // local variables
- int currentToken = 0;
- int splitTokenType = 0;
- int splitTokenDepth = Integer.MAX_VALUE;
- int splitTokenPriority = Integer.MAX_VALUE;
-
- int[] substringsStartPositions = new int[10];
- // contains the start position of substrings
- int[] substringsEndPositions = new int[10];
- // contains the start position of substrings
- int substringsCount = 1; // index in the substringsStartPosition array
- int[] splitOperators = new int[10];
- // contains the start position of substrings
- int splitOperatorsCount = 0; // index in the substringsStartPosition array
- int[] openParenthesisPosition = new int[10];
- int openParenthesisPositionCount = 0;
- int position = 0;
- int lastOpenParenthesisPosition = -1;
- // used to remember the position of the 1st open parenthesis
- // needed for a pattern like: A.B(C); we want formatted like A.B( split C);
- // setup the scanner with a new source
- int lastCommentStartPosition = -1;
- // to remember the start position of the last comment
- int firstTokenOnLine = -1;
- // to remember the first token of the line
- int previousToken = -1;
- // to remember the previous token.
- splitScanner.setSourceBuffer(stringToSplit.toCharArray());
-
- try {
- // start the loop
- while (true) {
- // takes the next token
- try {
- if (currentToken != Scanner.TokenNameWHITESPACE)
- previousToken = currentToken;
- currentToken = splitScanner.getNextToken();
- } catch (InvalidInputException e) {
- if (!handleInvalidToken(e))
- throw e;
- currentToken = 0; // this value is not modify when an exception is raised.
- }
- if (currentToken == TokenNameEOF)
- break;
-
- if (firstTokenOnLine == -1){
- firstTokenOnLine = currentToken;
- }
-
-
- switch (currentToken) {
- case TokenNameRBRACE:
- case TokenNameRPAREN :
- if (openParenthesisPositionCount > 0) {
- if (openParenthesisPositionCount == 1 && lastOpenParenthesisPosition < openParenthesisPosition[0]) {
- lastOpenParenthesisPosition = openParenthesisPosition[0];
- } else
- if ((splitTokenDepth == Integer.MAX_VALUE)
- || (splitTokenDepth > openParenthesisPositionCount
- && openParenthesisPositionCount == 1)) {
- splitTokenType = 0;
- splitTokenDepth = openParenthesisPositionCount;
- splitTokenPriority = Integer.MAX_VALUE;
- substringsStartPositions[0] = 0;
- // better token means the whole line until now is the first substring
- substringsCount = 1; // resets the count of substrings
-
- substringsEndPositions[0] = openParenthesisPosition[0];
- // substring ends on operator start
- position = openParenthesisPosition[0];
- // the string mustn't be cut before the closing parenthesis but after the opening one.
- splitOperatorsCount = 1; // resets the count of split operators
- splitOperators[0] = 0;
- }
- openParenthesisPositionCount--;
- }
- break;
- case TokenNameLBRACE:
- case TokenNameLPAREN :
- if (openParenthesisPositionCount == openParenthesisPosition.length) {
- System.arraycopy(
- openParenthesisPosition,
- 0,
- (openParenthesisPosition = new int[openParenthesisPositionCount * 2]),
- 0,
- openParenthesisPositionCount);
- }
- openParenthesisPosition[openParenthesisPositionCount++] = splitScanner.currentPosition;
- if (currentToken == TokenNameLPAREN && previousToken == TokenNameRPAREN){
- openParenthesisPosition[openParenthesisPositionCount - 1] = splitScanner.startPosition;
- }
- break;
- case TokenNameSEMICOLON : // ;
- case TokenNameCOMMA : // ,
- case TokenNameEQUAL : // =
- if (openParenthesisPositionCount < splitTokenDepth
- || (openParenthesisPositionCount == splitTokenDepth
- && splitTokenPriority > getTokenPriority(currentToken))) {
- // the current token is better than the one we currently have
- // (in level or in priority if same level)
- // reset the substringsCount
- splitTokenDepth = openParenthesisPositionCount;
- splitTokenType = currentToken;
- splitTokenPriority = getTokenPriority(currentToken);
- substringsStartPositions[0] = 0;
- // better token means the whole line until now is the first substring
-
- if (separateFirstArgumentOn(firstTokenOnLine)
- && openParenthesisPositionCount > 0) {
- substringsCount = 2; // resets the count of substrings
-
- substringsEndPositions[0] = openParenthesisPosition[splitTokenDepth - 1];
- substringsStartPositions[1] = openParenthesisPosition[splitTokenDepth - 1];
- substringsEndPositions[1] = splitScanner.startPosition;
- splitOperatorsCount = 2; // resets the count of split operators
- splitOperators[0] = 0;
- splitOperators[1] = currentToken;
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- } else {
- substringsCount = 1; // resets the count of substrings
-
- substringsEndPositions[0] = splitScanner.startPosition;
- // substring ends on operator start
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- splitOperatorsCount = 1; // resets the count of split operators
- splitOperators[0] = currentToken;
- }
- } else {
- if ((openParenthesisPositionCount == splitTokenDepth
- && splitTokenPriority == getTokenPriority(currentToken))
- && splitTokenType!=TokenNameEQUAL && currentToken != TokenNameEQUAL) {
- // fix for 1FG0BCN: LFCOM:WIN98 - Missing one indentation after split
- // take only the 1st = into account.
- // if another token with the same priority is found,
- // push the start position of the substring and
- // push the token into the stack.
- // create a new array object if the current one is full.
- if (substringsCount == substringsStartPositions.length) {
- System.arraycopy(
- substringsStartPositions,
- 0,
- (substringsStartPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- System.arraycopy(
- substringsEndPositions,
- 0,
- (substringsEndPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- }
- if (splitOperatorsCount == splitOperators.length) {
- System.arraycopy(
- splitOperators,
- 0,
- (splitOperators = new int[splitOperatorsCount * 2]),
- 0,
- splitOperatorsCount);
- }
- substringsStartPositions[substringsCount] = position;
- substringsEndPositions[substringsCount++] = splitScanner.startPosition;
- // substring ends on operator start
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- splitOperators[splitOperatorsCount++] = currentToken;
- }
- }
- break;
-
- case TokenNameCOLON : // : (15.24)
- // see 1FK7C5R, we only split on a colon, when it is associated with a question-mark.
- // indeed it might appear also behind a case statement, and we do not to break at this point.
- if ((splitOperatorsCount == 0) || splitOperators[splitOperatorsCount-1] != TokenNameQUESTION){
- break;
- }
- case TokenNameextends :
- case TokenNameimplements :
- case TokenNamethrows :
-
- case TokenNameDOT : // .
- case TokenNameMULTIPLY : // * (15.16.1)
- case TokenNameDIVIDE : // / (15.16.2)
- case TokenNameREMAINDER : // % (15.16.3)
- case TokenNamePLUS : // + (15.17, 15.17.2)
- case TokenNameMINUS : // - (15.17.2)
- case TokenNameLEFT_SHIFT : // << (15.18)
- case TokenNameRIGHT_SHIFT : // >> (15.18)
- case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
- case TokenNameLESS : // < (15.19.1)
- case TokenNameLESS_EQUAL : // <= (15.19.1)
- case TokenNameGREATER : // > (15.19.1)
- case TokenNameGREATER_EQUAL : // >= (15.19.1)
- case TokenNameinstanceof : // instanceof
- case TokenNameEQUAL_EQUAL : // == (15.20, 15.20.1, 15.20.2, 15.20.3)
- case TokenNameNOT_EQUAL : // != (15.20, 15.20.1, 15.20.2, 15.20.3)
- case TokenNameAND : // & (15.21, 15.21.1, 15.21.2)
- case TokenNameOR : // | (15.21, 15.21.1, 15.21.2)
- case TokenNameXOR : // ^ (15.21, 15.21.1, 15.21.2)
- case TokenNameAND_AND : // && (15.22)
- case TokenNameOR_OR : // || (15.23)
- case TokenNameQUESTION : // ? (15.24)
- case TokenNameMULTIPLY_EQUAL : // *= (15.25.2)
- case TokenNameDIVIDE_EQUAL : // /= (15.25.2)
- case TokenNameREMAINDER_EQUAL : // %= (15.25.2)
- case TokenNamePLUS_EQUAL : // += (15.25.2)
- case TokenNameMINUS_EQUAL : // -= (15.25.2)
- case TokenNameLEFT_SHIFT_EQUAL : // <<= (15.25.2)
- case TokenNameRIGHT_SHIFT_EQUAL : // >>= (15.25.2)
- case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
- case TokenNameAND_EQUAL : // &= (15.25.2)
- case TokenNameXOR_EQUAL : // ^= (15.25.2)
- case TokenNameOR_EQUAL : // |= (15.25.2)
-
- if ((openParenthesisPositionCount < splitTokenDepth
- || (openParenthesisPositionCount == splitTokenDepth
- && splitTokenPriority > getTokenPriority(currentToken)))
- &&
- !((currentToken == TokenNamePLUS || currentToken == TokenNameMINUS)
- && (previousToken == TokenNameLBRACE || previousToken == TokenNameLBRACKET || splitScanner.startPosition == 0))){
- // the current token is better than the one we currently have
- // (in level or in priority if same level)
- // reset the substringsCount
- splitTokenDepth = openParenthesisPositionCount;
- splitTokenType = currentToken;
- splitTokenPriority = getTokenPriority(currentToken);
- substringsStartPositions[0] = 0;
- // better token means the whole line until now is the first substring
-
- if (separateFirstArgumentOn(firstTokenOnLine)
- && openParenthesisPositionCount > 0) {
- substringsCount = 2; // resets the count of substrings
-
- substringsEndPositions[0] = openParenthesisPosition[splitTokenDepth - 1];
- substringsStartPositions[1] = openParenthesisPosition[splitTokenDepth - 1];
- substringsEndPositions[1] = splitScanner.startPosition;
- splitOperatorsCount = 3; // resets the count of split operators
- splitOperators[0] = 0;
- splitOperators[1] = 0;
- splitOperators[2] = currentToken;
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- } else {
- substringsCount = 1; // resets the count of substrings
-
- substringsEndPositions[0] = splitScanner.startPosition;
- // substring ends on operator start
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- splitOperatorsCount = 2; // resets the count of split operators
- splitOperators[0] = 0;
- // nothing for first operand since operator will be inserted in front of the second operand
- splitOperators[1] = currentToken;
-
- }
- } else {
- if (openParenthesisPositionCount == splitTokenDepth
- && splitTokenPriority == getTokenPriority(currentToken)) {
- // if another token with the same priority is found,
- // push the start position of the substring and
- // push the token into the stack.
- // create a new array object if the current one is full.
- if (substringsCount == substringsStartPositions.length) {
- System.arraycopy(
- substringsStartPositions,
- 0,
- (substringsStartPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- System.arraycopy(
- substringsEndPositions,
- 0,
- (substringsEndPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- }
- if (splitOperatorsCount == splitOperators.length) {
- System.arraycopy(
- splitOperators,
- 0,
- (splitOperators = new int[splitOperatorsCount * 2]),
- 0,
- splitOperatorsCount);
- }
- substringsStartPositions[substringsCount] = position;
- substringsEndPositions[substringsCount++] = splitScanner.startPosition;
- // substring ends on operator start
- position = splitScanner.currentPosition;
- // next substring will start from operator end
- splitOperators[splitOperatorsCount++] = currentToken;
- }
- }
- default :
- break;
- }
- if (isComment(currentToken)) {
- lastCommentStartPosition = splitScanner.startPosition;
- } else {
- lastCommentStartPosition = -1;
- }
- }
- } catch (InvalidInputException e) {
- return null;
- }
- // if the string cannot be split, return null.
- if (splitOperatorsCount == 0)
- return null;
-
- // ## SPECIAL CASES BEGIN
- if (((splitOperatorsCount == 2 && splitOperators[1] == TokenNameDOT && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1)
- || (splitOperatorsCount > 2 && splitOperators[1] == TokenNameDOT && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1 && lastOpenParenthesisPosition <= options.maxLineLength)
- || (separateFirstArgumentOn(firstTokenOnLine) && splitTokenDepth > 0 && lastOpenParenthesisPosition > -1))
- && (lastOpenParenthesisPosition<splitScanner.source.length && splitScanner.source[lastOpenParenthesisPosition]!=')')){
- // fix for 1FH4J2H: LFCOM:WINNT - Formatter - Empty parenthesis should not be broken on two lines
- // only one split on a top level .
- // or more than one split on . and substring before open parenthesis fits one line.
- // or split inside parenthesis and first token is not a for/while/if
- SplitLine sl = split(stringToSplit.substring(lastOpenParenthesisPosition), lastOpenParenthesisPosition);
- if (sl == null || sl.operators[0] != TokenNameCOMMA) {
- // trim() is used to remove the extra blanks at the end of the substring. See PR 1FGYPI1
- return new SplitLine(
- new int[] {0, 0},
- new String[] {
- stringToSplit.substring(0, lastOpenParenthesisPosition).trim(),
- stringToSplit.substring(lastOpenParenthesisPosition)},
- new int[] {offsetInGlobalLine, lastOpenParenthesisPosition + offsetInGlobalLine});
- } else {
-
- // right substring can be split and is split on comma
- // copy substrings and operators
- // except if the 1st string is empty.
-
- int startIndex = (sl.substrings[0].length()==0)?1:0;
-
- int subStringsLength = sl.substrings.length + 1 - startIndex;
- String[] result = new String[subStringsLength];
- int[] startIndexes = new int[subStringsLength];
- int operatorsLength = sl.operators.length + 1 - startIndex;
- int[] operators = new int[operatorsLength];
-
- result[0] = stringToSplit.substring(0, lastOpenParenthesisPosition);
- operators[0] = 0;
-
- System.arraycopy(sl.startSubstringsIndexes, startIndex, startIndexes, 1, subStringsLength - 1);
- for (int i = subStringsLength - 1; i >= 0; i--) {
- startIndexes[i] += offsetInGlobalLine;
- }
- System.arraycopy(sl.substrings, startIndex, result, 1, subStringsLength - 1);
- System.arraycopy(sl.operators, startIndex, operators, 1, operatorsLength - 1);
-
- return new SplitLine(operators, result, startIndexes);
- }
- }
-
- // if the last token is a comment and the substring before the comment fits on a line,
- // split before the comment and return the result.
- if (lastCommentStartPosition > -1
- && lastCommentStartPosition < options.maxLineLength
- && splitTokenPriority > 50) {
- int end = lastCommentStartPosition;
- int start = lastCommentStartPosition;
- if (stringToSplit.charAt(end - 1) == ' ') {
- end--;
- }
- if (start != end && stringToSplit.charAt(start) == ' ') {
- start++;
- }
- return new SplitLine(
- new int[] {0, 0},
- new String[] {
- stringToSplit.substring(0, end),
- stringToSplit.substring(start)},
- new int[] {0, start});
- }
-
- if (position != stringToSplit.length()) {
-
- if (substringsCount == substringsStartPositions.length) {
- System.arraycopy(
- substringsStartPositions,
- 0,
- (substringsStartPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- System.arraycopy(
- substringsEndPositions,
- 0,
- (substringsEndPositions = new int[substringsCount * 2]),
- 0,
- substringsCount);
- }
- // avoid empty extra substring, e.g. line terminated with a semi-colon
- substringsStartPositions[substringsCount] = position;
- substringsEndPositions[substringsCount++] = stringToSplit.length();
- }
-
- if (splitOperatorsCount == splitOperators.length) {
- System.arraycopy(
- splitOperators,
- 0,
- (splitOperators = new int[splitOperatorsCount * 2]),
- 0,
- splitOperatorsCount);
- }
-
- splitOperators[splitOperatorsCount] = 0;
-
- // the last element of the stack is the position of the end of StringToSPlit
- // +1 because the substring method excludes the last character
- String[] result = new String[substringsCount];
- for (int i = 0; i < substringsCount; i++) {
- int start = substringsStartPositions[i];
- int end = substringsEndPositions[i];
- if (stringToSplit.charAt(start) == ' ') {
- start++;
- substringsStartPositions[i]++;
- }
- if (end != start && stringToSplit.charAt(end - 1) == ' ') {
- end--;
- }
-
- result[i] = stringToSplit.substring(start, end);
- substringsStartPositions[i] += offsetInGlobalLine;
- }
- if (splitOperatorsCount > substringsCount) {
- System.arraycopy(substringsStartPositions, 0, (substringsStartPositions = new int[splitOperatorsCount]), 0, substringsCount);
- System.arraycopy(substringsEndPositions, 0, (substringsEndPositions = new int[splitOperatorsCount]), 0, substringsCount);
- for (int i = substringsCount; i < splitOperatorsCount; i++) {
- substringsStartPositions[i] = position;
- substringsEndPositions[i] = position;
- }
- System.arraycopy(splitOperators, 0, (splitOperators = new int[splitOperatorsCount]), 0, splitOperatorsCount);
- } else {
- System.arraycopy(substringsStartPositions, 0, (substringsStartPositions = new int[substringsCount]), 0, substringsCount);
- System.arraycopy(substringsEndPositions, 0, (substringsEndPositions = new int[substringsCount]), 0, substringsCount);
- System.arraycopy(splitOperators, 0, (splitOperators = new int[substringsCount]), 0, substringsCount);
- }
-
- SplitLine splitLine = new SplitLine(splitOperators, result, substringsStartPositions);
- return splitLine;
+ // local variables
+ int currentToken = 0;
+ int splitTokenType = 0;
+ int splitTokenDepth = Integer.MAX_VALUE;
+ int splitTokenPriority = Integer.MAX_VALUE;
+
+ int[] substringsStartPositions = new int[10];
+ // contains the start position of substrings
+ int[] substringsEndPositions = new int[10];
+ // contains the start position of substrings
+ int substringsCount = 1; // index in the substringsStartPosition array
+ int[] splitOperators = new int[10];
+ // contains the start position of substrings
+ int splitOperatorsCount = 0; // index in the substringsStartPosition array
+ int[] openParenthesisPosition = new int[10];
+ int openParenthesisPositionCount = 0;
+ int position = 0;
+ int lastOpenParenthesisPosition = -1;
+ // used to remember the position of the 1st open parenthesis
+ // needed for a pattern like: A.B(C); we want formatted like A.B( split C);
+ // setup the scanner with a new source
+ int lastCommentStartPosition = -1;
+ // to remember the start position of the last comment
+ int firstTokenOnLine = -1;
+ // to remember the first token of the line
+ int previousToken = -1;
+ // to remember the previous token.
+ splitScanner.setSourceBuffer(stringToSplit.toCharArray());
+
+ try {
+ // start the loop
+ while (true) {
+ // takes the next token
+ try {
+ if (currentToken != Scanner.TokenNameWHITESPACE)
+ previousToken = currentToken;
+ currentToken = splitScanner.getNextToken();
+ } catch (InvalidInputException e) {
+ if (!handleInvalidToken(e))
+ throw e;
+ currentToken = 0; // this value is not modify when an exception is raised.
+ }
+ if (currentToken == TokenNameEOF)
+ break;
+
+ if (firstTokenOnLine == -1){
+ firstTokenOnLine = currentToken;
+ }
+
+
+ switch (currentToken) {
+ case TokenNameRBRACE:
+ case TokenNameRPAREN :
+ if (openParenthesisPositionCount > 0) {
+ if (openParenthesisPositionCount == 1 && lastOpenParenthesisPosition < openParenthesisPosition[0]) {
+ lastOpenParenthesisPosition = openParenthesisPosition[0];
+ } else
+ if ((splitTokenDepth == Integer.MAX_VALUE)
+ || (splitTokenDepth > openParenthesisPositionCount
+ && openParenthesisPositionCount == 1)) {
+ splitTokenType = 0;
+ splitTokenDepth = openParenthesisPositionCount;
+ splitTokenPriority = Integer.MAX_VALUE;
+ substringsStartPositions[0] = 0;
+ // better token means the whole line until now is the first substring
+ substringsCount = 1; // resets the count of substrings
+
+ substringsEndPositions[0] = openParenthesisPosition[0];
+ // substring ends on operator start
+ position = openParenthesisPosition[0];
+ // the string mustn't be cut before the closing parenthesis but after the opening one.
+ splitOperatorsCount = 1; // resets the count of split operators
+ splitOperators[0] = 0;
+ }
+ openParenthesisPositionCount--;
+ }
+ break;
+ case TokenNameLBRACE:
+ case TokenNameLPAREN :
+ if (openParenthesisPositionCount == openParenthesisPosition.length) {
+ System.arraycopy(
+ openParenthesisPosition,
+ 0,
+ (openParenthesisPosition = new int[openParenthesisPositionCount * 2]),
+ 0,
+ openParenthesisPositionCount);
+ }
+ openParenthesisPosition[openParenthesisPositionCount++] = splitScanner.currentPosition;
+ if (currentToken == TokenNameLPAREN && previousToken == TokenNameRPAREN){
+ openParenthesisPosition[openParenthesisPositionCount - 1] = splitScanner.startPosition;
+ }
+ break;
+ case TokenNameSEMICOLON : // ;
+ case TokenNameCOMMA : // ,
+ case TokenNameEQUAL : // =
+ if (openParenthesisPositionCount < splitTokenDepth
+ || (openParenthesisPositionCount == splitTokenDepth
+ && splitTokenPriority > getTokenPriority(currentToken))) {
+ // the current token is better than the one we currently have
+ // (in level or in priority if same level)
+ // reset the substringsCount
+ splitTokenDepth = openParenthesisPositionCount;
+ splitTokenType = currentToken;
+ splitTokenPriority = getTokenPriority(currentToken);
+ substringsStartPositions[0] = 0;
+ // better token means the whole line until now is the first substring
+
+ if (separateFirstArgumentOn(firstTokenOnLine)
+ && openParenthesisPositionCount > 0) {
+ substringsCount = 2; // resets the count of substrings
+
+ substringsEndPositions[0] = openParenthesisPosition[splitTokenDepth - 1];
+ substringsStartPositions[1] = openParenthesisPosition[splitTokenDepth - 1];
+ substringsEndPositions[1] = splitScanner.startPosition;
+ splitOperatorsCount = 2; // resets the count of split operators
+ splitOperators[0] = 0;
+ splitOperators[1] = currentToken;
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ } else {
+ substringsCount = 1; // resets the count of substrings
+
+ substringsEndPositions[0] = splitScanner.startPosition;
+ // substring ends on operator start
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ splitOperatorsCount = 1; // resets the count of split operators
+ splitOperators[0] = currentToken;
+ }
+ } else {
+ if ((openParenthesisPositionCount == splitTokenDepth
+ && splitTokenPriority == getTokenPriority(currentToken))
+ && splitTokenType!=TokenNameEQUAL && currentToken != TokenNameEQUAL) {
+ // fix for 1FG0BCN: LFCOM:WIN98 - Missing one indentation after split
+ // take only the 1st = into account.
+ // if another token with the same priority is found,
+ // push the start position of the substring and
+ // push the token into the stack.
+ // create a new array object if the current one is full.
+ if (substringsCount == substringsStartPositions.length) {
+ System.arraycopy(
+ substringsStartPositions,
+ 0,
+ (substringsStartPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ System.arraycopy(
+ substringsEndPositions,
+ 0,
+ (substringsEndPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ }
+ if (splitOperatorsCount == splitOperators.length) {
+ System.arraycopy(
+ splitOperators,
+ 0,
+ (splitOperators = new int[splitOperatorsCount * 2]),
+ 0,
+ splitOperatorsCount);
+ }
+ substringsStartPositions[substringsCount] = position;
+ substringsEndPositions[substringsCount++] = splitScanner.startPosition;
+ // substring ends on operator start
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ splitOperators[splitOperatorsCount++] = currentToken;
+ }
+ }
+ break;
+
+ case TokenNameCOLON : // : (15.24)
+ // see 1FK7C5R, we only split on a colon, when it is associated with a question-mark.
+ // indeed it might appear also behind a case statement, and we do not to break at this point.
+ if ((splitOperatorsCount == 0) || splitOperators[splitOperatorsCount-1] != TokenNameQUESTION){
+ break;
+ }
+ case TokenNameextends :
+ case TokenNameimplements :
+ case TokenNamethrows :
+
+ case TokenNameDOT : // .
+ case TokenNameMULTIPLY : // * (15.16.1)
+ case TokenNameDIVIDE : // / (15.16.2)
+ case TokenNameREMAINDER : // % (15.16.3)
+ case TokenNamePLUS : // + (15.17, 15.17.2)
+ case TokenNameMINUS : // - (15.17.2)
+ case TokenNameLEFT_SHIFT : // << (15.18)
+ case TokenNameRIGHT_SHIFT : // >> (15.18)
+ case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
+ case TokenNameLESS : // < (15.19.1)
+ case TokenNameLESS_EQUAL : // <= (15.19.1)
+ case TokenNameGREATER : // > (15.19.1)
+ case TokenNameGREATER_EQUAL : // >= (15.19.1)
+ case TokenNameinstanceof : // instanceof
+ case TokenNameEQUAL_EQUAL : // == (15.20, 15.20.1, 15.20.2, 15.20.3)
+ case TokenNameNOT_EQUAL : // != (15.20, 15.20.1, 15.20.2, 15.20.3)
+ case TokenNameAND : // & (15.21, 15.21.1, 15.21.2)
+ case TokenNameOR : // | (15.21, 15.21.1, 15.21.2)
+ case TokenNameXOR : // ^ (15.21, 15.21.1, 15.21.2)
+ case TokenNameAND_AND : // && (15.22)
+ case TokenNameOR_OR : // || (15.23)
+ case TokenNameQUESTION : // ? (15.24)
+ case TokenNameMULTIPLY_EQUAL : // *= (15.25.2)
+ case TokenNameDIVIDE_EQUAL : // /= (15.25.2)
+ case TokenNameREMAINDER_EQUAL : // %= (15.25.2)
+ case TokenNamePLUS_EQUAL : // += (15.25.2)
+ case TokenNameMINUS_EQUAL : // -= (15.25.2)
+ case TokenNameLEFT_SHIFT_EQUAL : // <<= (15.25.2)
+ case TokenNameRIGHT_SHIFT_EQUAL : // >>= (15.25.2)
+ case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
+ case TokenNameAND_EQUAL : // &= (15.25.2)
+ case TokenNameXOR_EQUAL : // ^= (15.25.2)
+ case TokenNameOR_EQUAL : // |= (15.25.2)
+
+ if ((openParenthesisPositionCount < splitTokenDepth
+ || (openParenthesisPositionCount == splitTokenDepth
+ && splitTokenPriority > getTokenPriority(currentToken)))
+ &&
+ !((currentToken == TokenNamePLUS || currentToken == TokenNameMINUS)
+ && (previousToken == TokenNameLBRACE || previousToken == TokenNameLBRACKET || splitScanner.startPosition == 0))){
+ // the current token is better than the one we currently have
+ // (in level or in priority if same level)
+ // reset the substringsCount
+ splitTokenDepth = openParenthesisPositionCount;
+ splitTokenType = currentToken;
+ splitTokenPriority = getTokenPriority(currentToken);
+ substringsStartPositions[0] = 0;
+ // better token means the whole line until now is the first substring
+
+ if (separateFirstArgumentOn(firstTokenOnLine)
+ && openParenthesisPositionCount > 0) {
+ substringsCount = 2; // resets the count of substrings
+
+ substringsEndPositions[0] = openParenthesisPosition[splitTokenDepth - 1];
+ substringsStartPositions[1] = openParenthesisPosition[splitTokenDepth - 1];
+ substringsEndPositions[1] = splitScanner.startPosition;
+ splitOperatorsCount = 3; // resets the count of split operators
+ splitOperators[0] = 0;
+ splitOperators[1] = 0;
+ splitOperators[2] = currentToken;
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ } else {
+ substringsCount = 1; // resets the count of substrings
+
+ substringsEndPositions[0] = splitScanner.startPosition;
+ // substring ends on operator start
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ splitOperatorsCount = 2; // resets the count of split operators
+ splitOperators[0] = 0;
+ // nothing for first operand since operator will be inserted in front of the second operand
+ splitOperators[1] = currentToken;
+
+ }
+ } else {
+ if (openParenthesisPositionCount == splitTokenDepth
+ && splitTokenPriority == getTokenPriority(currentToken)) {
+ // if another token with the same priority is found,
+ // push the start position of the substring and
+ // push the token into the stack.
+ // create a new array object if the current one is full.
+ if (substringsCount == substringsStartPositions.length) {
+ System.arraycopy(
+ substringsStartPositions,
+ 0,
+ (substringsStartPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ System.arraycopy(
+ substringsEndPositions,
+ 0,
+ (substringsEndPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ }
+ if (splitOperatorsCount == splitOperators.length) {
+ System.arraycopy(
+ splitOperators,
+ 0,
+ (splitOperators = new int[splitOperatorsCount * 2]),
+ 0,
+ splitOperatorsCount);
+ }
+ substringsStartPositions[substringsCount] = position;
+ substringsEndPositions[substringsCount++] = splitScanner.startPosition;
+ // substring ends on operator start
+ position = splitScanner.currentPosition;
+ // next substring will start from operator end
+ splitOperators[splitOperatorsCount++] = currentToken;
+ }
+ }
+ default :
+ break;
+ }
+ if (isComment(currentToken)) {
+ lastCommentStartPosition = splitScanner.startPosition;
+ } else {
+ lastCommentStartPosition = -1;
+ }
+ }
+ } catch (InvalidInputException e) {
+ return null;
+ }
+ // if the string cannot be split, return null.
+ if (splitOperatorsCount == 0)
+ return null;
+
+ // ## SPECIAL CASES BEGIN
+ if (((splitOperatorsCount == 2 && splitOperators[1] == TokenNameDOT && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1)
+ || (splitOperatorsCount > 2 && splitOperators[1] == TokenNameDOT && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1 && lastOpenParenthesisPosition <= options.maxLineLength)
+ || (separateFirstArgumentOn(firstTokenOnLine) && splitTokenDepth > 0 && lastOpenParenthesisPosition > -1))
+ && (lastOpenParenthesisPosition<splitScanner.source.length && splitScanner.source[lastOpenParenthesisPosition]!=')')){
+ // fix for 1FH4J2H: LFCOM:WINNT - Formatter - Empty parenthesis should not be broken on two lines
+ // only one split on a top level .
+ // or more than one split on . and substring before open parenthesis fits one line.
+ // or split inside parenthesis and first token is not a for/while/if
+ SplitLine sl = split(stringToSplit.substring(lastOpenParenthesisPosition), lastOpenParenthesisPosition);
+ if (sl == null || sl.operators[0] != TokenNameCOMMA) {
+ // trim() is used to remove the extra blanks at the end of the substring. See PR 1FGYPI1
+ return new SplitLine(
+ new int[] {0, 0},
+ new String[] {
+ stringToSplit.substring(0, lastOpenParenthesisPosition).trim(),
+ stringToSplit.substring(lastOpenParenthesisPosition)},
+ new int[] {offsetInGlobalLine, lastOpenParenthesisPosition + offsetInGlobalLine});
+ } else {
+
+ // right substring can be split and is split on comma
+ // copy substrings and operators
+ // except if the 1st string is empty.
+
+ int startIndex = (sl.substrings[0].length()==0)?1:0;
+
+ int subStringsLength = sl.substrings.length + 1 - startIndex;
+ String[] result = new String[subStringsLength];
+ int[] startIndexes = new int[subStringsLength];
+ int operatorsLength = sl.operators.length + 1 - startIndex;
+ int[] operators = new int[operatorsLength];
+
+ result[0] = stringToSplit.substring(0, lastOpenParenthesisPosition);
+ operators[0] = 0;
+
+ System.arraycopy(sl.startSubstringsIndexes, startIndex, startIndexes, 1, subStringsLength - 1);
+ for (int i = subStringsLength - 1; i >= 0; i--) {
+ startIndexes[i] += offsetInGlobalLine;
+ }
+ System.arraycopy(sl.substrings, startIndex, result, 1, subStringsLength - 1);
+ System.arraycopy(sl.operators, startIndex, operators, 1, operatorsLength - 1);
+
+ return new SplitLine(operators, result, startIndexes);
+ }
+ }
+
+ // if the last token is a comment and the substring before the comment fits on a line,
+ // split before the comment and return the result.
+ if (lastCommentStartPosition > -1
+ && lastCommentStartPosition < options.maxLineLength
+ && splitTokenPriority > 50) {
+ int end = lastCommentStartPosition;
+ int start = lastCommentStartPosition;
+ if (stringToSplit.charAt(end - 1) == ' ') {
+ end--;
+ }
+ if (start != end && stringToSplit.charAt(start) == ' ') {
+ start++;
+ }
+ return new SplitLine(
+ new int[] {0, 0},
+ new String[] {
+ stringToSplit.substring(0, end),
+ stringToSplit.substring(start)},
+ new int[] {0, start});
+ }
+
+ if (position != stringToSplit.length()) {
+
+ if (substringsCount == substringsStartPositions.length) {
+ System.arraycopy(
+ substringsStartPositions,
+ 0,
+ (substringsStartPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ System.arraycopy(
+ substringsEndPositions,
+ 0,
+ (substringsEndPositions = new int[substringsCount * 2]),
+ 0,
+ substringsCount);
+ }
+ // avoid empty extra substring, e.g. line terminated with a semi-colon
+ substringsStartPositions[substringsCount] = position;
+ substringsEndPositions[substringsCount++] = stringToSplit.length();
+ }
+
+ if (splitOperatorsCount == splitOperators.length) {
+ System.arraycopy(
+ splitOperators,
+ 0,
+ (splitOperators = new int[splitOperatorsCount * 2]),
+ 0,
+ splitOperatorsCount);
+ }
+
+ splitOperators[splitOperatorsCount] = 0;
+
+ // the last element of the stack is the position of the end of StringToSPlit
+ // +1 because the substring method excludes the last character
+ String[] result = new String[substringsCount];
+ for (int i = 0; i < substringsCount; i++) {
+ int start = substringsStartPositions[i];
+ int end = substringsEndPositions[i];
+ if (stringToSplit.charAt(start) == ' ') {
+ start++;
+ substringsStartPositions[i]++;
+ }
+ if (end != start && stringToSplit.charAt(end - 1) == ' ') {
+ end--;
+ }
+
+ result[i] = stringToSplit.substring(start, end);
+ substringsStartPositions[i] += offsetInGlobalLine;
+ }
+ if (splitOperatorsCount > substringsCount) {
+ System.arraycopy(substringsStartPositions, 0, (substringsStartPositions = new int[splitOperatorsCount]), 0, substringsCount);
+ System.arraycopy(substringsEndPositions, 0, (substringsEndPositions = new int[splitOperatorsCount]), 0, substringsCount);
+ for (int i = substringsCount; i < splitOperatorsCount; i++) {
+ substringsStartPositions[i] = position;
+ substringsEndPositions[i] = position;
+ }
+ System.arraycopy(splitOperators, 0, (splitOperators = new int[splitOperatorsCount]), 0, splitOperatorsCount);
+ } else {
+ System.arraycopy(substringsStartPositions, 0, (substringsStartPositions = new int[substringsCount]), 0, substringsCount);
+ System.arraycopy(substringsEndPositions, 0, (substringsEndPositions = new int[substringsCount]), 0, substringsCount);
+ System.arraycopy(splitOperators, 0, (splitOperators = new int[substringsCount]), 0, substringsCount);
+ }
+
+ SplitLine splitLine = new SplitLine(splitOperators, result, substringsStartPositions);
+ return splitLine;
}
private void updateMappedPositions(int startPosition) {
- if (positionsToMap == null) return;
- char[] source = scanner.source;
- int sourceLength = source.length;
- while (indexToMap < positionsToMap.length && positionsToMap[indexToMap] <= startPosition) {
- int posToMap = positionsToMap[indexToMap];
- if (posToMap < 0 || posToMap >= sourceLength){ // protection against out of bounds position
- indexToMap = positionsToMap.length; // no more mapping
- return;
- }
- if (Character.isWhitespace(source[posToMap])) {
- mappedPositions[indexToMap] = startPosition + globalDelta + lineDelta;
- } else {
- mappedPositions[indexToMap] = posToMap + globalDelta + lineDelta;
- }
- indexToMap++;
- }
+ if (positionsToMap == null) return;
+ char[] source = scanner.source;
+ int sourceLength = source.length;
+ while (indexToMap < positionsToMap.length && positionsToMap[indexToMap] <= startPosition) {
+ int posToMap = positionsToMap[indexToMap];
+ if (posToMap < 0 || posToMap >= sourceLength){ // protection against out of bounds position
+ indexToMap = positionsToMap.length; // no more mapping
+ return;
+ }
+ if (Character.isWhitespace(source[posToMap])) {
+ mappedPositions[indexToMap] = startPosition + globalDelta + lineDelta;
+ } else {
+ mappedPositions[indexToMap] = posToMap + globalDelta + lineDelta;
+ }
+ indexToMap++;
+ }
}
private void updateMappedPositionsWhileSplitting(int startPosition, int endPosition) {
- if (mappedPositions == null || mappedPositions.length == indexInMap) return;
-
- while(indexInMap < mappedPositions.length
- && startPosition <= mappedPositions[indexInMap]
- && mappedPositions[indexInMap] < endPosition
- && indexInMap < indexToMap) {
- mappedPositions[indexInMap]+= splitDelta;
- indexInMap++;
- }
+ if (mappedPositions == null || mappedPositions.length == indexInMap) return;
+
+ while(indexInMap < mappedPositions.length
+ && startPosition <= mappedPositions[indexInMap]
+ && mappedPositions[indexInMap] < endPosition
+ && indexInMap < indexToMap) {
+ mappedPositions[indexInMap]+= splitDelta;
+ indexInMap++;
+ }
}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
index 175d967bb6..fd6b7aeebf 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
@@ -8,21 +8,8 @@ import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.formatter.*;
import java.util.*;
-public class FormatterOptions {
+public class FormatterOptions {
- /**
- * Option IDs
- */
- public static final String OPTION_InsertNewlineBeforeOpeningBrace = CodeFormatter.class.getName() + ".newlineOpeningBrace"; //$NON-NLS-1$
- public static final String OPTION_InsertNewlineInControlStatement = CodeFormatter.class.getName() + ".newlineControlStatement"; //$NON-NLS-1$
- public static final String OPTION_InsertNewLineBetweenElseAndIf = CodeFormatter.class.getName() + ".newlineElseIf"; //$NON-NLS-1$
- public static final String OPTION_InsertNewLineInEmptyBlock = CodeFormatter.class.getName() + ".newlineEmptyBlock"; //$NON-NLS-1$
- public static final String OPTION_ClearAllBlankLines = CodeFormatter.class.getName() + ".newlineClearAll"; //$NON-NLS-1$
- public static final String OPTION_SplitLineExceedingLength = CodeFormatter.class.getName() + ".lineSplit"; //$NON-NLS-1$
- public static final String OPTION_CompactAssignment = CodeFormatter.class.getName() + ".compactAssignment"; //$NON-NLS-1$
- public static final String OPTION_TabulationChar = CodeFormatter.class.getName() + ".tabulationChar"; //$NON-NLS-1$
- public static final String OPTION_TabulationSize = CodeFormatter.class.getName() + ".tabulationSize"; //$NON-NLS-1$
-
// by default, do not insert blank line before opening brace
public boolean newLineBeforeOpeningBraceMode = false;
@@ -44,7 +31,7 @@ public class FormatterOptions {
public boolean compactElseIfMode = false; // if true, else and if are kept on the same line.
public boolean newLineInEmptyBlockMode = true; // if false, no new line in {} if it's empty.
- public char[] lineSeparatorSequence = System.getProperty("line.separator").toCharArray(); //$NON-NLS-1$
+ public char[] lineSeparatorSequence = System.getProperty("line.separator"/*nonNLS*/).toCharArray();
/**
* Initializing the formatter options with default settings
*/
@@ -55,8 +42,7 @@ public FormatterOptions(){
*/
public FormatterOptions(ConfigurableOption[] settings){
if (settings == null) return;
-
- // filter options which are related to the formatter component
+ // filter options which are related to the compiler component
String componentName = CodeFormatter.class.getName();
for (int i = 0, max = settings.length; i < max; i++){
if (settings[i].getComponentName().equals(componentName)){
@@ -64,7 +50,26 @@ public FormatterOptions(ConfigurableOption[] settings){
}
}
}
-
+/**
+ * Returns all the options of the Code Formatter to be shown by the UI
+ *
+ * @param locale java.util.Locale
+ * @return com.ibm.compiler.java.ConfigurableOption[]
+ */
+public ConfigurableOption[] getConfigurableOptions(Locale locale) {
+ String componentName = CodeFormatter.class.getName();
+ return new ConfigurableOption[] {
+ new ConfigurableOption(componentName, "newline.openingBrace"/*nonNLS*/, locale, newLineBeforeOpeningBraceMode ? 0 : 1),
+ new ConfigurableOption(componentName, "newline.controlStatement"/*nonNLS*/, locale, newlineInControlStatementMode ? 0 : 1),
+ new ConfigurableOption(componentName, "newline.clearAll"/*nonNLS*/, locale, clearAllBlankLinesMode ? 0 : 1),
+ new ConfigurableOption(componentName, "newline.elseIf"/*nonNLS*/, locale, compactElseIfMode ? 0 : 1),
+ new ConfigurableOption(componentName, "newline.emptyBlock"/*nonNLS*/, locale, newLineInEmptyBlockMode ? 0 : 1),
+ new ConfigurableOption(componentName, "line.split"/*nonNLS*/, locale, maxLineLength),
+ new ConfigurableOption(componentName, "style.compactAssignment"/*nonNLS*/, locale, compactAssignmentMode ? 0 : 1),
+ new ConfigurableOption(componentName, "tabulation.char"/*nonNLS*/, locale, indentWithTab ? 0 : 1),
+ new ConfigurableOption(componentName, "tabulation.size"/*nonNLS*/, locale, tabSize)
+ };
+}
/**
*
* @return int
@@ -155,36 +160,37 @@ public void setNewLineInEmptyBlockMode(boolean flag) {
* @param newValue <CODE>int</CODE>
*/
public void setOption(ConfigurableOption setting) {
-
- String optionID = setting.getID();
-
- if(optionID.equals(OPTION_InsertNewlineBeforeOpeningBrace)){
- setNewLineBeforeOpeningBraceMode(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_InsertNewlineInControlStatement)){
- setNewlineInControlStatementMode(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_ClearAllBlankLines)){
- setClearAllBlankLinesMode(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_InsertNewLineBetweenElseAndIf)){
- setCompactElseIfMode(setting.getValueIndex() == 1);
- }else if(optionID.equals(OPTION_InsertNewLineInEmptyBlock)){
- setNewLineInEmptyBlockMode(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_SplitLineExceedingLength)){
- try {
- setMaxLineLength(Integer.parseInt(setting.getValue()));
- } catch(NumberFormatException e){
- }
- }else if(optionID.equals(OPTION_CompactAssignment)){
- setCompactAssignmentMode(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_TabulationChar)){
- setIndentationUsesTab(setting.getValueIndex() == 0);
- }else if(optionID.equals(OPTION_TabulationSize)){
- try {
- setTabSize(Integer.parseInt(setting.getValue()));
- } catch(NumberFormatException e){
- }
+
+ switch (setting.getID()) {
+ case 1 : // insert blank line before opening brace
+ setNewLineBeforeOpeningBraceMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 2 : // insert blank line behind keywords (ELSE, CATCH, FINALLY,...) in control statements
+ setNewlineInControlStatementMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 3 : // flush all blank lines
+ setClearAllBlankLinesMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 4 : // puts else if on the same line
+ setCompactElseIfMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 5 : // add a new line inside an empty block.
+ setNewLineInEmptyBlockMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 6 : // line splitting will occur when line exceeds this length (0 -> no splitting)
+ setMaxLineLength(setting.getCurrentValueIndex());
+ break;
+ case 7 : // if isTrue, assignments look like x= 12 (not like x = 12);
+ setCompactAssignmentMode(setting.getCurrentValueIndex() == 0);
+ break;
+ case 9 : // should use tab or spaces to indent
+ setIndentationUsesTab(setting.getCurrentValueIndex() == 0);
+ break;
+ case 10 : // amount of spaces for a tabulation
+ setTabSize(setting.getCurrentValueIndex());
+ break;
}
}
-
public void setReuseExistingLayoutMode(boolean flag) {
}
public void setTabSize(int size) {
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
index dfaab42f47..912da60e27 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
@@ -45,151 +45,151 @@ public String toString() {
switch (currentOperator){
case TokenNameextends:
- operatorString="extends"; //$NON-NLS-1$
+ operatorString="extends"/*nonNLS*/;
break;
case TokenNameimplements:
- operatorString="implements"; //$NON-NLS-1$
+ operatorString="implements"/*nonNLS*/;
break;
case TokenNamethrows:
- operatorString="throws"; //$NON-NLS-1$
+ operatorString="throws"/*nonNLS*/;
break;
case TokenNameSEMICOLON : // ;
- operatorString=";"; //$NON-NLS-1$
+ operatorString=";"/*nonNLS*/;
break;
case TokenNameCOMMA : // ,
- operatorString=","; //$NON-NLS-1$
+ operatorString=","/*nonNLS*/;
break;
case TokenNameEQUAL : // =
- operatorString="="; //$NON-NLS-1$
+ operatorString="="/*nonNLS*/;
break;
case TokenNameAND_AND : // && (15.22)
- operatorString="&&"; //$NON-NLS-1$
+ operatorString="&&"/*nonNLS*/;
break;
case TokenNameOR_OR : // || (15.23)
- operatorString="||"; //$NON-NLS-1$
+ operatorString="||"/*nonNLS*/;
break;
case TokenNameQUESTION : // ? (15.24)
- operatorString="?"; //$NON-NLS-1$
+ operatorString="?"/*nonNLS*/;
break;
case TokenNameCOLON : // : (15.24)
- operatorString=":"; //$NON-NLS-1$
+ operatorString=":"/*nonNLS*/;
break;
case TokenNameEQUAL_EQUAL : // == (15.20, 15.20.1, 15.20.2, 15.20.3)
- operatorString="=="; //$NON-NLS-1$
+ operatorString="=="/*nonNLS*/;
break;
case TokenNameNOT_EQUAL : // != (15.20, 15.20.1, 15.20.2, 15.20.3)
- operatorString="!="; //$NON-NLS-1$
+ operatorString="!="/*nonNLS*/;
break;
case TokenNameLESS : // < (15.19.1)
- operatorString="<"; //$NON-NLS-1$
+ operatorString="<"/*nonNLS*/;
break;
case TokenNameLESS_EQUAL : // <= (15.19.1)
- operatorString="<="; //$NON-NLS-1$
+ operatorString="<="/*nonNLS*/;
break;
case TokenNameGREATER : // > (15.19.1)
- operatorString=">"; //$NON-NLS-1$
+ operatorString=">"/*nonNLS*/;
break;
case TokenNameGREATER_EQUAL : // >= (15.19.1)
- operatorString=">="; //$NON-NLS-1$
+ operatorString=">="/*nonNLS*/;
break;
case TokenNameinstanceof : // instanceof
- operatorString="instanceof"; //$NON-NLS-1$
+ operatorString="instanceof"/*nonNLS*/;
break;
case TokenNamePLUS : // + (15.17, 15.17.2)
- operatorString="+"; //$NON-NLS-1$
+ operatorString="+"/*nonNLS*/;
break;
case TokenNameMINUS : // - (15.17.2)
- operatorString="-"; //$NON-NLS-1$
+ operatorString="-"/*nonNLS*/;
break;
case TokenNameMULTIPLY : // * (15.16.1)
- operatorString="*"; //$NON-NLS-1$
+ operatorString="*"/*nonNLS*/;
break;
case TokenNameDIVIDE : // / (15.16.2)
- operatorString="/"; //$NON-NLS-1$
+ operatorString="/"/*nonNLS*/;
break;
case TokenNameREMAINDER : // % (15.16.3)
- operatorString="%"; //$NON-NLS-1$
+ operatorString="%"/*nonNLS*/;
break;
case TokenNameLEFT_SHIFT : // << (15.18)
- operatorString="<<"; //$NON-NLS-1$
+ operatorString="<<"/*nonNLS*/;
break;
case TokenNameRIGHT_SHIFT : // >> (15.18)
- operatorString=">>"; //$NON-NLS-1$
+ operatorString=">>"/*nonNLS*/;
break;
case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
- operatorString=">>>"; //$NON-NLS-1$
+ operatorString=">>>"/*nonNLS*/;
break;
case TokenNameAND : // & (15.21, 15.21.1, 15.21.2)
- operatorString="&"; //$NON-NLS-1$
+ operatorString="&"/*nonNLS*/;
break;
case TokenNameOR : // | (15.21, 15.21.1, 15.21.2)
- operatorString="|"; //$NON-NLS-1$
+ operatorString="|"/*nonNLS*/;
break;
case TokenNameXOR : // ^ (15.21, 15.21.1, 15.21.2)
- operatorString="^"; //$NON-NLS-1$
+ operatorString="^"/*nonNLS*/;
break;
case TokenNameMULTIPLY_EQUAL : // *= (15.25.2)
- operatorString="*="; //$NON-NLS-1$
+ operatorString="*="/*nonNLS*/;
break;
case TokenNameDIVIDE_EQUAL : // /= (15.25.2)
- operatorString="/="; //$NON-NLS-1$
+ operatorString="/="/*nonNLS*/;
break;
case TokenNameREMAINDER_EQUAL : // %= (15.25.2)
- operatorString="%="; //$NON-NLS-1$
+ operatorString="%="/*nonNLS*/;
break;
case TokenNamePLUS_EQUAL : // += (15.25.2)
- operatorString="+="; //$NON-NLS-1$
+ operatorString="+="/*nonNLS*/;
break;
case TokenNameMINUS_EQUAL : // -= (15.25.2)
- operatorString="-="; //$NON-NLS-1$
+ operatorString="-="/*nonNLS*/;
break;
case TokenNameLEFT_SHIFT_EQUAL : // <<= (15.25.2)
- operatorString="<<="; //$NON-NLS-1$
+ operatorString="<<="/*nonNLS*/;
break;
case TokenNameRIGHT_SHIFT_EQUAL : // >>= (15.25.2)
- operatorString=">>="; //$NON-NLS-1$
+ operatorString=">>="/*nonNLS*/;
break;
case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
- operatorString=">>>="; //$NON-NLS-1$
+ operatorString=">>>="/*nonNLS*/;
break;
case TokenNameAND_EQUAL : // &= (15.25.2)
- operatorString="&="; //$NON-NLS-1$
+ operatorString="&="/*nonNLS*/;
break;
case TokenNameXOR_EQUAL : // ^= (15.25.2)
- operatorString="^="; //$NON-NLS-1$
+ operatorString="^="/*nonNLS*/;
break;
case TokenNameOR_EQUAL : // |= (15.25.2)
- operatorString="|="; //$NON-NLS-1$
+ operatorString="|="/*nonNLS*/;
break;
case TokenNameDOT : // .
- operatorString="."; //$NON-NLS-1$
+ operatorString="."/*nonNLS*/;
break;
default:
- operatorString=""; //$NON-NLS-1$
+ operatorString=""/*nonNLS*/;
}
if (placeOperatorAhead){
result.append(operatorString);
@@ -200,6 +200,6 @@ public String toString() {
}
result.append('\n');
}
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties
new file mode 100644
index 0000000000..9a9b3d8f34
--- /dev/null
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties
@@ -0,0 +1,59 @@
+newline.openingBrace.number=1
+newline.openingBrace.category=Newline
+newline.openingBrace.name=I&nsert new line before opening brace
+newline.openingBrace.possibleValues=2|Insert|Do not insert
+newline.openingBrace.description=When Insert, a new line is inserted before an opening brace, otherwise nothing is inserted
+
+newline.controlStatement.number=2
+newline.controlStatement.category=Newline
+newline.controlStatement.name=Insert new &line in control statement
+newline.controlStatement.possibleValues=2|Insert|Do not insert
+newline.controlStatement.description=When Insert, a new line is inserted between } and else, catch, finally
+
+newline.clearAll.number=3
+newline.clearAll.category=Newline
+newline.clearAll.name=Clear all &blank lines
+newline.clearAll.possibleValues=2|Clear|Preserve one
+newline.clearAll.description=When Clear, all blank lines are removed. When Preserve one, only one is kept and all others removed.
+
+newline.elseIf.number=4
+newline.elseIf.category=Newline
+newline.elseIf.name=&Keep else if on the same line
+newline.elseIf.possibleValues=2|Yes|No
+newline.elseIf.description=When Yes, a blank line is inserted between a else and a if when they are contiguous
+
+newline.emptyBlock.number=5
+newline.emptyBlock.category=Newline
+newline.emptyBlock.name=In&sert a new line inside an empty block
+newline.emptyBlock.possibleValues=2|Insert|Do not insert
+newline.emptyBlock.description=When insert, a line break is inserted between contiguous { and }, if } is not followed by a keyword.
+
+line.split.number=6
+line.split.category=Line splitting
+line.split.name=Ma&ximum line length
+line.split.possibleValues=-1
+line.split.description=Enable splitting of long lines (exceeding the configurable length). Length of 0 will disable line splitting
+
+style.compactAssignment.number=7
+style.compactAssignment.category=Style
+style.compactAssignment.name=&Compact assignment
+style.compactAssignment.possibleValues=2|Compact|Normal
+style.compactAssignment.description=Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space is inserted before the assignment operator
+
+style.reuseExistingLayout.number=8
+style.reuseExistingLayout.category=Style
+style.reuseExistingLayout.name=&Reuse existing layout
+style.reuseExistingLayout.possibleValues=2|Reuse|Do not reuse
+style.reuseExistingLayout.description=If the user has formatted his code a certain way, the formatter does not try to reformat it
+
+tabulation.char.number=9
+tabulation.char.category=Style
+tabulation.char.name=Indentation is represented by &tab
+tabulation.char.possibleValues=2|Tab|Spaces
+tabulation.char.description=Either choose to indent with tab characters or spaces
+
+tabulation.size.number=10
+tabulation.size.category=Style
+tabulation.size.name=&Amount of spaces representing a tab
+tabulation.size.possibleValues=-1
+tabulation.size.description=Tabulation size in term of space characters \ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
index 2df2d84d5e..b2a1737ec2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
@@ -169,20 +169,20 @@ private Flags() {}
public static String toString(int flags) {
StringBuffer sb = new StringBuffer();
- if (isPublic(flags)) sb.append("public "); //$NON-NLS-1$
- if (isProtected(flags)) sb.append("protected "); //$NON-NLS-1$
- if (isPrivate(flags)) sb.append("private "); //$NON-NLS-1$
- if (isStatic(flags)) sb.append("static "); //$NON-NLS-1$
- if (isAbstract(flags)) sb.append("abstract "); //$NON-NLS-1$
- if (isFinal(flags)) sb.append("final "); //$NON-NLS-1$
- if (isNative(flags)) sb.append("native "); //$NON-NLS-1$
- if (isSynchronized(flags)) sb.append("synchronized "); //$NON-NLS-1$
- if (isTransient(flags)) sb.append("transient "); //$NON-NLS-1$
- if (isVolatile(flags)) sb.append("volatile "); //$NON-NLS-1$
- if (isStrictfp(flags)) sb.append("strictfp "); //$NON-NLS-1$
+ if (isPublic(flags)) sb.append("public "/*nonNLS*/);
+ if (isProtected(flags)) sb.append("protected "/*nonNLS*/);
+ if (isPrivate(flags)) sb.append("private "/*nonNLS*/);
+ if (isStatic(flags)) sb.append("static "/*nonNLS*/);
+ if (isAbstract(flags)) sb.append("abstract "/*nonNLS*/);
+ if (isFinal(flags)) sb.append("final "/*nonNLS*/);
+ if (isNative(flags)) sb.append("native "/*nonNLS*/);
+ if (isSynchronized(flags)) sb.append("synchronized "/*nonNLS*/);
+ if (isTransient(flags)) sb.append("transient "/*nonNLS*/);
+ if (isVolatile(flags)) sb.append("volatile "/*nonNLS*/);
+ if (isStrictfp(flags)) sb.append("strictfp "/*nonNLS*/);
int len = sb.length();
- if (len == 0) return ""; //$NON-NLS-1$
+ if (len == 0) return ""/*nonNLS*/;
sb.setLength(len-1);
return sb.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
index cbe4641c86..30af205c32 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
@@ -19,7 +19,7 @@ public interface IJavaModelMarker {
* This can be used to recognize those markers in the workspace that flag problems
* detected by the Java tooling during compilation.
*/
- public static final String JAVA_MODEL_PROBLEM_MARKER = JavaCore.PLUGIN_ID + ".problem"; //$NON-NLS-1$
+ public static final String JAVA_MODEL_PROBLEM_MARKER = JavaCore.PLUGIN_ID + ".problem"/*nonNLS*/;
/**
@@ -28,19 +28,19 @@ public interface IJavaModelMarker {
* problems detected by the Java tooling (such as a cycle in the build path, a problem
* detected by the outliner, or a problem detected during a code completion)
*/
- public static final String TRANSIENT_PROBLEM = JavaCore.PLUGIN_ID + ".transient_problem"; //$NON-NLS-1$
+ public static final String TRANSIENT_PROBLEM = JavaCore.PLUGIN_ID + ".transient_problem"/*nonNLS*/;
/**
* Id marker attribute (value <code>"id"</code>).
* Reserved for future use.
*/
- public static final String ID = "id"; //$NON-NLS-1$
+ public static final String ID = "id"/*nonNLS*/;
/**
* Flags marker attribute (value <code>"flags"</code>).
* Reserved for future use.
*/
- public static final String FLAGS = "flags"; //$NON-NLS-1$
+ public static final String FLAGS = "flags"/*nonNLS*/;
/**
* Cycle detected marker attribute (value <code>"cycleDetected"</code>).
@@ -48,11 +48,11 @@ public interface IJavaModelMarker {
* The value of this attribute is the name of the project that caused a
* cycle in the projects classpaths.
*/
- public static final String CYCLE_DETECTED = "cycleDetected"; //$NON-NLS-1$
+ public static final String CYCLE_DETECTED = "cycleDetected"/*nonNLS*/;
/**
* Build path problem marker type (value <code>"org.eclipse.jdt.core.buildpath_problem"</code>).
* This can be used to recognize those markers in the workspace that flag problems
* detected by the Java tooling during classpath setting.
*/
- public static final String BUILDPATH_PROBLEM_MARKER = JavaCore.PLUGIN_ID + ".buildpath_problem"; //$NON-NLS-1$
+ public static final String BUILDPATH_PROBLEM_MARKER = JavaCore.PLUGIN_ID + ".buildpath_problem"/*nonNLS*/;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
index 27dfaa148f..6297996c38 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
@@ -227,13 +227,4 @@ public interface IJavaModelStatusConstants {
* Status constant indicating that a classpath entry was invalid
*/
public static final int INVALID_CLASSPATH = 964;
- /**
- * Status constant indicating that a value is not a possible value
- * for an option.
- */
- public static final int INVALID_OPTION_VALUE = 963;
- /**
- * Status constant indicating that an option is not an existing option.
- */
- public static final int INVALID_OPTION = 962;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
index a63f6098ad..fde463d5a8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
@@ -31,7 +31,7 @@ public interface IPackageFragment extends IParent, IJavaElement, IOpenable, ISou
* string, <code>""</code>).
* </p>
*/
- public static final String DEFAULT_PACKAGE_NAME = ""; //$NON-NLS-1$
+ public static final String DEFAULT_PACKAGE_NAME = ""/*nonNLS*/;
/**
* Returns whether this fragment contains at least one Java resource.
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
index 9de4421155..ed893af0a2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
@@ -40,7 +40,7 @@ public interface IPackageFragmentRoot extends IParent, IJavaElement, IOpenable {
/**
* Empty root path
*/
- String DEFAULT_PACKAGEROOT_PATH = ""; //$NON-NLS-1$
+ String DEFAULT_PACKAGEROOT_PATH = ""/*nonNLS*/;
/**
* Attaches the source archive identified by the given absolute path to this
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
index 00aaca0e36..5026726766 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
@@ -29,7 +29,7 @@ import org.eclipse.core.resources.*;
*/
public final class JavaConventions {
private final static char fgDot= '.';
- private final static String fgJAVA= "JAVA"; //$NON-NLS-1$
+ private final static String fgJAVA= "JAVA"/*nonNLS*/;
/**
* Not instantiable.
*/
@@ -48,8 +48,8 @@ public static boolean isOverlappingRoots(IPath rootPath1, IPath rootPath2) {
}
String extension1 = rootPath1.getFileExtension();
String extension2 = rootPath2.getFileExtension();
- String jarExtension = "JAR"; //$NON-NLS-1$
- String zipExtension = "ZIP"; //$NON-NLS-1$
+ String jarExtension = "JAR"/*nonNLS*/;
+ String zipExtension = "ZIP"/*nonNLS*/;
if (extension1 != null && (extension1.equalsIgnoreCase(jarExtension) || extension1.equalsIgnoreCase(zipExtension))) {
return false;
}
@@ -111,14 +111,14 @@ private static char[] scannedIdentifier(String id) {
*/
public static IStatus validateCompilationUnitName(String name) {
if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"/*nonNLS*/), null);
}
String extension;
String identifier;
int index;
index = name.indexOf('.');
if (index == -1) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"/*nonNLS*/), null);
}
identifier = name.substring(0, index);
extension = name.substring(index + 1);
@@ -127,9 +127,9 @@ public static IStatus validateCompilationUnitName(String name) {
return status;
}
if (!Util.isJavaFileName(name)) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"/*nonNLS*/), null);
}
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK"/*nonNLS*/, null);
}
/**
* Validate the given field name.
@@ -159,9 +159,9 @@ public static IStatus validateFieldName(String name) {
*/
public static IStatus validateIdentifier(String id) {
if (scannedIdentifier(id) != null) {
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK"/*nonNLS*/, null);
} else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", id), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier"/*nonNLS*/, id), null);
}
}
/**
@@ -178,13 +178,13 @@ public static IStatus validateIdentifier(String id) {
*/
public static IStatus validateImportDeclaration(String name) {
if (name == null || name.length() == 0) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.nullImport"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.nullImport"/*nonNLS*/), null);
}
if (name.charAt(name.length() - 1) == '*') {
if (name.charAt(name.length() - 2) == '.') {
return validatePackageName(name.substring(0, name.length() - 2));
} else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.unqualifiedImport"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.unqualifiedImport"/*nonNLS*/), null);
}
}
return validatePackageName(name);
@@ -204,11 +204,11 @@ public static IStatus validateImportDeclaration(String name) {
*/
public static IStatus validateJavaTypeName(String name) {
if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nullName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nullName"/*nonNLS*/), null);
}
String trimmed = name.trim();
if (!name.equals(trimmed)) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nameWithBlanks"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nameWithBlanks"/*nonNLS*/), null);
}
int index = name.lastIndexOf('.');
char[] scannedID;
@@ -228,14 +228,14 @@ public static IStatus validateJavaTypeName(String name) {
if (scannedID != null) {
if (CharOperation.contains('$', scannedID)) {
- return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.dollarName"), null); //$NON-NLS-1$
+ return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.dollarName"/*nonNLS*/), null);
}
if ((scannedID.length > 0 && Character.isLowerCase(scannedID[0]))) {
- return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.lowercaseName"), null); //$NON-NLS-1$
+ return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.lowercaseName"/*nonNLS*/), null);
}
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK"/*nonNLS*/, null);
} else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.invalidName", name), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.invalidName"/*nonNLS*/, name), null);
}
}
/**
@@ -266,22 +266,22 @@ public static IStatus validateMethodName(String name) {
*/
public static IStatus validatePackageName(String name) {
if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nullName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nullName"/*nonNLS*/), null);
}
int length;
if ((length = name.length()) == 0) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.emptyName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.emptyName"/*nonNLS*/), null);
}
if (name.charAt(0) == fgDot || name.charAt(length-1) == fgDot) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.dotName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.dotName"/*nonNLS*/), null);
}
if (Character.isWhitespace(name.charAt(0)) || Character.isWhitespace(name.charAt(name.length() - 1))) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nameWithBlanks"), null);; //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nameWithBlanks"/*nonNLS*/), null);;
}
int dot = 0;
while (dot != -1 && dot < length-1) {
if ((dot = name.indexOf(fgDot, dot+1)) != -1 && dot < length-1 && name.charAt(dot+1) == fgDot) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.consecutiveDotsName"), null); //$NON-NLS-1$
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.consecutiveDotsName"/*nonNLS*/), null);
}
}
StringTokenizer st = new StringTokenizer(name, new String(new char[] {fgDot}));
@@ -293,178 +293,7 @@ public static IStatus validatePackageName(String name) {
return status;
}
}
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
+ return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK"/*nonNLS*/, null);
}
-/**
- * Validate the given classpath and output location.
- * - Source folders cannot be nested inside the binary output, and reciprocally. They can coincidate.
- * - Source folders cannot be nested in each other.
- * - Output location must be nested inside project.
-
- * @param classpath a given classpath
- * @param outputLocation a given output location
- * @return a status object with code <code>IStatus.OK</code> if
- * the given classpath and output location are compatible, otherwise a status
- * object indicating what is wrong with the classpath or output location
- */
-public static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] classpath, IPath outputLocation) {
-
- IProject project = javaProject.getProject();
- IPath projectPath= project.getFullPath();
-
- /* validate output location */
- if (outputLocation == null) {
- return new JavaModelStatus(IJavaModelStatusConstants.NULL_PATH);
- }
- if (outputLocation.isAbsolute()) {
- if (!projectPath.isPrefixOf(outputLocation)) {
- return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, javaProject, outputLocation.toString());
- }
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, outputLocation);
- }
-
-
-
- // check if any source entries coincidates with binary output - in which case nesting inside output is legal
- boolean allowNestingInOutput = false;
- boolean hasSource = false;
- for (int i = 0 ; i < classpath.length; i++) {
- if (classpath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) hasSource = true;
- if (classpath[i].getPath().equals(outputLocation)){
- allowNestingInOutput = true;
- break;
- }
- }
- if (!hasSource) allowNestingInOutput = true; // if no source, then allowed
-
- // check all entries
- for (int i = 0 ; i < classpath.length; i++) {
- IClasspathEntry entry = classpath[i];
- IPath entryPath = entry.getPath();
-
- // no further check if entry coincidates with project or output location
- if (entryPath.equals(projectPath)) continue;
- if (entryPath.equals(outputLocation)) continue;
-
- // prevent nesting source entries in each other
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
- for (int j = 0; j < classpath.length; j++){
- IClasspathEntry otherEntry = classpath[j];
- if (entry != otherEntry && otherEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
- if (entryPath.isPrefixOf(otherEntry.getPath())){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestSourceFolderInSource",entryPath.toString(), otherEntry.getPath().toString())); //$NON-NLS-1$
- }
- }
- }
- }
- // prevent nesting output location inside entry
- if (entryPath.isPrefixOf(outputLocation)) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestSourceFolderInOutput",entryPath.toString(), outputLocation.toString())); //$NON-NLS-1$
- }
-
- // prevent nesting entry inside output location - when distinct from project or a source folder
- if (!allowNestingInOutput && outputLocation.isPrefixOf(entryPath)) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestOuputInSourceFolder", outputLocation.toString(), entryPath.toString())); //$NON-NLS-1$
- }
- }
- return JavaModelStatus.VERIFIED_OK;
-}
-
- /**
- * Returns a message describing the problem related to this classpath entry if any, or null if entry is fine
- * (i.e. if the given classpath entry denotes a valid element to be referenced onto a classpath).
- */
- public static IJavaModelStatus validateClasspathEntry(IJavaProject javaProject, IClasspathEntry entry, boolean checkSourceAttachment){
-
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IPath path = entry.getPath();
-
- switch(entry.getEntryKind()){
-
- // variable entry check
- case IClasspathEntry.CPE_VARIABLE :
- if (path != null && path.segmentCount() >= 1){
- entry = JavaCore.getResolvedClasspathEntry(entry);
- if (entry == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundVariablePath", path.toString())); //$NON-NLS-1$
- }
- return validateClasspathEntry(javaProject, entry, checkSourceAttachment);
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalVariablePath", path.toString())); //$NON-NLS-1$
- }
-
- // library entry check
- case IClasspathEntry.CPE_LIBRARY :
- if (path != null && path.isAbsolute() && !path.isEmpty()) {
- IPath sourceAttachment = entry.getSourceAttachmentPath();
- Object target = JavaModel.getTarget(workspaceRoot, path, true);
- if (target instanceof IResource){
- IResource resolvedResource = (IResource) target;
- switch(resolvedResource.getType()){
- case IResource.FILE :
- String extension = resolvedResource.getFileExtension();
- if ("jar".equalsIgnoreCase(extension) || "zip".equalsIgnoreCase(extension)){ // internal binary archive //$NON-NLS-2$ //$NON-NLS-1$
- if (checkSourceAttachment
- && sourceAttachment != null
- && !sourceAttachment.isEmpty()
- && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString())); //$NON-NLS-1$
- }
- }
- break;
- case IResource.FOLDER : // internal binary folder
- if (checkSourceAttachment
- && sourceAttachment != null
- && !sourceAttachment.isEmpty()
- && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString())); //$NON-NLS-1$
- }
- }
- } else if (target instanceof File){
- if (checkSourceAttachment
- && sourceAttachment != null
- && !sourceAttachment.isEmpty()
- && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString())); //$NON-NLS-1$
- }
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundLibrary", path.toString())); //$NON-NLS-1$
- }
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalLibraryPath", path.toString())); //$NON-NLS-1$
- }
- break;
-
- // project entry check
- case IClasspathEntry.CPE_PROJECT :
- if (path != null && path.isAbsolute() && !path.isEmpty()) {
- IProject project = workspaceRoot.getProject(path.segment(0));
- try {
- if (!project.exists() || !project.hasNature(JavaCore.NATURE_ID)){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.segment(0).toString())); //$NON-NLS-1$
- }
- } catch (CoreException e){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.segment(0).toString())); //$NON-NLS-1$
- }
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalProjectPath", path.segment(0).toString())); //$NON-NLS-1$
- }
- break;
-
- // project source folder
- case IClasspathEntry.CPE_SOURCE :
- if (path != null && path.isAbsolute() && !path.isEmpty()) {
- IPath projectPath= javaProject.getProject().getFullPath();
- if (!projectPath.isPrefixOf(path) || JavaModel.getTarget(workspaceRoot, path, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceFolder", path.toString())); //$NON-NLS-1$
- }
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalSourceFolderPath", path.toString())); //$NON-NLS-1$
- }
- break;
- }
- return JavaModelStatus.VERIFIED_OK;
-}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.ini b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.ini
deleted file mode 100644
index f05b9a7d50..0000000000
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.ini
+++ /dev/null
@@ -1,400 +0,0 @@
-# ===============================================================
-# List of recognized configurable options for the Java Core
-# ===============================================================
-# All available options of the underlying components are listed below, with the
-# default setting to be used in the Java core. Note that the default values mentionned
-# below might override some defaults in the underlying component. Therefore, the
-# component default value is indicated in comment.
-
-
-# ===============================================================
-# COMPILER / Generating Local Variable Debug Attribute
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.localVariableAttribute = 0
-
-# When generated, this attribute will enable local variable names
-# to be displayed in debugger, only in place where variables are
-# definitely assigned (.class file is then bigger)
-#
-# Possible values:
-# 0 - Generate
-# 1 - Do not generate [default]
-
-
-# ===============================================================
-# COMPILER / Generating Line Number Debug Attribute
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.lineNumberAttribute = 0
-
-# When generated, this attribute will enable source code highlighting in debugger
-# (.class file is then bigger).
-#
-# Possible values:
-# 0 - Generate [default]
-# 1 - Do not generate
-
-
-# ===============================================================
-# COMPILER / Generating Source Debug Attribute
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.sourceFileAttribute = 0
-
-# When generated, this attribute will enable the debugger to present the
-# corresponding source code.
-#
-# Possible values:
-# 0 - Generate [default]
-# 1 - Do not generate
-
-
-# ===============================================================
-# COMPILER / Preserving Unused Local Variables
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.preserveUnusedLocal = 0
-
-# Unless requested to preserve unused local variables (i.e. never read), the
-# compiler will optimize them out, potentially altering debugging
-#
-# Possible values:
-# 0 - Preserve
-# 1 - Optimize out [default]
-
-
-# ===============================================================
-# COMPILER / Defining Target Java Platform
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.targetPlatform = 0
-
-# Generate .class files either backward compatible with JVM 1.1 or only executable
-# on JVM 1.2 and later
-#
-# Possible values:
-# 0 - 1.1 [default]
-# 1 - 1.2 or better
-
-
-# ===============================================================
-# COMPILER / Reporting Unreachable Code
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportUnreachableCode = 0
-
-# Unreachable code can optionally be reported as an error, warning or simply
-# ignored. The bytecode generation will always optimized it out.
-#
-# Possible values:
-# 0 - Error [default]
-# 1 - Warning
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Invalid Import
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportInvalidImport = 0
-
-# An import statement that cannot be resolved might optionally be reported
-# as an error, as a warning or ignored.
-#
-# Possible values:
-# 0 - Error [default]
-# 1 - Warning
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Attempt to Override Package-Default Method
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportOverridingPackageDefaultMethod = 1
-
-# A package default method is not visible in a different package, and thus
-# cannot be overriden. When enabling this option, the compiler will signal
-# such scenarii either as an error or a warning.
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Method With Constructor Name
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportMethodWithConstructorName = 1
-
-# Naming a method with a constructor name is generally considered poor
-# style programming. When enabling this option, the compiler will signal such
-# scenarii either as an error or a warning.
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Deprecation
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportDeprecation = 1
-
-# When enabled, the compiler will signal use of deprecated API either as an
-# error or a warning.
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Hidden Catch Block
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportHiddenCatchBlock = 1
-
-# Locally to a try statement, some catch blocks may hide others
-# (e.g. try { throw new java.io.CharConversionException();
-# } catch (java.io.CharConversionException e) {
-# } catch (java.io.IOException e) {}).
-# When enabling this option, the compiler will issue an error or a warning for hidden
-# catch blocks corresponding to checked exceptions
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Unused Local
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportUnusedLocal = 2
-
-# When enabled, the compiler will issue an error or a warning for unused local
-# variables (i.e. variables never read from)
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Unused Parameter
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportUnusedParameter = 2
-
-# When enabled, the compiler will issue an error or a warning for unused method
-# parameters (i.e. parameters never read from)
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Reporting Synthetic Access Emulation
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportSyntheticAccessEmulation = 2
-
-# When enabled, the compiler will issue an error or a warning whenever it emulates
-# access to a non-accessible member of an enclosing type. Such access can have
-# performance ramifications.
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning
-# 2 - Ignore [default]
-
-
-# ===============================================================
-# COMPILER / Reporting Non-Externalized String Literal
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportNonExternalizedStringLiteral = 2
-
-# When enabled, the compiler will issue an error or a warning for non externalized
-# String literal (i.e. non immediately followed by '/*nonNLS*/').
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning
-# 2 - Ignore [default]
-
-
-# ===============================================================
-# COMPILER / Reporting Usage of 'assert' Identifier
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.reportAssertIdentifier = 2
-
-# When enabled, the compiler will issue an error or a warning whenever 'assert' is
-# used as an identifier (reserved keyword in 1.4)
-#
-# Possible values:
-# 0 - Error
-# 1 - Warning [default]
-# 2 - Ignore
-
-
-# ===============================================================
-# COMPILER / Setting Source Compatibility Mode
-# ===============================================================
-org.eclipse.jdt.internal.compiler.Compiler.source = 0
-
-# Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
-# reserved for assertion support.
-#
-# Possible values:
-# 0 - 1.3 [default]
-# 1 - 1.4
-
-
-# ===============================================================
-# JAVACORE / Computing Project Build Order
-# ===============================================================
-org.eclipse.jdt.core.JavaCore.computeJavaBuildOrder = 1
-
-# Indicate whether JavaCore should enforce the project build order to be based on
-# the classpath prerequisite chain. When requesting to compute, this takes over
-# the platform default order (based on project references).
-#
-# Possible values:
-# 0 - Compute
-# 1 - Ignore [default]
-
-
-# ===============================================================
-# FORMATTER / Inserting New Line Before Opening Brace
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.newlineOpeningBrace = 1
-
-# When Insert, a new line is inserted before an opening brace, otherwise nothing
-# is inserted
-#
-# Possible values:
-# 0 - Insert
-# 1 - Do not insert [default]
-
-
-# ===============================================================
-# FORMATTER / Inserting New Line Inside Control Statement
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.newlineControlStatement = 1
-
-# When Insert, a new line is inserted between } and following else, catch, finally
-#
-# Possible values:
-# 0 - Insert
-# 1 - Do not insert [default]
-
-
-# ===============================================================
-# FORMATTER / Clearing Blank Lines
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.newlineClearAll = 1
-
-# When Clear all, all blank lines are removed. When Preserve one, only one is kept
-# and all others removed.
-#
-# Possible values:
-# 0 - Clear all
-# 1 - Preserve one [default]
-
-
-# ===============================================================
-# FORMATTER / Inserting New Line Between Else/If
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.newlineElseIf = 0
-
-# When Insert, a blank line is inserted between an else and an if when they are
-# contiguous. When choosing to not insert, else-if will be kept on the same
-# line when possible.
-#
-# Possible values:
-# 0 - Insert [default]
-# 1 - Do not insert
-
-
-# ===============================================================
-# FORMATTER / Inserting New Line In Empty Block
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.newlineEmptyBlock = 0
-
-# When insert, a line break is inserted between contiguous { and }, if } is not followed
-# by a keyword.
-#
-# Possible values:
-# 0 - Insert [default]
-# 1 - Do not insert
-
-
-# ===============================================================
-# FORMATTER / Splitting Lines Exceeding Length
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.lineSplit = 80
-
-# Enable splitting of long lines (exceeding the configurable length). Length of 0 will
-# disable line splitting
-#
-# Possible values:
-# 0 - Do not split
-# >0 - Split when exceeding length [default:80]
-
-
-# ===============================================================
-# FORMATTER / Compacting Assignment
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.compactAssignment = 1
-
-# Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
-# is inserted before the assignment operator
-#
-# Possible values:
-# 0 - Compact
-# 1 - Normal [default]
-
-
-# ===============================================================
-# FORMATTER / Defining Indentation Character
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.tabulationChar = 0
-
-# Either choose to indent with tab characters or spaces
-#
-# Possible values:
-# 0 - Tab [default]
-# 1 - Spaces
-
-
-# ===============================================================
-# FORMATTER / Defining Space Indentation Length
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CodeFormatter.tabulationSize = 4
-
-# When using spaces, set the amount of space characters to use for each
-# indentation mark.
-#
-# Possible values:
-# >0 - Amount of spaces for a tab [default:4]
-
-# ===============================================================
-# CODEASSIST / Activate Visibility Sensitive Completion
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CompletionEngine.performVisibilityCheck = 0
-
-# When active, completion doesn't show that you can not see
-# (eg. you can not see private methods of a super class).
-#
-# Possible values:
-# 0 - Active [default]
-# 1 - Inactive
-
-# ===============================================================
-# CODEASSIST / Activate Entire Word Replacemement Completion
-# ===============================================================
-org.eclipse.jdt.internal.formatter.CompletionEngine.entireWordReplacement = 0
-
-# When Active, completion replace all the word.
-#
-# Possible values:
-# 0 - Active [default]
-# 1 - Inactive
-
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index c146e33b88..08955adcd4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -4,18 +4,14 @@ package org.eclipse.jdt.core;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-
+
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
import java.io.*;
-import java.net.URL;
import java.util.*;
-import org.eclipse.jdt.internal.codeassist.impl.CompletionOptions;
import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.core.builder.*;
@@ -23,8 +19,6 @@ import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.builder.impl.*;
import org.eclipse.jdt.internal.core.builder.impl.ProblemFactory;
import org.eclipse.jdt.internal.core.search.indexing.*;
-import org.eclipse.jdt.internal.formatter.CodeFormatter;
-import org.eclipse.jdt.internal.formatter.impl.FormatterOptions;
/**
* The plug-in runtime class for the Java model plug-in containing the core
@@ -44,25 +38,25 @@ import org.eclipse.jdt.internal.formatter.impl.FormatterOptions;
*/
public final class JavaCore extends Plugin implements IExecutableExtension {
+
private static Plugin JAVA_CORE_PLUGIN = null;
/**
* The plug-in identifier of the Java core support
* (value <code>"org.eclipse.jdt.core"</code>).
*/
- public static final String PLUGIN_ID = "org.eclipse.jdt.core" ; //$NON-NLS-1$
- // getPlugin().getDescriptor().getUniqueIdentifier();
+ public static final String PLUGIN_ID = "org.eclipse.jdt.core"/*nonNLS*/; // getPlugin().getDescriptor().getUniqueIdentifier();
/**
* The identifier for the Java builder
* (value <code>"org.eclipse.jdt.core.javabuilder"</code>).
*/
- public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder" ; //$NON-NLS-1$
+ public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder"/*nonNLS*/;
/**
* The identifier for the Java model
* (value <code>"org.eclipse.jdt.core.javamodel"</code>).
*/
- public static final String MODEL_ID = PLUGIN_ID + ".javamodel" ; //$NON-NLS-1$
+ public static final String MODEL_ID = PLUGIN_ID + ".javamodel"/*nonNLS*/;
/**
* The identifier for the Java nature
@@ -72,353 +66,347 @@ public final class JavaCore extends Plugin implements IExecutableExtension {
*
* @see org.eclipse.core.resources.IProject#hasNature
*/
- public static final String NATURE_ID = PLUGIN_ID + ".javanature" ; //$NON-NLS-1$
+ public static final String NATURE_ID = PLUGIN_ID + ".javanature"/*nonNLS*/;
/**
* Name of the handle id attribute in a Java marker
*/
- private static final String ATT_HANDLE_ID =
- "org.eclipse.jdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$
-
- private static Hashtable Variables = new Hashtable(5);
+ private static final String ATT_HANDLE_ID= "org.eclipse.jdt.internal.core.JavaModelManager.handleId"/*nonNLS*/;
/**
- * Configurable option names. For further information, refer to the file named Java.ini
+ * Names of recognized configurable options
*/
+ public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"/*nonNLS*/;
+ // possible values are GENERATE or DO_NOT_GENERATE (default is DO_NOT_GENERATE)
+
+ public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"/*nonNLS*/;
+ // possible values are GENERATE or DO_NOT_GENERATE (default is GENERATE)
+
+ public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"/*nonNLS*/;
+ // possible values are GENERATE or DO_NOT_GENERATE (default is GENERATE)
- // File containing default settings for configurable options
- private static final String JAVA_CORE_INIT = "JavaCore.ini"; //$NON-NLS-1$
-
- /**
- * Compiler options
- */
- public static final String OPTION_LocalVariableAttribute = CompilerOptions.OPTION_LocalVariableAttribute;
- public static final String OPTION_LineNumberAttribute = CompilerOptions.OPTION_LineNumberAttribute;
- public static final String OPTION_SourceFileAttribute = CompilerOptions.OPTION_SourceFileAttribute;
- public static final String OPTION_PreserveUnusedLocal = CompilerOptions.OPTION_PreserveUnusedLocal;
- public static final String OPTION_ReportUnreachableCode = CompilerOptions.OPTION_ReportUnreachableCode;
- public static final String OPTION_ReportInvalidImport = CompilerOptions.OPTION_ReportInvalidImport;
- public static final String OPTION_ReportMethodWithConstructorName = CompilerOptions.OPTION_ReportMethodWithConstructorName;
- public static final String OPTION_ReportOverridingPackageDefaultMethod = CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod;
- public static final String OPTION_ReportDeprecation = CompilerOptions.OPTION_ReportDeprecation;
- public static final String OPTION_ReportHiddenCatchBlock = CompilerOptions.OPTION_ReportHiddenCatchBlock;
- public static final String OPTION_ReportUnusedLocal = CompilerOptions.OPTION_ReportUnusedLocal;
- public static final String OPTION_ReportUnusedParameter = CompilerOptions.OPTION_ReportUnusedParameter;
- public static final String OPTION_TargetPlatform = CompilerOptions.OPTION_TargetPlatform;
- public static final String OPTION_ReportSyntheticAccessEmulation = CompilerOptions.OPTION_ReportSyntheticAccessEmulation;
- public static final String OPTION_ReportNonExternalizedStringLiteral = CompilerOptions.OPTION_ReportNonExternalizedStringLiteral;
- public static final String OPTION_Source = CompilerOptions.OPTION_Source;
- public static final String OPTION_ReportAssertIdentifier = CompilerOptions.OPTION_ReportAssertIdentifier;
+ public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"/*nonNLS*/;
+ // possible values are PRESERVE or OPTIMIZE_OUT (default is OPTIMIZE_OUT)
- /**
- * Code Formatter options
- */
- public static final String OPTION_InsertNewlineBeforeOpeningBrace = FormatterOptions.OPTION_InsertNewlineBeforeOpeningBrace;
- public static final String OPTION_InsertNewlineInControlStatement = FormatterOptions.OPTION_InsertNewlineInControlStatement;
- public static final String OPTION_InsertNewLineBetweenElseAndIf = FormatterOptions.OPTION_InsertNewLineBetweenElseAndIf;
- public static final String OPTION_InsertNewLineInEmptyBlock = FormatterOptions.OPTION_InsertNewLineInEmptyBlock;
- public static final String OPTION_ClearAllBlankLines = FormatterOptions.OPTION_ClearAllBlankLines;
- public static final String OPTION_SplitLineExceedingLength = FormatterOptions.OPTION_SplitLineExceedingLength;
- public static final String OPTION_CompactAssignment = FormatterOptions.OPTION_CompactAssignment;
- public static final String OPTION_TabulationChar = FormatterOptions.OPTION_TabulationChar;
- public static final String OPTION_TabulationSize = FormatterOptions.OPTION_TabulationSize;
-
- /**
- * Completion Engine options
- */
- public static final String OPTION_VisibilitySensitivity = CompletionOptions.OPTION_PerformVisibilityCheck;
- public static final String OPTION_EntireWordReplacement = CompletionOptions.OPTION_EntireWordReplacement;
-
- /**
- * JavaCore options
- */
- public static final String OPTION_ComputeBuildOrder = "org.eclipse.jdt.core.JavaCore.computeJavaBuildOrder"; //$NON-NLS-1$
+ public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"/*nonNLS*/;
+ // possible values are VERSION_1_1 or VERSION_1_2 (default is VERSION_1_1)
+
+ public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"/*nonNLS*/;
+ // possible values are ERROR or WARNING (default is ERROR)
+
+ public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"/*nonNLS*/;
+ // possible values are ERROR or WARNING (default is ERROR)
+
+ public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is WARNING)
+
+ public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"/*nonNLS*/;
+ // possible values are WARNING or IGNORE (default is IGNORE)
+ public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"/*nonNLS*/;
+ // possible values are COMPUTE or IGNORE (default is COMPUTE)
/**
- * Code Assist options
+ * Possible values for configurable options
*/
+ public static final String GENERATE = "generate"/*nonNLS*/;
+ public static final String DO_NOT_GENERATE = "do not generate"/*nonNLS*/;
+ public static final String PRESERVE = "preserve"/*nonNLS*/;
+ public static final String OPTIMIZE_OUT = "optimize out"/*nonNLS*/;
+ public static final String VERSION_1_1 = "1.1"/*nonNLS*/;
+ public static final String VERSION_1_2 = "1.2"/*nonNLS*/;
+ public static final String ERROR = "error"/*nonNLS*/;
+ public static final String WARNING = "warning"/*nonNLS*/;
+ public static final String IGNORE = "ignore"/*nonNLS*/;
+ public static final String COMPUTE = "compute"/*nonNLS*/;
- /**
- * Creates the Java core plug-in.
- */
- public JavaCore(IPluginDescriptor pluginDescriptor) {
- super(pluginDescriptor);
- JAVA_CORE_PLUGIN = this;
- }
+ private static Hashtable ConfigurableOptions;
+ private static Hashtable Variables = new Hashtable(5);
+ // possible values are WARNING or IGNORE (default is IGNORE)
- /**
- * Adds the given listener for changes to Java elements.
- * Has no effect if an identical listener is already registered.
- *
- * @param listener the listener
- */
- public static void addElementChangedListener(IElementChangedListener listener) {
- JavaModelManager.getJavaModelManager().addElementChangedListener(listener);
- }
+ public static final String COMPILER_PB_NON_EXTERNALIZED_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"/*nonNLS*/;
- /**
- * Configures the given marker attribute map for the given Java element.
- * Used for markers which denote a Java element rather than a resource.
- *
- * @param attributes the mutable marker attribute map (key type: <code>String</code>,
- * value type: <code>String</code>)
- * @param element the Java element for which the marker needs to be configured
- */
- public static void addJavaElementMarkerAttributes(
- Map attributes,
- IJavaElement element) {
- if (element instanceof IMember)
- element = ((IMember) element).getClassFile();
- if (attributes != null && element != null)
- attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
+/**
+ * Creates the Java core plug-in.
+ */
+public JavaCore(IPluginDescriptor pluginDescriptor) {
+ super(pluginDescriptor);
+ JAVA_CORE_PLUGIN = this;
+}
+/**
+ * Adds the given listener for changes to Java elements.
+ * Has no effect if an identical listener is already registered.
+ *
+ * @param listener the listener
+ */
+public static void addElementChangedListener(IElementChangedListener listener) {
+ JavaModelManager.getJavaModelManager().addElementChangedListener(listener);
+}
+/**
+ * Configures the given marker attribute map for the given Java element.
+ * Used for markers which denote a Java element rather than a resource.
+ *
+ * @param attributes the mutable marker attribute map (key type: <code>String</code>,
+ * value type: <code>String</code>)
+ * @param element the Java element for which the marker needs to be configured
+ */
+public static void addJavaElementMarkerAttributes(Map attributes, IJavaElement element) {
+ if (element instanceof IMember)
+ element= ((IMember) element).getClassFile();
+ if (attributes != null && element != null)
+ attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
+}
+/**
+ * Configures the given marker for the given Java element.
+ * Used for markers which denote a Java element rather than a resource.
+ *
+ * @param marker the marker to be configured
+ * @param element the Java element for which the marker needs to be configured
+ * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
+ */
+public void configureJavaElementMarker(IMarker marker, IJavaElement element) throws CoreException {
+ if (element instanceof IMember)
+ element= ((IMember)element).getClassFile();
+ if (marker != null && element != null)
+ marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
+}
+/**
+ * Returns the Java model element corresponding to the given handle identifier
+ * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
+ * <code>null</code> if unable to create the associated element.
+ */
+public static IJavaElement create(String handleIdentifier) {
+ if (handleIdentifier == null) {
+ return null;
}
- /**
- * Configures the given marker for the given Java element.
- * Used for markers which denote a Java element rather than a resource.
- *
- * @param marker the marker to be configured
- * @param element the Java element for which the marker needs to be configured
- * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
- */
- public void configureJavaElementMarker(IMarker marker, IJavaElement element)
- throws CoreException {
- if (element instanceof IMember)
- element = ((IMember) element).getClassFile();
- if (marker != null && element != null)
- marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
+ try {
+ return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier);
+ } catch (JavaModelException e) {
+ return null;
}
- /**
- * Returns the Java model element corresponding to the given handle identifier
- * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
- * <code>null</code> if unable to create the associated element.
- */
- public static IJavaElement create(String handleIdentifier) {
- if (handleIdentifier == null) {
- return null;
- }
- try {
- return JavaModelManager.getJavaModelManager().getHandleFromMemento(
- handleIdentifier);
- } catch (JavaModelException e) {
- return null;
- }
+}
+/**
+ * Returns the Java element corresponding to the given file, or
+ * <code>null</code> if unable to associate the given file
+ * with a Java element.
+ *
+ * <p>The file must be one of:<ul>
+ * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
+ * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
+ * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
+ * </ul>
+ * <p>
+ * Creating a Java element has the side effect of creating and opening all of the
+ * element's parents if they are not yet open.
+ */
+public static IJavaElement create(IFile file) {
+ if (file == null) {
+ return null;
}
- /**
- * Returns the Java element corresponding to the given file, or
- * <code>null</code> if unable to associate the given file
- * with a Java element.
- *
- * <p>The file must be one of:<ul>
- * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
- * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
- * </ul>
- * <p>
- * Creating a Java element has the side effect of creating and opening all of the
- * element's parents if they are not yet open.
- */
- public static IJavaElement create(IFile file) {
- if (file == null) {
- return null;
- }
- String extension = file.getProjectRelativePath().getFileExtension();
- if (extension != null) {
- extension = extension.toLowerCase();
- if (extension.equals("java" //$NON-NLS-1$
- )) {
- return createCompilationUnitFrom(file);
- } else if (extension.equals("class" //$NON-NLS-1$
- )) {
- return createClassFileFrom(file);
- } else if (extension.equals("jar" //$NON-NLS-1$
- ) || extension.equals("zip" //$NON-NLS-1$
- )) {
- return createJarPackageFragmentRootFrom(file);
- }
+ String extension= file.getProjectRelativePath().getFileExtension();
+ if (extension != null) {
+ extension= extension.toLowerCase();
+ if (extension.equals("java"/*nonNLS*/)) {
+ return createCompilationUnitFrom(file);
+ } else if (extension.equals("class"/*nonNLS*/)) {
+ return createClassFileFrom(file);
+ } else if (extension.equals("jar"/*nonNLS*/) || extension.equals("zip"/*nonNLS*/)) {
+ return createJarPackageFragmentRootFrom(file);
}
+ }
+ return null;
+}
+/**
+ * Returns the package fragment or package fragment root corresponding to the given folder, or
+ * <code>null</code> if unable to associate the given folder with a Java element.
+ * <p>
+ * Note that a package fragment root is returned rather than a default package.
+ * <p>
+ * Creating a Java element has the side effect of creating and opening all of the
+ * element's parents if they are not yet open.
+ */
+public static IJavaElement create(IFolder folder) {
+ if (folder == null) {
return null;
}
- /**
- * Returns the package fragment or package fragment root corresponding to the given folder, or
- * <code>null</code> if unable to associate the given folder with a Java element.
- * <p>
- * Note that a package fragment root is returned rather than a default package.
- * <p>
- * Creating a Java element has the side effect of creating and opening all of the
- * element's parents if they are not yet open.
- */
- public static IJavaElement create(IFolder folder) {
- if (folder == null) {
- return null;
- }
- if (folder.getName().indexOf('.') < 0) {
- JavaProject project = (JavaProject) create(folder.getProject());
- if (project == null)
- return null;
- IJavaElement element = determineIfOnClasspath(folder, project);
- try {
- IPath outputLocation = project.getOutputLocation();
- if (outputLocation == null)
- return null;
- if (outputLocation.isPrefixOf(folder.getFullPath())) {
- if (project.getClasspathEntryFor(outputLocation) != null) {
- // if the output location is the same as an input location, return the element
- return element;
- } else {
- // otherwise, do not create elements for folders in the output location
- return null;
- }
- } else {
+ if (folder.getName().indexOf('.') < 0) {
+ JavaProject project = (JavaProject) create(folder.getProject());
+ if (project == null) return null;
+ IJavaElement element = determineIfOnClasspath(folder, project);
+ try {
+ IPath outputLocation = project.getOutputLocation();
+ if (outputLocation == null) return null;
+ if (outputLocation.isPrefixOf(folder.getFullPath())) {
+ if (project.getClasspathEntryFor(outputLocation) != null) {
+ // if the output location is the same as an input location, return the element
return element;
+ } else {
+ // otherwise, do not create elements for folders in the output location
+ return null;
}
- } catch (JavaModelException e) {
- return null;
+ } else {
+ return element;
}
- }
- return null;
- }
- /**
- * Returns the Java project corresponding to the given project, or
- * <code>null</code> if unable to associate the given project
- * with a Java project.
- * <p>
- * Creating a Java Project has the side effect of creating and opening all of the
- * project's parents if they are not yet open.
- */
- public static IJavaProject create(IProject project) {
- if (project == null) {
+ } catch (JavaModelException e) {
return null;
}
- JavaModel javaModel = JavaModelManager.getJavaModel(project.getWorkspace());
- return javaModel.getJavaProject(project);
}
- /**
- * Returns the Java element corresponding to the given resource, or
- * <code>null</code> if unable to associate the given resource
- * with a Java element.
- * <p>
- * The resource must be one of:<ul>
- * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
- * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
- * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
- * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
- * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
- * or <code>IPackageFragment</code></li>
- * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
- * </ul>
- * <p>
- * Creating a Java element has the side effect of creating and opening all of the
- * element's parents if they are not yet open.
- */
- public static IJavaElement create(IResource resource) {
- if (resource == null) {
- return null;
- }
- int type = resource.getType();
- switch (type) {
- case IResource.PROJECT :
- return create((IProject) resource);
- case IResource.FILE :
- return create((IFile) resource);
- case IResource.FOLDER :
- return create((IFolder) resource);
- case IResource.ROOT :
- return create((IWorkspaceRoot) resource);
- default :
- return null;
- }
+ return null;
+}
+/**
+ * Returns the Java project corresponding to the given project, or
+ * <code>null</code> if unable to associate the given project
+ * with a Java project.
+ * <p>
+ * Creating a Java Project has the side effect of creating and opening all of the
+ * project's parents if they are not yet open.
+ */
+public static IJavaProject create(IProject project) {
+ if (project == null) {
+ return null;
}
- /**
- * Returns the Java model.
- */
- public static IJavaModel create(IWorkspaceRoot root) {
- if (root == null) {
+ JavaModel javaModel= JavaModelManager.getJavaModel(project.getWorkspace());
+ return javaModel.getJavaProject(project);
+}
+/**
+ * Returns the Java element corresponding to the given resource, or
+ * <code>null</code> if unable to associate the given resource
+ * with a Java element.
+ * <p>
+ * The resource must be one of:<ul>
+ * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
+ * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
+ * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
+ * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
+ * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
+ * or <code>IPackageFragment</code></li>
+ * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
+ * </ul>
+ * <p>
+ * Creating a Java element has the side effect of creating and opening all of the
+ * element's parents if they are not yet open.
+ */
+public static IJavaElement create(IResource resource) {
+ if (resource == null) {
+ return null;
+ }
+ int type= resource.getType();
+ switch (type) {
+ case IResource.PROJECT:
+ return create((IProject)resource);
+ case IResource.FILE:
+ return create((IFile)resource);
+ case IResource.FOLDER:
+ return create((IFolder)resource);
+ case IResource.ROOT:
+ return create((IWorkspaceRoot)resource);
+ default:
return null;
- }
- return JavaModelManager.getJavaModel(root.getWorkspace());
}
- /**
- * Creates and returns a class file element for
- * the given <code>.class</code> file. Returns <code>null</code> if unable
- * to recognize the class file.
- */
- public static IClassFile createClassFileFrom(IFile file) {
- IJavaProject project = (IJavaProject) create(file.getProject());
- IPackageFragment pkg = (IPackageFragment) determineIfOnClasspath(file, project);
- if (pkg == null) {
- // fix for 1FVS7WE
- // not on classpath - make the root its folder, and a default package
- IPackageFragmentRoot root = project.getPackageFragmentRoot(file.getParent());
- pkg = root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
- }
- return pkg.getClassFile(file.getName());
+}
+/**
+ * Returns the Java model.
+ */
+public static IJavaModel create(IWorkspaceRoot root) {
+ if (root == null) {
+ return null;
}
- /**
- * Creates and returns a compilation unit element for
- * the given <code>.java</code> file. Returns <code>null</code> if unable
- * to recognize the compilation unit.
- */
- public static ICompilationUnit createCompilationUnitFrom(IFile file) {
- IProject fileProject = file.getProject();
- IJavaProject project = (IJavaProject) create(fileProject);
- IPackageFragment pkg = (IPackageFragment) determineIfOnClasspath(file, project);
- if (pkg == null) {
- // fix for 1FVS7WE
- // not on classpath - make the root its folder, and a default package
- IPackageFragmentRoot root = project.getPackageFragmentRoot(file.getParent());
- pkg = root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
- }
- return pkg.getCompilationUnit(file.getName());
+ return JavaModelManager.getJavaModel(root.getWorkspace());
+}
+/**
+ * Creates and returns a class file element for
+ * the given <code>.class</code> file. Returns <code>null</code> if unable
+ * to recognize the class file.
+ */
+public static IClassFile createClassFileFrom(IFile file) {
+ IJavaProject project = (IJavaProject) create(file.getProject());
+ IPackageFragment pkg = (IPackageFragment) determineIfOnClasspath(file, project);
+ if (pkg == null) {
+ // fix for 1FVS7WE
+ // not on classpath - make the root its folder, and a default package
+ IPackageFragmentRoot root= project.getPackageFragmentRoot(file.getParent());
+ pkg= root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
}
- /**
- * Creates and returns a handle for the given JAR file.
- * The Java model associated with the JAR's project may be
- * created as a side effect.
- * Returns <code>null</code> if unable to create a JAR package fragment root.
- * (for example, if the JAR file represents a non-Java resource)
- */
- public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
- IJavaProject project = (IJavaProject) create(file.getProject());
-
- // Create a jar package fragment root only if on the classpath
- IPath resourcePath = file.getFullPath();
- try {
- IClasspathEntry[] entries = project.getResolvedClasspath(true);
- for (int i = 0, length = entries.length; i < length; i++) {
- IClasspathEntry entry = entries[i];
- IPath rootPath = entry.getPath();
- if (rootPath.equals(resourcePath)) {
- return project.getPackageFragmentRoot(file);
- }
+ return pkg.getClassFile(file.getName());
+}
+/**
+ * Creates and returns a compilation unit element for
+ * the given <code>.java</code> file. Returns <code>null</code> if unable
+ * to recognize the compilation unit.
+ */
+public static ICompilationUnit createCompilationUnitFrom(IFile file) {
+ IProject fileProject = file.getProject();
+ IJavaProject project = (IJavaProject) create(fileProject);
+ IPackageFragment pkg= (IPackageFragment)determineIfOnClasspath(file, project);
+ if (pkg == null) {
+ // fix for 1FVS7WE
+ // not on classpath - make the root its folder, and a default package
+ IPackageFragmentRoot root= project.getPackageFragmentRoot(file.getParent());
+ pkg= root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
+ }
+ return pkg.getCompilationUnit(file.getName());
+}
+/**
+ * Creates and returns a handle for the given JAR file.
+ * The Java model associated with the JAR's project may be
+ * created as a side effect.
+ * Returns <code>null</code> if unable to create a JAR package fragment root.
+ * (for example, if the JAR file represents a non-Java resource)
+ */
+public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
+ IJavaProject project= (IJavaProject)create(file.getProject());
+
+ // Create a jar package fragment root only if on the classpath
+ IPath resourcePath = file.getFullPath();
+ try {
+ IClasspathEntry[] entries = project.getResolvedClasspath(true);
+ for (int i = 0, length = entries.length; i < length; i++) {
+ IClasspathEntry entry = entries[i];
+ IPath rootPath = entry.getPath();
+ if (rootPath.equals(resourcePath)) {
+ return project.getPackageFragmentRoot(file);
}
- } catch (JavaModelException e) {
}
- return null;
+ } catch (JavaModelException e) {
}
- /**
- * Returns the package fragment root represented by the resource, or
- * the package fragment the given resource is located in, or <code>null</code>
- * if the given resource is not on the classpath of the given project.
- */
- private static IJavaElement determineIfOnClasspath(
- IResource resource,
- IJavaProject project) {
- IPath resourcePath = resource.getFullPath();
- try {
- IClasspathEntry[] entries = project.getResolvedClasspath(true);
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- IPath rootPath = entry.getPath();
- if (rootPath.equals(resourcePath)) {
- return project.getPackageFragmentRoot(resource);
- } else if (rootPath.isPrefixOf(resourcePath)) {
- IPackageFragmentRoot root =
- ((JavaProject) project).getPackageFragmentRoot(rootPath);
+ return null;
+}
+/**
+ * Returns the package fragment root represented by the resource, or
+ * the package fragment the given resource is located in, or <code>null</code>
+ * if the given resource is not on the classpath of the given project.
+ */
+private static IJavaElement determineIfOnClasspath(IResource resource, IJavaProject project) {
+ IPath resourcePath = resource.getFullPath();
+ try {
+ IClasspathEntry[] entries = project.getResolvedClasspath(true);
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ IPath rootPath = entry.getPath();
+ if (rootPath.equals(resourcePath)) {
+ return project.getPackageFragmentRoot(resource);
+ } else
+ if (rootPath.isPrefixOf(resourcePath)) {
+ IPackageFragmentRoot root = ((JavaProject)project).getPackageFragmentRoot(rootPath);
IPath pkgPath = resourcePath.removeFirstSegments(rootPath.segmentCount());
if (resource.getType() == IResource.FILE) {
// if the resource is a file, then remove the last segment which
// is the file name in the package
- pkgPath = pkgPath.removeLastSegments(1);
+ pkgPath= pkgPath.removeLastSegments(1);
}
StringBuffer pkgName = new StringBuffer(IPackageFragment.DEFAULT_PACKAGE_NAME);
for (int j = 0, max = pkgPath.segmentCount(); j < max; j++) {
@@ -428,936 +416,662 @@ public final class JavaCore extends Plugin implements IExecutableExtension {
}
pkgName.append(segment);
if (j < pkgPath.segmentCount() - 1) {
- pkgName.append("." ); //$NON-NLS-1$
+ pkgName.append("."/*nonNLS*/);
}
}
return root.getPackageFragment(pkgName.toString());
}
- }
- } catch (JavaModelException npe) {
- return null;
}
+ } catch (JavaModelException npe) {
return null;
}
- /**
- * Returns the path held in the given classpath variable.
- * Returns <node>null</code> if unable to bind.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @param variableName the name of the classpath variable
- * @return the path, or <code>null</code> if none
- * @see #setClasspathVariable
- */
- public static IPath getClasspathVariable(String variableName) {
- return (IPath) Variables.get(variableName);
- }
- /**
- * Returns the names of all known classpath variables.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @return the list of classpath variable names
- * @see #setClasspathVariable
- */
- public static String[] getClasspathVariableNames() {
- int length = Variables.size();
- String[] result = new String[length];
- Enumeration vars = Variables.keys();
- int index = 0;
- while (vars.hasMoreElements()) {
- result[index++] = (String) vars.nextElement();
- }
- return result;
- }
-
- private static IPath getInstallLocation() {
- return new Path(getPlugin().getDescriptor().getInstallURL().getFile());
+ return null;
+}
+/**
+ * Returns the path held in the given classpath variable.
+ * Returns <node>null</code> if unable to bind.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @param variableName the name of the classpath variable
+ * @return the path, or <code>null</code> if none
+ * @see #setClasspathVariable
+ */
+public static IPath getClasspathVariable(String variableName) {
+ return (IPath)Variables.get(variableName);
+}
+/**
+ * Returns the names of all known classpath variables.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @return the list of classpath variable names
+ * @see #setClasspathVariable
+ */
+public static String[] getClasspathVariableNames() {
+ int length = Variables.size();
+ String[] result = new String[length];
+ Enumeration vars = Variables.keys();
+ int index = 0;
+ while (vars.hasMoreElements()){
+ result[index++] = (String)vars.nextElement();
}
+ return result;
+}
+/**
+ * Answers a set of configurable options with their default values.
+ * These options allow to configure the behavior of the underlying components.
+ *
+ * Recognized options are listed below, optionName = possibleValue1 / possibleValue2
+ * where [] are enclosing the default value of the corresponding option.
+ *
+ * Note: more options might be added in further releases.
+ *
+ * RECOGNIZED OPTIONS:
+ *
+ * COMPILER_LOCAL_VARIABLE_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable local variable names to be displayed
+ * in debugger, only in place where variables are definitely assigned
+ * (.class file is then bigger)
+ *
+ * COMPILER_LINE_NUMBER_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable source code highlighting in debugger
+ * (.class file is then bigger).
+ *
+ * COMPILER_SOURCE_FILE_ATTR = [GENERATE] | DO_NOT_GENERATE
+ * When generated, this attribute will enable the debugger to present the
+ * corresponding source code.
+ *
+ * COMPILER_CODEGEN_UNUSED_LOCAL = [PRESERVE] | OPTIMIZE_OUT
+ * Unless requested to preserve unused local variables (i.e. never read), the
+ * compiler will optimize them out, potentially altering debugging
+ *
+ * COMPILER_CODEGEN_TARGET_PLATFORM = [VERSION_1_1] | VERSION_1_2
+ * Generate .class files either backward compatible with JVM 1.1 or only executable
+ * on JVM 1.2 and later
+ *
+ * COMPILER_PB_UNREACHABLE_CODE = [ERROR] | WARNING
+ * Unreachable code can either be reported as an error or a warning
+ *
+ * COMPILER_PB_INVALID_IMPORT = [ERROR] | WARNING
+ * An import statement that cannot be resolved might either be reported
+ * either as an error or as a warning
+ *
+ * COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = [WARNING] | IGNORE
+ * A package default method is not visible in a different package, and thus
+ * cannot be overriden. When enabling this option, the compiler will signal
+ * such scenarii.
+ *
+ * COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = [WARNING] | IGNORE
+ * Naming a method with a constructor name is generally considered poor
+ * style programming. When enabling this option, the compiler will signal such
+ * scenarii
+ *
+ * COMPILER_PB_DEPRECATION = [WARNING] | IGNORE
+ * When enabled, the compiler will signal use of deprecated API.
+ *
+ * COMPILER_PB_HIDDEN_CATCH_BLOCK = [WARNING] | IGNORE
+ * Locally to a try statement, some catch blocks may hide others
+ * (e.g. try { throw new java.io.CharConversionException();
+ * } catch (java.io.CharConversionException e) {
+ * } catch (java.io.IOException e) {}).
+ * When enabling this option, the compiler will issue a warning for hidden catch
+ * blocks corresponding to checked exceptions
+ *
+ * COMPILER_PB_UNUSED_LOCAL = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning for unused local variables
+ * (i.e. variables never read from)
+ *
+ * COMPILER_PB_UNUSED_PARAMETER = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning for unused method parameters
+ * (i.e. parameters never read from)
+ *
+ * COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = WARNING | [IGNORE]
+ * When enabled, the compiler will issue a warning whenever it emulates access
+ * to a non-accessible member of an enclosing type
+ *
+ * CORE_JAVA_BUILD_ORDER = [COMPUTE] | IGNORE
+ * When enabled, the build order is automatically reflecting the classpath on each
+ * classpath change action. It can still be modified manually afterwards.
+ */
+
+public static Hashtable getDefaultOptions(){
+
+ Hashtable defaultOptions = new Hashtable(10);
+
+ // Compiler settings
+ defaultOptions.put(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_LINE_NUMBER_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_SOURCE_FILE_ATTR, GENERATE);
+ defaultOptions.put(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
+ defaultOptions.put(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
+ defaultOptions.put(COMPILER_PB_UNREACHABLE_CODE, ERROR);
+ defaultOptions.put(COMPILER_PB_INVALID_IMPORT, ERROR);
+ defaultOptions.put(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING);
+ defaultOptions.put(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING);
+ defaultOptions.put(COMPILER_PB_DEPRECATION, WARNING);
+ defaultOptions.put(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
+ defaultOptions.put(COMPILER_PB_UNUSED_LOCAL, IGNORE);
+ defaultOptions.put(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
+ defaultOptions.put(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
+ defaultOptions.put(COMPILER_PB_NON_EXTERNALIZED_STRING_LITERAL, IGNORE);
+
+ // JavaCore settings
+ defaultOptions.put(CORE_JAVA_BUILD_ORDER, IGNORE);
- /**
- * Returns the single instance of the Java core plug-in runtime class.
- * Equivalent to <code>(JavaCore) getPlugin()</code>.
- */
- public static JavaCore getJavaCore() {
- return (JavaCore) getPlugin();
- }
- /**
- * Returns the <code>IJavaProject</code> associated with the
- * given <code>IProject</code>, or <code>null</code> if the
- * project does not have a Java nature.
- */
- private IJavaProject getJavaProject(IProject project) {
- try {
- if (project.hasNature(NATURE_ID)) {
- JavaModel model = JavaModelManager.getJavaModel(project.getWorkspace());
- if (model != null) {
- return model.getJavaProject(project);
- }
+ return defaultOptions;
+}
+/**
+ * Returns the single instance of the Java core plug-in runtime class.
+ * Equivalent to <code>(JavaCore) getPlugin()</code>.
+ */
+public static JavaCore getJavaCore() {
+ return (JavaCore) getPlugin();
+}
+/**
+ * Returns the <code>IJavaProject</code> associated with the
+ * given <code>IProject</code>, or <code>null</code> if the
+ * project does not have a Java nature.
+ */
+private IJavaProject getJavaProject(IProject project) {
+ try {
+ if (project.hasNature(NATURE_ID)) {
+ JavaModel model= JavaModelManager.getJavaModel(project.getWorkspace());
+ if (model != null) {
+ return model.getJavaProject(project);
}
- } catch (CoreException e) {
}
- return null;
+ } catch (CoreException e) {
}
-
- /**
- * Returns the single instance of the Java core plug-in runtime class.
- */
- public static Plugin getPlugin() {
- return JAVA_CORE_PLUGIN;
- }
-
- /**
- * This is a helper method which returns the resolved classpath entry denoted
- * by a given entry (if it is a variable entry). It is obtained by resolving the variable
- * reference in the first segment. Returns <node>null</code> if unable to resolve using
- * the following algorithm:
- * <ul>
- * <li> if variable segment cannot be resolved, returns <code>null</code></li>
- * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
- * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
- * <li> if none returns <code>null</code></li>
- * </ul>
- * <p>
- * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
- * <p>
- * @return the resolved library or project classpath entry, or <code>null</code>
- * if the given variable entry could not be resolved to a valid classpath entry
- */
- public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
-
- if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
- return entry;
-
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
- if (resolvedPath == null)
- return null;
-
- Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
- if (target == null)
- return null;
+ return null;
+}
+/**
+ * Answers a copy of the current set of configurable options supported by the Java core.
+ * These options allow to configure the behavior of the underlying components.
+ *
+ * Changes on the set of options are not committed until invoking <code>JavaCore.setOptions</code>
+ *
+ * For a list of recognized options, refer to <code>JavaCore.getDefaultOptions</code>
+ */
+public static Hashtable getOptions(){
- // inside the workspace
- if (target instanceof IResource) {
- IResource resolvedResource = (IResource) target;
- if (resolvedResource != null) {
- switch (resolvedResource.getType()) {
- case IResource.PROJECT :
- return JavaCore.newProjectEntry(resolvedPath); // internal project
- case IResource.FILE :
- String extension = resolvedResource.getFileExtension();
- if ("jar" //$NON-NLS-1$
- .equalsIgnoreCase(extension) || "zip" //$NON-NLS-1$
- .equalsIgnoreCase(extension)) { // internal binary archive
- return JavaCore.newLibraryEntry(
+ if (ConfigurableOptions == null) return ConfigurableOptions = getDefaultOptions();
+ return (Hashtable)ConfigurableOptions.clone();
+}
+/**
+ * Returns the single instance of the Java core plug-in runtime class.
+ */
+public static Plugin getPlugin() {
+ return JAVA_CORE_PLUGIN;
+}
+/**
+ * This is a helper method which returns the resolved classpath entry denoted
+ * by a given entry (if it is a variable entry). It is obtained by resolving the variable
+ * reference in the first segment. Returns <node>null</code> if unable to resolve using
+ * the following algorithm:
+ * <ul>
+ * <li> if variable segment cannot be resolved, returns <code>null</code></li>
+ * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
+ * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
+ * <li> if none returns <code>null</code></li>
+ * </ul>
+ * <p>
+ * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
+ * <p>
+ * @return the resolved library or project classpath entry, or <code>null</code>
+ * if the given variable entry could not be resolved to a valid classpath entry
+ */
+public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
+
+ if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) return entry;
+
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
+ if (resolvedPath == null) return null;
+
+ Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
+ if (target == null) return null;
+
+ // inside the workspace
+ if (target instanceof IResource){
+ IResource resolvedResource = (IResource) target;
+ if (resolvedResource != null){
+ switch(resolvedResource.getType()){
+ case IResource.PROJECT :
+ return JavaCore.newProjectEntry(resolvedPath); // internal project
+ case IResource.FILE :
+ String extension = resolvedResource.getFileExtension();
+ if ("jar"/*nonNLS*/.equalsIgnoreCase(extension) || "zip"/*nonNLS*/.equalsIgnoreCase(extension)){ // internal binary archive
+ return JavaCore.newLibraryEntry(
resolvedPath,
getResolvedVariablePath(entry.getSourceAttachmentPath()),
- getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
- }
- break;
- case IResource.FOLDER : // internal binary folder
- return JavaCore.newLibraryEntry(
+ getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
+ }
+ break;
+ case IResource.FOLDER : // internal binary folder
+ return JavaCore.newLibraryEntry(
resolvedPath,
getResolvedVariablePath(entry.getSourceAttachmentPath()),
- getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
- }
+ getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
}
}
- // outside the workspace
- if (target instanceof File) {
- File externalFile = (File) target;
- if (externalFile.isFile()) {
- String fileName = externalFile.getName().toLowerCase();
- if (fileName.endsWith(".jar" //$NON-NLS-1$
- ) || fileName.endsWith(".zip" //$NON-NLS-1$
- )) { // external binary archive
- return JavaCore.newLibraryEntry(
+ }
+ // outside the workspace
+ if (target instanceof File){
+ File externalFile = (File) target;
+ if (externalFile.isFile()){
+ String fileName = externalFile.getName().toLowerCase();
+ if (fileName.endsWith(".jar"/*nonNLS*/) || fileName.endsWith(".zip"/*nonNLS*/)){ // external binary archive
+ return JavaCore.newLibraryEntry(
resolvedPath,
getResolvedVariablePath(entry.getSourceAttachmentPath()),
- getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
- }
- } else { // external binary folder
- return JavaCore.newLibraryEntry(
- resolvedPath,
- getResolvedVariablePath(entry.getSourceAttachmentPath()),
- getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
+ getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
}
+ } else { // external binary folder
+ return JavaCore.newLibraryEntry(
+ resolvedPath,
+ getResolvedVariablePath(entry.getSourceAttachmentPath()),
+ getResolvedVariablePath(entry.getSourceAttachmentRootPath()));
}
- return null;
}
+ return null;
+}
+/**
+ * Resolve a variable path (helper method)
+ */
+public static IPath getResolvedVariablePath(IPath variablePath) {
- /**
- * Resolve a variable path (helper method)
- */
- public static IPath getResolvedVariablePath(IPath variablePath) {
+ if (variablePath == null) return null;
+ int count = variablePath.segmentCount();
+ if (count == 0) return null;
- if (variablePath == null)
- return null;
- int count = variablePath.segmentCount();
- if (count == 0)
- return null;
-
- // lookup variable
- String variableName = variablePath.segment(0);
- IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
- if (resolvedPath == null || resolvedPath.isEmpty())
- return null;
+ // lookup variable
+ String variableName = variablePath.segment(0);
+ IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
+ if (resolvedPath == null || resolvedPath.isEmpty()) return null;
- // append path suffix
- if (count > 1) {
- resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
- }
- return resolvedPath;
+ // append path suffix
+ if (count > 1){
+ resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
}
-
- /**
- * Returns whether the given marker references the given Java element.
- * Used for markers which denote a Java element rather than a resource.
- *
- * @param element the element
- * @param marker the marker
- * @return <code>true</code> if the marker references the element
- * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails
- */
- public static boolean isReferencedBy(IJavaElement element, IMarker marker)
- throws CoreException {
- if (element instanceof IMember)
- element = ((IMember) element).getClassFile();
- return (
- element != null
- && marker != null
- && element.getHandleIdentifier().equals(marker.getAttribute(ATT_HANDLE_ID)));
- }
-
- /**
- * Returns whether the given marker delta references the given Java element.
- * Used for markers deltas which denote a Java element rather than a resource.
- *
- * @param element the element
- * @param markerDelta the marker delta
- * @return <code>true</code> if the marker delta references the element
- * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails
- */
- public static boolean isReferencedBy(
- IJavaElement element,
- IMarkerDelta markerDelta)
- throws CoreException {
- if (element instanceof IMember)
- element = ((IMember) element).getClassFile();
- return element != null
- && markerDelta != null
+ return resolvedPath;
+}
+/**
+ * Returns whether the given marker references the given Java element.
+ * Used for markers which denote a Java element rather than a resource.
+ *
+ * @param element the element
+ * @param marker the marker
+ * @return <code>true</code> if the marker references the element
+ * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails
+ */
+ public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException {
+ if (element instanceof IMember)
+ element= ((IMember)element).getClassFile();
+ return (element != null
+ && marker != null
+ && element.getHandleIdentifier().equals(marker.getAttribute(ATT_HANDLE_ID)));
+}
+/**
+ * Returns whether the given marker delta references the given Java element.
+ * Used for markers deltas which denote a Java element rather than a resource.
+ *
+ * @param element the element
+ * @param markerDelta the marker delta
+ * @return <code>true</code> if the marker delta references the element
+ * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails
+ */
+public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException {
+ if (element instanceof IMember) element= ((IMember) element).getClassFile();
+ return element != null
+ && markerDelta != null
&& element.getHandleIdentifier().equals(markerDelta.getAttribute(ATT_HANDLE_ID));
- }
-
- /**
- * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
- * identified by the given absolute path. This specifies that all package fragments within the root
- * will have children of type <code>IClassFile</code>.
- * <p>
- * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
- * The target JAR or folder can either be defined internally to the workspace (absolute path relative
- * to the workspace root) or externally to the workspace (absolute path in the file system).
- *
- * e.g. Here are some examples of binary path usage<ul>
- * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
- * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
- * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
- * </ul>
- * Note that this operation does not attempt to validate or access the
- * resources at the given paths.
- * <p>
- * @param path the absolute path of the binary archive
- * @param sourceAttachmentPath the absolute path of the corresponding source archive,
- * or <code>null</code> if none
- * @param sourceAttachmentRootPath the location of the root within the source archive
- * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
- */
- public static IClasspathEntry newLibraryEntry(
- IPath path,
- IPath sourceAttachmentPath,
- IPath sourceAttachmentRootPath) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
- return new ClasspathEntry(
- IPackageFragmentRoot.K_BINARY,
- IClasspathEntry.CPE_LIBRARY,
+}
+/**
+ * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
+ * identified by the given absolute path. This specifies that all package fragments within the root
+ * will have children of type <code>IClassFile</code>.
+ * <p>
+ * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
+ * The target JAR or folder can either be defined internally to the workspace (absolute path relative
+ * to the workspace root) or externally to the workspace (absolute path in the file system).
+ *
+ * e.g. Here are some examples of binary path usage<ul>
+ * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
+ * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
+ * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
+ * </ul>
+ * Note that this operation does not attempt to validate or access the
+ * resources at the given paths.
+ * <p>
+ * @param path the absolute path of the binary archive
+ * @param sourceAttachmentPath the absolute path of the corresponding source archive,
+ * or <code>null</code> if none
+ * @param sourceAttachmentRootPath the location of the root within the source archive
+ * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
+ */
+
+public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath) {
+ Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ return new ClasspathEntry(
+ IPackageFragmentRoot.K_BINARY,
+ IClasspathEntry.CPE_LIBRARY,
JavaProject.canonicalizedPath(path),
sourceAttachmentPath,
sourceAttachmentRootPath);
- }
-
- /**
- * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
- * for the project identified by the given absolute path.
- * <p>
- * A project entry is used to denote a prerequisite project on a classpath.
- * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
- * contributes all its package fragment roots) or as binaries (when building, it contributes its
- * whole output location).
- * <p>
- * A project reference allows to indirect through another project, independently from its internal layout.
- * <p>
- * The prerequisite project is referred to using an absolute path relative to the workspace root.
- */
- public static IClasspathEntry newProjectEntry(IPath path) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
- return new ClasspathEntry(
- IPackageFragmentRoot.K_SOURCE,
- IClasspathEntry.CPE_PROJECT,
- path,
- null,
- null);
- }
-
- /**
- * Returns a new empty region.
- */
- public static IRegion newRegion() {
- return new Region();
- }
+}
+/**
+ * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
+ * for the project identified by the given absolute path.
+ * <p>
+ * A project entry is used to denote a prerequisite project on a classpath.
+ * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
+ * contributes all its package fragment roots) or as binaries (when building, it contributes its
+ * whole output location).
+ * <p>
+ * A project reference allows to indirect through another project, independently from its internal layout.
+ * <p>
+ * The prerequisite project is referred to using an absolute path relative to the workspace root.
+ */
+public static IClasspathEntry newProjectEntry(IPath path){
+ Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, path, null, null);
+}
+/**
+ * Returns a new empty region.
+ */
+public static IRegion newRegion() {
+ return new Region();
+}
+/**
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> for the project's source folder
+ * identified by the given absolute path. This specifies that all package fragments within the root will
+ * have children of type <code>ICompilationUnit</code>.
+ * <p>
+ * The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>"/Project/src"</code>.
+ * <p>
+ * A source entry is used to setup the internal source layout of a project, and cannot be used out of the
+ * context of the containing project (a source entry "Proj1/src" cannot be used on the classpath of Proj2).
+ */
+public static IClasspathEntry newSourceEntry(IPath path){
+ Assert.isTrue(path.isAbsolute(), Util.bind("classpath.needAbsolutePath"/*nonNLS*/));
+ return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, path, null, null);
+}
+/**
+ * Creates and returns a new classpath entry of kind <code>CPE_VARIABLE</code>
+ * for the given path. The first segment of the the path is the name of a classpath variable.
+ * The trailing segments of the path will be appended to resolved variable path.
+ * <p>
+ * A variable entry allows to express indirect references on a classpath to other projects or libraries,
+ * depending on what the classpath variable is referring.
+ * <p>
+ * e.g. Here are some examples of variable path usage<ul>
+ * <li><"JDTCORE" where variable <code>JDTCORE</code> is
+ * bound to "c:/jars/jdtcore.jar". The resoved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
+ * <li> "JDTCORE" where variable <code>JDTCORE</code> is
+ * bound to "/Project_JDTCORE". The resoved classpath entry is denoting the project "/Project_JDTCORE"</li>
+ * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
+ * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
+ * </ul>
+ * <p>
+ * Note that this operation does not attempt to validate classpath variables
+ * or access the resources at the given paths.
+ * <p>
+ * @param variablePath the path of the binary archive; first segment is the
+ * name of a classpath variable
+ * @param variableSourceAttachmentPath the path of the corresponding source archive,
+ * or <code>null</code> if none; if present, the first segment is the
+ * name of a classpath variable (not necessarily the same variable
+ * as the one that begins <code>variablePath</code>)
+ * @param sourceAttachmentRootPath the location of the root within the source archive
+ * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
+ */
+public static IClasspathEntry newVariableEntry(IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath){
+ Assert.isTrue(variablePath != null && variablePath.segmentCount() >= 1, Util.bind("classpath.illegalVariablePath"/*nonNLS*/));
+ return new ClasspathEntry(
+ IPackageFragmentRoot.K_SOURCE,
+ IClasspathEntry.CPE_VARIABLE,
+ variablePath,
+ variableSourceAttachmentPath,
+ sourceAttachmentRootPath);
+}
+/**
+ * Removed the given classpath variable. Does nothing if no value was
+ * set for this classpath variable.
+ * <p>
+ * This functionality cannot be used while the resource tree is locked.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @param variableName the name of the classpath variable
+ * @see #setClasspathVariable
+ *
+ * @deprecated - use version with extra IProgressMonitor
+ */
+public static void removeClasspathVariable(String variableName) {
- /**
- * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> for the project's source folder
- * identified by the given absolute path. This specifies that all package fragments within the root will
- * have children of type <code>ICompilationUnit</code>.
- * <p>
- * The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>"/Project/src"</code>.
- * <p>
- * A source entry is used to setup the internal source layout of a project, and cannot be used out of the
- * context of the containing project (a source entry "Proj1/src" cannot be used on the classpath of Proj2).
- */
- public static IClasspathEntry newSourceEntry(IPath path) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
- return new ClasspathEntry(
- IPackageFragmentRoot.K_SOURCE,
- IClasspathEntry.CPE_SOURCE,
- path,
- null,
- null);
- }
+ removeClasspathVariable(variableName, null);
+}
+/**
+ * Removed the given classpath variable. Does nothing if no value was
+ * set for this classpath variable.
+ * <p>
+ * This functionality cannot be used while the resource tree is locked.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @param variableName the name of the classpath variable
+ * @param monitor the progress monitor to report progress
+ * @see #setClasspathVariable
+ */
+public static void removeClasspathVariable(String variableName, IProgressMonitor monitor) {
- /**
- * Creates and returns a new classpath entry of kind <code>CPE_VARIABLE</code>
- * for the given path. The first segment of the the path is the name of a classpath variable.
- * The trailing segments of the path will be appended to resolved variable path.
- * <p>
- * A variable entry allows to express indirect references on a classpath to other projects or libraries,
- * depending on what the classpath variable is referring.
- * <p>
- * e.g. Here are some examples of variable path usage<ul>
- * <li><"JDTCORE" where variable <code>JDTCORE</code> is
- * bound to "c:/jars/jdtcore.jar". The resoved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
- * <li> "JDTCORE" where variable <code>JDTCORE</code> is
- * bound to "/Project_JDTCORE". The resoved classpath entry is denoting the project "/Project_JDTCORE"</li>
- * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
- * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
- * </ul>
- * <p>
- * Note that this operation does not attempt to validate classpath variables
- * or access the resources at the given paths.
- * <p>
- * @param variablePath the path of the binary archive; first segment is the
- * name of a classpath variable
- * @param variableSourceAttachmentPath the path of the corresponding source archive,
- * or <code>null</code> if none; if present, the first segment is the
- * name of a classpath variable (not necessarily the same variable
- * as the one that begins <code>variablePath</code>)
- * @param sourceAttachmentRootPath the location of the root within the source archive
- * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
- */
- public static IClasspathEntry newVariableEntry(
- IPath variablePath,
- IPath variableSourceAttachmentPath,
- IPath sourceAttachmentRootPath) {
- Assert.isTrue(
- variablePath != null && variablePath.segmentCount() >= 1,
- Util.bind("classpath.illegalVariablePath" )); //$NON-NLS-1$
- return new ClasspathEntry(
- IPackageFragmentRoot.K_SOURCE,
- IClasspathEntry.CPE_VARIABLE,
- variablePath,
- variableSourceAttachmentPath,
- sourceAttachmentRootPath);
+ try {
+ updateVariableValue(variableName, null, monitor);
+ } catch(JavaModelException e){
}
+}
+/**
+ * Removes the given element changed listener.
+ * Has no affect if an identical listener is not registered.
+ *
+ * @param listener the listener
+ */
+public static void removeElementChangedListener(IElementChangedListener listener) {
+ JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
+}
+/**
+ * Sets the value of the given classpath variable.
+ * The path must have at least one segment.
+ * <p>
+ * This functionality cannot be used while the resource tree is locked.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @param variableName the name of the classpath variable
+ * @param path the path
+ * @see #getClasspathVariable
+ *
+ * @deprecated - use API with IProgressMonitor
+ */
+public static void setClasspathVariable(String variableName, IPath path) throws JavaModelException {
- /**
- * Removed the given classpath variable. Does nothing if no value was
- * set for this classpath variable.
- * <p>
- * This functionality cannot be used while the resource tree is locked.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @param variableName the name of the classpath variable
- * @see #setClasspathVariable
- *
- * @deprecated - use version with extra IProgressMonitor
- */
- public static void removeClasspathVariable(String variableName) {
- removeClasspathVariable(variableName, null);
- }
+ setClasspathVariable(variableName, path, null);
+}
+/**
+ * Sets the value of the given classpath variable.
+ * The path must have at least one segment.
+ * <p>
+ * This functionality cannot be used while the resource tree is locked.
+ * <p>
+ * Classpath variable values are persisted locally to the workspace, and
+ * are preserved from session to session.
+ * <p>
+ *
+ * @param variableName the name of the classpath variable
+ * @param path the path
+ * @param monitor a monitor to report progress
+ * @see #getClasspathVariable
+ */
+public static void setClasspathVariable(String variableName, IPath path, IProgressMonitor monitor) throws JavaModelException {
+
+ Assert.isTrue(path != null, Util.bind("classpath.nullVariablePath"/*nonNLS*/));
+ updateVariableValue(variableName, path, monitor);
+}
+/* (non-Javadoc)
+ * Method declared on IExecutableExtension.
+ * Record any necessary initialization data from the plugin.
+ */
+public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) throws CoreException {}
+/**
+ * Set current set of configurable options supported by the Java core.
+ * These options allow to configure the behavior of the underlying components.
+ *
+ * For a list of recognized options, refer to <code>JavaCore.getDefaultOptions</code>
+ */
+public static void setOptions(Hashtable configurableOptions){
+ ConfigurableOptions = (Hashtable) configurableOptions.clone();
+}
+/**
+ * Shutdown the JavaCore plugin
+ * <p>
+ * De-registers the JavaModelManager as a resource changed listener and save participant.
+ * <p>
+ * @see Plugin#shutdown
+ */
+public void shutdown() {
- /**
- * Removed the given classpath variable. Does nothing if no value was
- * set for this classpath variable.
- * <p>
- * This functionality cannot be used while the resource tree is locked.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @param variableName the name of the classpath variable
- * @param monitor the progress monitor to report progress
- * @see #setClasspathVariable
- */
- public static void removeClasspathVariable(
- String variableName,
- IProgressMonitor monitor) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager());
+ workspace.removeSaveParticipant(this);
- try {
- updateVariableValue(variableName, null, monitor);
- } catch (JavaModelException e) {
+ ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
+}
+/**
+ * Initiate the background indexing process.
+ * This should be deferred after the plugin activation.
+ */
+private void startIndexing() {
+
+ JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
+ IndexManager indexManager = manager.getIndexManager();
+ if (indexManager != null) indexManager.reset();
+ /*
+ // if there is a desktop defer the start of the indexing by posting a runnable
+ if (getDesktopPlugin() != null) {
+ IDesktop desktop= getDesktop();
+ ApplicationWindow window= (ApplicationWindow) desktop.getActiveDesktopWindow();
+ Display display= null;
+ if (window != null)
+ display= window.getDisplay();
+ if (display != null) {
+ display.asyncExec(start);
+ return;
+ }
}
- }
-
- /**
- * Removes the given element changed listener.
- * Has no affect if an identical listener is not registered.
- *
- * @param listener the listener
- */
- public static void removeElementChangedListener(IElementChangedListener listener) {
- JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
- }
-
- /**
- * Sets the value of the given classpath variable.
- * The path must have at least one segment.
- * <p>
- * This functionality cannot be used while the resource tree is locked.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @param variableName the name of the classpath variable
- * @param path the path
- * @see #getClasspathVariable
- *
- * @deprecated - use API with IProgressMonitor
- */
- public static void setClasspathVariable(String variableName, IPath path)
- throws JavaModelException {
-
- setClasspathVariable(variableName, path, null);
- }
-
- /**
- * Sets the value of the given classpath variable.
- * The path must have at least one segment.
- * <p>
- * This functionality cannot be used while the resource tree is locked.
- * <p>
- * Classpath variable values are persisted locally to the workspace, and
- * are preserved from session to session.
- * <p>
- *
- * @param variableName the name of the classpath variable
- * @param path the path
- * @param monitor a monitor to report progress
- * @see #getClasspathVariable
- */
- public static void setClasspathVariable(
- String variableName,
- IPath path,
- IProgressMonitor monitor)
- throws JavaModelException {
-
- Assert.isTrue(path != null, Util.bind("classpath.nullVariablePath" )); //$NON-NLS-1$
- updateVariableValue(variableName, path, monitor);
- }
-
- /* (non-Javadoc)
- * Method declared on IExecutableExtension.
- * Record any necessary initialization data from the plugin.
- */
- public void setInitializationData(
- IConfigurationElement cfig,
- String propertyName,
- Object data)
- throws CoreException {
- }
-
- /**
- * Shutdown the JavaCore plugin
- * <p>
- * De-registers the JavaModelManager as a resource changed listener and save participant.
- * <p>
- * @see Plugin#shutdown
- */
- public void shutdown() {
-
+ */
+}
+/**
+ * Startup of the JavaCore plugin
+ * <p>
+ * Registers the JavaModelManager as a resource changed listener and save participant.
+ * Starts the background indexing, and restore saved classpath variable values.
+ * <p>
+ * @see Plugin#startup
+ */
+public void startup() {
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager());
- workspace.removeSaveParticipant(this);
-
- ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
- }
-
- /**
- * Initiate the background indexing process.
- * This should be deferred after the plugin activation.
- */
- private void startIndexing() {
-
- JavaModelManager manager =
- (JavaModelManager) JavaModelManager.getJavaModelManager();
IndexManager indexManager = manager.getIndexManager();
- if (indexManager != null)
- indexManager.reset();
- }
-
- /**
- * Startup of the JavaCore plugin
- * <p>
- * Registers the JavaModelManager as a resource changed listener and save participant.
- * Starts the background indexing, and restore saved classpath variable values.
- * <p>
- * @see Plugin#startup
- */
- public void startup() {
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IndexManager indexManager = manager.getIndexManager();
- if (indexManager != null) {
- // need to initialize workbench now since a query may be done before indexing starts
- indexManager.workspace = workspace;
- }
- workspace.addResourceChangeListener(
- manager,
- IResourceChangeEvent.PRE_AUTO_BUILD
- | IResourceChangeEvent.POST_CHANGE
- | IResourceChangeEvent.PRE_DELETE
- | IResourceChangeEvent.PRE_CLOSE);
-
- startIndexing();
-
- workspace.addSaveParticipant(this, manager);
- manager.loadVariables();
- manager.loadOptions();
- } catch (CoreException e) {
- } catch (RuntimeException e) {
- manager.shutdown();
- throw e;
+ if (indexManager != null) {
+ // need to initialize workbench now since a query may be done before indexing starts
+ indexManager.workspace = workspace;
}
+ workspace.addResourceChangeListener(
+ manager,
+ IResourceChangeEvent.PRE_AUTO_BUILD | IResourceChangeEvent.POST_CHANGE
+ | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE);
+
+ startIndexing();
+
+ workspace.addSaveParticipant(this, manager);
+ manager.loadVariables();
+ } catch(CoreException e) {
+ } catch(RuntimeException e){
+ manager.shutdown();
+ throw e;
}
-
- /**
- * Internal updating of a variable value (null path meaning removal).
- */
- private static void updateVariableValue(
- String variableName,
- IPath path,
- IProgressMonitor monitor)
- throws JavaModelException {
-
- // gather classpath information for updating
- Hashtable affectedProjects = new Hashtable(5);
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- try {
- IJavaModel model = manager.getJavaModel();
- if (model != null) {
- IJavaProject[] projects = model.getJavaProjects();
- nextProject : for (int i = 0, max = projects.length; i < max; i++) {
- IClasspathEntry[] entries = projects[i].getRawClasspath();
- for (int j = 0, cplength = entries.length; j < cplength; j++) {
- IClasspathEntry oldEntry = entries[j];
- if (oldEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
- IPath sourcePath, sourceRootPath;
- if (oldEntry.getPath().segment(0).equals(variableName)
- || ((sourcePath = oldEntry.getSourceAttachmentPath()) != null
- && sourcePath.segment(0).equals(variableName))
- || ((sourceRootPath = oldEntry.getSourceAttachmentRootPath()) != null
- && sourceRootPath.segment(0).equals(variableName))) {
- affectedProjects.put(projects[i], projects[i].getResolvedClasspath(true));
- continue nextProject;
- }
+}
+/**
+ * Internal updating of a variable value (null path meaning removal).
+ */
+private static void updateVariableValue(String variableName, IPath path, IProgressMonitor monitor) throws JavaModelException {
+
+ // gather classpath information for updating
+ Hashtable affectedProjects = new Hashtable(5);
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ try {
+ IJavaModel model = manager.getJavaModel();
+ if (model != null){
+ IJavaProject[] projects = model.getJavaProjects();
+ nextProject: for (int i = 0, max = projects.length; i < max; i++){
+ IClasspathEntry[] entries = projects[i].getRawClasspath();
+ for (int j = 0, cplength = entries.length; j < cplength; j++){
+ IClasspathEntry oldEntry = entries[j];
+ if (oldEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
+ IPath sourcePath, sourceRootPath;
+ if (oldEntry.getPath().segment(0).equals(variableName)
+ || ((sourcePath = oldEntry.getSourceAttachmentPath()) != null && sourcePath.segment(0).equals(variableName))
+ || ((sourceRootPath = oldEntry.getSourceAttachmentRootPath()) != null && sourceRootPath.segment(0).equals(variableName))) {
+ affectedProjects.put(projects[i], projects[i].getResolvedClasspath(true));
+ continue nextProject;
}
}
}
}
- } catch (JavaModelException e) {
- }
- if (path == null) {
- Variables.remove(variableName);
- } else {
- // new variable value is assigned
- Variables.put(variableName, path);
- }
- if (!affectedProjects.isEmpty()) {
- boolean wasFiring = manager.isFiring();
- try {
- if (wasFiring)
- manager.stopDeltas();
- // propagate classpath change
- Enumeration projectsToUpdate = affectedProjects.keys();
- while (projectsToUpdate.hasMoreElements()) {
- JavaProject project = (JavaProject) projectsToUpdate.nextElement();
- project
- .setRawClasspath(
- project.getRawClasspath(),
- monitor,
- project.getWorkspace().isAutoBuilding(),
- // force build if in auto build mode
- (IClasspathEntry[]) affectedProjects.get(project));
- }
- } finally {
- manager.mergeDeltas();
- if (wasFiring) {
- manager.startDeltas();
- manager.fire();
- }
- }
- }
- }
-
- /**
- * Set the value of the current setting for an option.
- *
- * @return IJavaModelStatusConstants.INVALID_OPTION_VALUE if option value
- * are not correct and IJavaModelStatusConstants.INVALID_OPTION if option
- * doesn't exist.
- */
- public static IJavaModelStatus setOptionValue(String id, String value) {
- IJavaModelStatus status = validateOptionValue(id, value);
- if (status.getCode() == IJavaModelStatus.OK) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
- if (option != null)
- option.setValue(value);
- }
- return status;
- }
-
- /**
- * Answer the value of the current setting for an option.
- *
- * @return String
- */
- public static String getOptionValue(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getValue();
-
- return null;
- }
-
- /**
- * Set the value of the default setting for an option.
- *
- * @return IJavaModelStatusConstants.INVALID_OPTION_VALUE if option value
- * are not correct and IJavaModelStatusConstants.INVALID_OPTION if option
- * doesn't exist.
- */
- private static IJavaModelStatus setOptionDefaultValue(
- String id,
- String value) {
- IJavaModelStatus status = validateOptionValue(id, value);
- if (status.getCode() == IJavaModelStatus.OK) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
- if (option != null)
- option.setDefaultValue(value);
- }
- return status;
- }
-
- /**
- * Answer the value of the default setting for an option.
- *
- * @return String
- */
- public static String getOptionDefaultValue(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getDefaultValue();
-
- return null;
- }
-
- /**
- * Return an String that represents the localized description of an option.
- *
- * @return java.lang.String
- */
- public static String getOptionDescription(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getDescription();
-
- return null;
- }
- /**
- * Return a String that represents the localized name of an option.
- * @return java.lang.String
- */
- public static String getOptionName(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getName();
-
- return null;
- }
-
- /**
- * Return a String that identifies the component owner of an option
- * (typically the qualified type name of the class which it corresponds to).
- *
- * e.g. "org.eclipse.jdt.internal.compiler.api.Compiler"
- *
- * @return java.lang.String
- */
- public static String getOptionComponentName(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getComponentName();
-
- return null;
- }
-
- /**
- * Return a String that represents the localized category of an option.
- * @return java.lang.String
- */
- public static String getOptionCategory(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getCategory();
-
- return null;
- }
-
- /**
- * Return an array of String that represents the localized possible values of an option.
- *
- * @return java.lang.String[]
- */
- public static String[] getOptionPossibleValues(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getPossibleValues();
-
- return null;
- }
-
- /**
- * Return the type of option. Type is a String with possible value :
- * <code>discrete</code>,<code>string</code>,<code>int</code> and
- * <code>float</code>.
- */
- public static String getOptionType(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getType();
-
- return null;
- }
-
- /**
- * Return the maximum value of option if option's type is <code>int</code>
- * or <code>float</code>.Otherwise return null.
- */
- public static Number getOptionMax(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null) {
- return option.getMax();
- }
-
- return null;
- }
-
- /**
- * Return the minimum value of option if option's type is <code>int</code>
- * or <code>float</code>.Otherwise return null.
- */
- public static Number getOptionMin(String id) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null)
- return option.getMin();
-
- return null;
- }
-
- /**
- * Answers a set of option'IDs which are in option set of JavaCore
- */
- public static String[] getOptionIDs() {
- return JavaModelManager.getOptionIDs();
- }
-
- /**
- * Answers a set of option'IDs which are in option set of JavaCore
- * and associated with a component.
- */
- public static String[] getOptionIDs(String componentName) {
- String[] ids = getOptionIDs();
-
- String[] result = new String[ids.length];
- int resultCount = 0;
- for (int i = 0; i < ids.length; i++) {
- if (ids[i].startsWith(componentName))
- result[resultCount++] = ids[i];
- }
-
- System.arraycopy(result, 0, result = new String[resultCount], 0, resultCount);
-
- return result;
- }
-
- /**
- * Answers if a value is valide for an option
- *
- * @return IJavaModelStatusConstants.INVALID_OPTION_VALUE if option value
- * are not correct and IJavaModelStatusConstants.INVALID_OPTION if option
- * doesn't exist.
- */
- public static IJavaModelStatus validateOptionValue(String id, String value) {
- ConfigurableOption option = (ConfigurableOption) getOptions().get(id);
-
- if (option != null) {
- String[] values = option.getPossibleValues();
- if (values == ConfigurableOption.NoDiscreteValue) {
- try {
- if (option.getType().equals(ConfigurableOption.INT)) {
- int max = option.getMax().intValue();
- int min = option.getMin().intValue();
- int val = Integer.parseInt(value);
- if (val > max || val < min)
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_OPTION_VALUE);
- } else if (option.getType().equals(ConfigurableOption.FLOAT)) {
- float max = option.getMax().floatValue();
- float min = option.getMin().floatValue();
- float val = Float.parseFloat(value);
- if (val > max || val < min)
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_OPTION_VALUE);
- }
- } catch (NumberFormatException e) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_OPTION_VALUE);
- }
- return JavaModelStatus.VERIFIED_OK;
- } else {
- for (int i = 0; i < values.length; i++) {
- if (values[i].equals(value))
- return JavaModelStatus.VERIFIED_OK;
- }
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_OPTION_VALUE);
- }
}
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_OPTION);
+ } catch(JavaModelException e){
}
- /**
- * Reset JavaCore option values to defaults.
- */
- public static void resetOptions() {
- Locale locale = Locale.getDefault();
-
- if (JavaModelManager.fOptions == null) {
- JavaModelManager.initializeOptions();
- // Set options to JavaCore default value
- setJavaCoreDefaultOptionsValue(locale);
-
- } else {
- ConfigurableOption[] options =
- (ConfigurableOption[]) JavaModelManager.fOptions.values().toArray(
- new ConfigurableOption[0]);
- for (int i = 0; i < options.length; i++)
- options[i].setToDefault();
- }
+ if (path == null){
+ Variables.remove(variableName);
+ } else {
+ // new variable value is assigned
+ Variables.put(variableName, path);
}
- private static void setJavaCoreDefaultOptionsValue(Locale locale) {
- BufferedReader reader = null;
+ if (!affectedProjects.isEmpty()){
+ boolean wasFiring = manager.isFiring();
try {
- reader =
- new BufferedReader(
- new InputStreamReader(JavaCore.class.getResourceAsStream(JAVA_CORE_INIT)));
- String line = reader.readLine();
- while (line != null) {
- int equalIndex = line.indexOf("=" ); //$NON-NLS-1$
- if (!line.startsWith("#" ) && equalIndex != -1) { //$NON-NLS-1$
- String id = line.substring(0, equalIndex).trim();
-
- ConfigurableOption option = new ConfigurableOption(id, locale);
- if (option.getPossibleValues() != ConfigurableOption.NoDiscreteValue) {
- try {
- int index = Integer.parseInt(line.substring(equalIndex + 1).trim());
- option.setDefaultValueIndex(index);
- } catch (NumberFormatException e) {
- // value is default default value
- }
- } else {
- String value = line.substring(equalIndex + 1).trim();
- option.setDefaultValue(value);
- }
- JavaModelManager.addOption(option);
- }
- line = reader.readLine();
+ if (wasFiring) manager.stopDeltas();
+ // propagate classpath change
+ Enumeration projectsToUpdate = affectedProjects.keys();
+ while (projectsToUpdate.hasMoreElements()){
+ JavaProject project = (JavaProject)projectsToUpdate.nextElement();
+ project.setRawClasspath(
+ project.getRawClasspath(),
+ monitor,
+ project.getWorkspace().isAutoBuilding(), // force build if in auto build mode
+ (IClasspathEntry[])affectedProjects.get(project));
}
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
} finally {
- if (reader != null) {
- try {
- reader.close();
- } catch(IOException e){
- }
+ manager.mergeDeltas();
+ if (wasFiring){
+ manager.startDeltas();
+ manager.fire();
}
}
}
-
- private static Hashtable getOptions() {
- if (JavaModelManager.fOptions == null)
- resetOptions();
-
- return JavaModelManager.fOptions;
- }
-
- /**
- * Returns all the options of Java Core to be shown by the UI
- *
- * @param locale java.util.Locale
- * @return org.eclipse.jdt.internal.compiler.ConfigurableOption[]
- */
- private static ConfigurableOption[] getDefaultOptions(Locale locale) {
- String[] ids = ConfigurableOption.getIDs(JavaCore.class.getName(), locale);
-
- ConfigurableOption[] result = new ConfigurableOption[ids.length];
- for (int i = 0; i < ids.length; i++) {
- result[i] = new ConfigurableOption(ids[i], locale);
- }
- return result;
- }
-} \ No newline at end of file
+}
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
index 0a6ba96945..e7017e5071 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
@@ -98,13 +98,13 @@ public boolean isDoesNotExist() {
*/
public String toString() {
StringBuffer buffer= new StringBuffer();
- buffer.append("Java Model Exception: "); //$NON-NLS-1$
+ buffer.append("Java Model Exception: "/*nonNLS*/);
if (getException() != null) {
if (getException() instanceof CoreException) {
CoreException c= (CoreException)getException();
- buffer.append("Core Exception [code "); //$NON-NLS-1$
+ buffer.append("Core Exception [code "/*nonNLS*/);
buffer.append(c.getStatus().getCode());
- buffer.append("] "); //$NON-NLS-1$
+ buffer.append("] "/*nonNLS*/);
buffer.append(c.getStatus().getMessage());
} else {
buffer.append(getException().toString());
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
index 0afa1ac33c..7a870dd705 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
@@ -173,54 +173,54 @@ public final class Signature {
* String constant for the signature of the primitive type boolean.
* Value is <code>"Z"</code>.
*/
- public static final String SIG_BOOLEAN = "Z"; //$NON-NLS-1$
+ public static final String SIG_BOOLEAN = "Z"/*nonNLS*/;
/**
* String constant for the signature of the primitive type byte.
* Value is <code>"B"</code>.
*/
- public static final String SIG_BYTE = "B"; //$NON-NLS-1$
+ public static final String SIG_BYTE = "B"/*nonNLS*/;
/**
* String constant for the signature of the primitive type char.
* Value is <code>"C"</code>.
*/
- public static final String SIG_CHAR = "C"; //$NON-NLS-1$
+ public static final String SIG_CHAR = "C"/*nonNLS*/;
/**
* String constant for the signature of the primitive type double.
* Value is <code>"D"</code>.
*/
- public static final String SIG_DOUBLE = "D"; //$NON-NLS-1$
+ public static final String SIG_DOUBLE = "D"/*nonNLS*/;
/**
* String constant for the signature of the primitive type float.
* Value is <code>"F"</code>.
*/
- public static final String SIG_FLOAT = "F"; //$NON-NLS-1$
+ public static final String SIG_FLOAT = "F"/*nonNLS*/;
/**
* String constant for the signature of the primitive type int.
* Value is <code>"I"</code>.
*/
- public static final String SIG_INT = "I"; //$NON-NLS-1$
+ public static final String SIG_INT = "I"/*nonNLS*/;
/**
* String constant for the signature of the primitive type long.
* Value is <code>"J"</code>.
*/
- public static final String SIG_LONG = "J"; //$NON-NLS-1$
+ public static final String SIG_LONG = "J"/*nonNLS*/;
/**
* String constant for the signature of the primitive type short.
* Value is <code>"S"</code>.
*/
- public static final String SIG_SHORT = "S"; //$NON-NLS-1$
+ public static final String SIG_SHORT = "S"/*nonNLS*/;
/** String constant for the signature of result type void.
* Value is <code>"V"</code>.
*/
- public static final String SIG_VOID = "V"; //$NON-NLS-1$
+ public static final String SIG_VOID = "V"/*nonNLS*/;
/**
* Not instantiable.
@@ -236,7 +236,7 @@ private static String arrayIfy(String typeName, int arrayCount) {
StringBuffer sb = new StringBuffer(typeName.length() + arrayCount * 2);
sb.append(typeName);
for (int i = 0; i < arrayCount; ++i) {
- sb.append("[]"); //$NON-NLS-1$
+ sb.append("[]"/*nonNLS*/);
}
return sb.toString();
}
@@ -302,7 +302,7 @@ public static String createTypeSignature(char[] typeName, boolean isResolved) {
return SIG_VOID;
case 6 :
if (typeName[0] == 'S' && typeName[1] == 't' && typeName[2] == 'r' && typeName[3] == 'i' && typeName[4] == 'n' && typeName[5] == 'g')
- if (!isResolved) return "QString;"; //$NON-NLS-1$
+ if (!isResolved) return "QString;"/*nonNLS*/;
break;
case 7 :
if (typeName[0] == 'b' && typeName[1] == 'o' && typeName[2] == 'o' && typeName[3] == 'l' && typeName[4] == 'e' && typeName[5] == 'a' && typeName[6] == 'n')
@@ -617,7 +617,7 @@ public static String[] getParameterTypes(String methodSignature) throws IllegalA
public static String getQualifier(String name) {
int lastDot = name.lastIndexOf(C_DOT);
if (lastDot == -1) {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
return name.substring(0, lastDot);
}
@@ -715,7 +715,7 @@ public static String[] getSimpleNames(String name) {
*/
public static String toQualifiedName(String[] segments) {
if (segments.length == 0) {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
if (segments.length == 1) {
return segments[0];
@@ -755,28 +755,28 @@ public static String toQualifiedName(String[] segments) {
public static String toString(String signature) throws IllegalArgumentException {
try {
if (signature.charAt(0) == C_PARAM_START) {
- return toString(signature, "", null, true, true); //$NON-NLS-1$
+ return toString(signature, ""/*nonNLS*/, null, true, true);
}
int arrayCount = getArrayCount(signature);
switch (signature.charAt(arrayCount)) {
case C_BOOLEAN :
- return arrayIfy("boolean", arrayCount); //$NON-NLS-1$
+ return arrayIfy("boolean"/*nonNLS*/, arrayCount);
case C_BYTE :
- return arrayIfy("byte", arrayCount); //$NON-NLS-1$
+ return arrayIfy("byte"/*nonNLS*/, arrayCount);
case C_CHAR :
- return arrayIfy("char", arrayCount); //$NON-NLS-1$
+ return arrayIfy("char"/*nonNLS*/, arrayCount);
case C_DOUBLE :
- return arrayIfy("double", arrayCount); //$NON-NLS-1$
+ return arrayIfy("double"/*nonNLS*/, arrayCount);
case C_FLOAT :
- return arrayIfy("float", arrayCount); //$NON-NLS-1$
+ return arrayIfy("float"/*nonNLS*/, arrayCount);
case C_INT :
- return arrayIfy("int", arrayCount); //$NON-NLS-1$
+ return arrayIfy("int"/*nonNLS*/, arrayCount);
case C_LONG :
- return arrayIfy("long", arrayCount); //$NON-NLS-1$
+ return arrayIfy("long"/*nonNLS*/, arrayCount);
case C_SHORT :
- return arrayIfy("short", arrayCount); //$NON-NLS-1$
+ return arrayIfy("short"/*nonNLS*/, arrayCount);
case C_VOID :
- return arrayIfy("void", arrayCount); //$NON-NLS-1$
+ return arrayIfy("void"/*nonNLS*/, arrayCount);
case C_RESOLVED :
case C_UNRESOLVED :
int semi = signature.indexOf(C_SEMICOLON, arrayCount + 1);
@@ -838,7 +838,7 @@ public static String toString(String methodSignature, String methodName, String[
sb.append(C_PARAM_START);
for (int i = 0; i < paramTypes.length; ++i) {
if (i != 0)
- sb.append(", "); //$NON-NLS-1$
+ sb.append(", "/*nonNLS*/);
String readableParamType = toString(paramTypes[i]);
if (!fullyQualifyTypeNames) {
int lastDot = readableParamType.lastIndexOf(C_DOT);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
index 83758ed1b8..bb561115f9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
@@ -47,7 +47,7 @@ public IDOMCompilationUnit createCompilationUnit(String sourceCode, String name)
* Method declared on IDOMFactory.
*/
public IDOMField createField() {
- return createField("Object aField;"+ JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ return createField("Object aField;"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR);
}
/* (non-Javadoc)
* Method declared on IDOMFactory.
@@ -77,7 +77,7 @@ public IDOMImport createImport(String sourceCode) {
* Method declared on IDOMFactory.
*/
public IDOMInitializer createInitializer() {
- return createInitializer("static {}"+ JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ return createInitializer("static {}"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR);
}
/* (non-Javadoc)
* Method declared on IDOMFactory.
@@ -92,7 +92,7 @@ public IDOMInitializer createInitializer(String sourceCode) {
* Method declared on IDOMFactory.
*/
public IDOMMethod createMethod() {
- return createMethod("public void newMethod() {"+ JavaModelManager.LINE_SEPARATOR+"}"+ JavaModelManager.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
+ return createMethod("public void newMethod() {"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR+"}"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR);
}
/* (non-Javadoc)
* Method declared on IDOMFactory.
@@ -122,7 +122,7 @@ public IDOMPackage createPackage(String sourceCode) {
* Method declared on IDOMFactory.
*/
public IDOMType createType() {
- return createType("public class AClass {"+ JavaModelManager.LINE_SEPARATOR +"}"+ JavaModelManager.LINE_SEPARATOR); //$NON-NLS-2$ //$NON-NLS-1$
+ return createType("public class AClass {"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR +"}"/*nonNLS*/+ JavaModelManager.LINE_SEPARATOR);
}
/* (non-Javadoc)
* Method declared on IDOMFactory.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
index 8ad8792f2f..707494cf7b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
@@ -19,7 +19,7 @@ private Assert() {
* @exception IllegalArgumentException if the legality test failed
*/
public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
+ return isLegal(expression, ""/*nonNLS*/);
}
/** Asserts that an argument is legal. If the given boolean is
* not <code>true</code>, an <code>IllegalArgumentException</code>
@@ -44,7 +44,7 @@ public static boolean isLegal(boolean expression, String message) {
* @exception IllegalArgumentException if the object is <code>null</code>
*/
public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
+ isNotNull(object, ""/*nonNLS*/);
}
/** Asserts that the given object is not <code>null</code>. If this
* is not the case, some kind of unchecked exception is thrown.
@@ -56,7 +56,7 @@ public static void isNotNull(Object object) {
*/
public static void isNotNull(Object object, String message) {
if (object == null)
- throw new AssertionFailedException(Util.bind("assert.nullArgument",message)); //$NON-NLS-1$
+ throw new AssertionFailedException(Util.bind("assert.nullArgument"/*nonNLS*/,message));
}
/** Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
@@ -66,7 +66,7 @@ public static void isNotNull(Object object, String message) {
* if the check fails)
*/
public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
+ return isTrue(expression, ""/*nonNLS*/);
}
/** Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
@@ -79,7 +79,7 @@ public static boolean isTrue(boolean expression) {
*/
public static boolean isTrue(boolean expression, String message) {
if (!expression)
- throw new AssertionFailedException(Util.bind("assert.failed", message)); //$NON-NLS-1$
+ throw new AssertionFailedException(Util.bind("assert.failed"/*nonNLS*/, message));
return expression;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
index c1972e9062..7f9ec6723d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
@@ -21,11 +21,11 @@ public BasicCompilationUnit(char[] contents, String fileName) {
this.contents = contents;
this.fileName = fileName.toCharArray();
- int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$
- if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$
- start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$
+ int start = fileName.lastIndexOf("/"/*nonNLS*/) + 1;
+ if (start == 0 || start < fileName.lastIndexOf("\\"/*nonNLS*/))
+ start = fileName.lastIndexOf("\\"/*nonNLS*/) + 1;
- int end = fileName.lastIndexOf("."); //$NON-NLS-1$
+ int end = fileName.lastIndexOf("."/*nonNLS*/);
if (end == -1)
end = fileName.length();
@@ -75,6 +75,6 @@ public char[] getMainTypeName() {
return mainTypeName;
}
public String toString(){
- return "CompilationUnit: "+new String(fileName); //$NON-NLS-1$
+ return "CompilationUnit: "/*nonNLS*/+new String(fileName);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
index 2bf473bf2a..0616e24f54 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
@@ -110,7 +110,7 @@ public String[] getParameterNames() throws JavaModelException {
int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
fParameterNames = new String[paramCount];
for (int i = 0; i < paramCount; i++) {
- fParameterNames[i] = "arg" + i; //$NON-NLS-1$
+ fParameterNames[i] = "arg"/*nonNLS*/ + i;
}
}
return fParameterNames;
@@ -151,18 +151,18 @@ public boolean isConstructor() throws JavaModelException {
public String readableName() {
StringBuffer buffer = new StringBuffer(super.readableName());
- buffer.append("("); //$NON-NLS-1$
+ buffer.append("("/*nonNLS*/);
String[] parameterTypes = this.getParameterTypes();
int length;
if (parameterTypes != null && (length = parameterTypes.length) > 0) {
for (int i = 0; i < length; i++) {
buffer.append(Signature.toString(parameterTypes[i]));
if (i < length - 1) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
}
}
- buffer.append(")"); //$NON-NLS-1$
+ buffer.append(")"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
index d71ce8ed06..49dbcaf257 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
@@ -109,7 +109,7 @@ public IType getDeclaringType() {
return null;
}
enclosingTypeName = ClassFile.unqualifiedName(enclosingTypeName);
- return getPackageFragment().getClassFile(new String(enclosingTypeName) + ".class").getType(); //$NON-NLS-1$
+ return getPackageFragment().getClassFile(new String(enclosingTypeName) + ".class"/*nonNLS*/).getType();
} catch (JavaModelException npe) {
return null;
}
@@ -231,7 +231,7 @@ public String[] getSuperInterfaceNames() throws JavaModelException {
* @see IType#getType
*/
public IType getType(String name) {
- IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + name + ".class"); //$NON-NLS-2$ //$NON-NLS-1$
+ IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$"/*nonNLS*/ + name + ".class"/*nonNLS*/);
return new BinaryType(classFile, name);
}
/**
@@ -302,7 +302,7 @@ public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaMode
*/
public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
if (project == null) {
- throw new IllegalArgumentException(Util.bind("hierarchy.nullProject")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("hierarchy.nullProject"/*nonNLS*/));
}
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(
this,
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
index 85b4c44149..150909f0e4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
@@ -166,8 +166,8 @@ private String findLineSeparator(char[] text) {
char currentChar = nextChar;
nextChar = i < length-1 ? text[i+1] : ' ';
switch (currentChar) {
- case '\n': return "\n"; //$NON-NLS-1$
- case '\r': return nextChar == '\n' ? "\r\n" : "\r"; //$NON-NLS-1$ //$NON-NLS-2$
+ case '\n': return "\n"/*nonNLS*/;
+ case '\r': return nextChar == '\n' ? "\r\n"/*nonNLS*/ : "\r"/*nonNLS*/;
}
}
}
@@ -208,7 +208,7 @@ public char[] getCharacters() {
*/
public String getContents() {
if (fContents == null)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
synchronized (fLock) {
if (fGapStart < 0) {
return new String(fContents);
@@ -261,7 +261,7 @@ public IOpenable getOwner() {
*/
public String getText(int offset, int length) {
if (fContents == null)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
synchronized (fLock) {
if (offset + length < fGapStart)
return new String(fContents, offset, length);
@@ -616,19 +616,19 @@ public String toString() {
char[] contents = this.getCharacters();
int length = contents.length;
StringBuffer buffer = new StringBuffer(length);
- buffer.append("Buffer:\n"); //$NON-NLS-1$
+ buffer.append("Buffer:\n"/*nonNLS*/);
for (int i = 0; i < length; i++) {
char car = contents[i];
switch (car) {
case '\n':
- buffer.append("\\n\n"); //$NON-NLS-1$
+ buffer.append("\\n\n"/*nonNLS*/);
break;
case '\r':
if (i < length-1 && contents[i+1] == '\n') {
- buffer.append("\\r\\n\n"); //$NON-NLS-1$
+ buffer.append("\\r\\n\n"/*nonNLS*/);
i++;
} else {
- buffer.append("\\r\n"); //$NON-NLS-1$
+ buffer.append("\\r\n"/*nonNLS*/);
}
break;
default:
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
index d4c5da52e2..a956b0d46b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
@@ -33,7 +33,7 @@ public class ClassFile extends Openable implements IClassFile {
protected ClassFile(IPackageFragment parent, String name) {
super(CLASS_FILE, parent, name);
if (!Util.isClassFileName(name)) {
- throw new IllegalArgumentException(Util.bind("element.invalidClassFileName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.invalidClassFileName"/*nonNLS*/));
}
}
/**
@@ -42,7 +42,7 @@ protected ClassFile(IPackageFragment parent, String name) {
public void codeComplete(int offset, ICodeCompletionRequestor requestor) throws JavaModelException {
String source = getSource();
if (source != null) {
- BasicCompilationUnit cu = new BasicCompilationUnit(getSource().toCharArray(), getElementName() + ".java"); //$NON-NLS-1$
+ BasicCompilationUnit cu = new BasicCompilationUnit(getSource().toCharArray(), getElementName() + ".java"/*nonNLS*/);
codeComplete(cu, cu, offset, requestor);
}
}
@@ -56,7 +56,7 @@ public IJavaElement[] codeSelect(int offset, int length) throws JavaModelExcepti
contents = buffer.getCharacters();
String name = getElementName();
name = name.substring(0, name.length() - 6); // remove ".class"
- name = name + ".java"; //$NON-NLS-1$
+ name = name + ".java"/*nonNLS*/;
BasicCompilationUnit cu = new BasicCompilationUnit(contents, name);
return super.codeSelect(cu, offset, length);
} else {
@@ -141,7 +141,7 @@ private IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException {
zip = root.getJar();
String entryName = getParent().getElementName();
entryName = entryName.replace('.', '/');
- if (entryName.equals("")) { //$NON-NLS-1$
+ if (entryName.equals(""/*nonNLS*/)) {
entryName += getElementName();
} else {
entryName += '/' + getElementName();
@@ -278,7 +278,7 @@ public IType getType() throws JavaModelException {
public WorkingCopy getWorkingCopy() {
String name = getElementName();
name = name.substring(0, name.length() - 6); // remove ".class"
- name = name + ".java"; //$NON-NLS-1$
+ name = name + ".java"/*nonNLS*/;
return new WorkingCopy((IPackageFragment) getParent(), name);
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
index 35ca099896..2db5ba76dd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
@@ -73,7 +73,7 @@ private void generateInnerClassInfos(IType type, IBinaryType typeInfo, Hashtable
for (int i = 0, typeCount = innerTypes.length; i < typeCount; i++) {
IBinaryNestedType binaryType = innerTypes[i];
String innerQualifiedName = new String(binaryType.getName());
- IClassFile classFile= ((IPackageFragment)fClassFile.getParent()).getClassFile(new String(ClassFile.unqualifiedName(binaryType.getName())) + ".class"); //$NON-NLS-1$
+ IClassFile classFile= ((IPackageFragment)fClassFile.getParent()).getClassFile(new String(ClassFile.unqualifiedName(binaryType.getName())) + ".class"/*nonNLS*/);
IType innerType = new BinaryType(classFile, new String(ClassFile.simpleName(binaryType.getName())));
children.addElement(innerType);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
index d0a65fd757..8ec95adbbd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
@@ -170,38 +170,38 @@ public String toString() {
buffer.append('[');
switch (getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY:
- buffer.append("CPE_LIBRARY"); //$NON-NLS-1$
+ buffer.append("CPE_LIBRARY"/*nonNLS*/);
break;
case IClasspathEntry.CPE_PROJECT:
- buffer.append("CPE_PROJECT"); //$NON-NLS-1$
+ buffer.append("CPE_PROJECT"/*nonNLS*/);
break;
case IClasspathEntry.CPE_SOURCE:
- buffer.append("CPE_SOURCE"); //$NON-NLS-1$
+ buffer.append("CPE_SOURCE"/*nonNLS*/);
break;
case IClasspathEntry.CPE_VARIABLE:
- buffer.append("CPE_VARIABLE"); //$NON-NLS-1$
+ buffer.append("CPE_VARIABLE"/*nonNLS*/);
break;
}
- buffer.append("]["); //$NON-NLS-1$
+ buffer.append("]["/*nonNLS*/);
switch (getContentKind()) {
case IPackageFragmentRoot.K_BINARY:
- buffer.append("K_BINARY"); //$NON-NLS-1$
+ buffer.append("K_BINARY"/*nonNLS*/);
break;
case IPackageFragmentRoot.K_SOURCE:
- buffer.append("K_SOURCE"); //$NON-NLS-1$
+ buffer.append("K_SOURCE"/*nonNLS*/);
break;
case ClasspathEntry.K_OUTPUT:
- buffer.append("K_OUTPUT"); //$NON-NLS-1$
+ buffer.append("K_OUTPUT"/*nonNLS*/);
break;
}
buffer.append(']');
if (getSourceAttachmentPath() != null){
- buffer.append("[sourcePath:"); //$NON-NLS-1$
+ buffer.append("[sourcePath:"/*nonNLS*/);
buffer.append(getSourceAttachmentPath());
buffer.append(']');
}
if (getSourceAttachmentRootPath() != null){
- buffer.append("[rootPath:"); //$NON-NLS-1$
+ buffer.append("[rootPath:"/*nonNLS*/);
buffer.append(getSourceAttachmentRootPath());
buffer.append(']');
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
index b42b95fc1d..28d5127d25 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
@@ -86,7 +86,7 @@ private void checkPackageDeclaration(ICompilationUnit cu)
* of the original compilation unit fails
*/
protected void executeOperation() throws JavaModelException {
- beginTask(Util.bind("workingCopy.commit"), 2); //$NON-NLS-1$
+ beginTask(Util.bind("workingCopy.commit"/*nonNLS*/), 2);
ICompilationUnit copy = getCompilationUnit();
ICompilationUnit original = (ICompilationUnit) copy.getOriginalElement();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
index 266d4a93c5..8372504636 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
@@ -34,7 +34,7 @@ public class CompilationUnit extends Openable implements ICompilationUnit, org.e
protected CompilationUnit(IPackageFragment parent, String name) {
super(COMPILATION_UNIT, parent, name);
if (!Util.isJavaFileName(name)) {
- throw new IllegalArgumentException(Util.bind("convention.unit.notJavaName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("convention.unit.notJavaName"/*nonNLS*/));
}
}
/**
@@ -77,7 +77,7 @@ public void commit(boolean force, IProgressMonitor monitor) throws JavaModelExce
*/
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements = new IJavaElement[] {this};
IJavaElement[] containers = new IJavaElement[] {container};
@@ -120,10 +120,10 @@ public IType createType(String content, IJavaElement sibling, boolean force, IPr
if (!exists()) {
//autogenerate this compilation unit
IPackageFragment pkg = (IPackageFragment) getParent();
- String source = ""; //$NON-NLS-1$
+ String source = ""/*nonNLS*/;
if (pkg.getElementName().length() > 0) {
//not the default package...add the package declaration
- source = "package " + pkg.getElementName() + ";" + JavaModelManager.LINE_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
+ source = "package "/*nonNLS*/ + pkg.getElementName() + ";"/*nonNLS*/ + JavaModelManager.LINE_SEPARATOR;
}
CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, fName, source, force);
runOperation(op, monitor);
@@ -173,7 +173,7 @@ protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
} else {
// iterate through all the types inside the receiver and see if one of them can fit
IType[] types = getTypes();
- String typeNodeName = nodeName.substring(0, nodeName.indexOf(".java")); //$NON-NLS-1$
+ String typeNodeName = nodeName.substring(0, nodeName.indexOf(".java"/*nonNLS*/));
for (int i = 0, max = types.length; i < max; i++) {
if (types[i].getElementName().equals(typeNodeName)) {
return true;
@@ -378,7 +378,7 @@ public ReferenceInfo getReferenceInfo() throws JavaModelException {
*/
public String getSource() throws JavaModelException {
IBuffer buffer = getBuffer();
- if (buffer == null) return ""; //$NON-NLS-1$
+ if (buffer == null) return ""/*nonNLS*/;
return buffer.getContents();
}
/**
@@ -470,7 +470,7 @@ public void makeConsistent(IProgressMonitor pm) throws JavaModelException {
*/
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] containers= new IJavaElement[] {container};
@@ -540,7 +540,7 @@ public IMarker[] reconcile() throws JavaModelException {
*/
public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullName"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] dests= new IJavaElement[] {this.getParent()};
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
index db6f62978d..acecc72b22 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
@@ -148,7 +148,7 @@ public void acceptConstructorReference(char[] typeName, int argCount, int source
addReference(ReferenceInfo.REFTYPE_call, name);
}
else {
- String name = "<" + new String(typeName) + ">/" + argCount; //$NON-NLS-2$ //$NON-NLS-1$
+ String name = "<"/*nonNLS*/ + new String(typeName) + ">/"/*nonNLS*/ + argCount;
addReference(ReferenceInfo.REFTYPE_call, name.toCharArray());
}
}
@@ -178,7 +178,7 @@ public void acceptImport(int declarationStart, int declarationEnd, char[] name,
// tack on the '.*' if it is onDemand
String importName;
if (onDemand) {
- importName= new String(name) + ".*"; //$NON-NLS-1$
+ importName= new String(name) + ".*"/*nonNLS*/;
} else {
importName= new String(name);
}
@@ -239,7 +239,7 @@ public void acceptMethodReference(char[] methodName, int argCount, int sourcePos
addReference(ReferenceInfo.REFTYPE_call, name);
}
else {
- String name = new String(methodName) + "/" + argCount; //$NON-NLS-1$
+ String name = new String(methodName) + "/"/*nonNLS*/ + argCount;
addReference(ReferenceInfo.REFTYPE_call, name.toCharArray());
}
}
@@ -559,13 +559,13 @@ protected void enterType(
if (fPackageName == null) {
qualifiedName= nameString.toCharArray();
} else {
- qualifiedName= (new String(fPackageName) + "." + nameString).toCharArray(); //$NON-NLS-1$
+ qualifiedName= (new String(fPackageName) + "."/*nonNLS*/ + nameString).toCharArray();
}
}
else if (parentHandle.getElementType() == IJavaElement.TYPE) {
handle = ((IType) parentHandle).getType(nameString);
enclosingTypeName= ((SourceTypeElementInfo)parentInfo).getName();
- qualifiedName= (new String(((SourceTypeElementInfo)parentInfo).getQualifiedName()) + "." + nameString).toCharArray(); //$NON-NLS-1$
+ qualifiedName= (new String(((SourceTypeElementInfo)parentInfo).getQualifiedName()) + "."/*nonNLS*/ + nameString).toCharArray();
}
else {
Assert.isTrue(false); // Should not happen
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
index 27c55071fd..8a3b8ec22f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
@@ -19,164 +19,138 @@ import java.io.*;
import java.util.*;
public class CompilationUnitVisitor extends Compiler {
-
- /**
- * Answer a new CompilationUnitVisitor using the given name environment and compiler options.
- * The environment and options will be in effect for the lifetime of the compiler.
- * When the compiler is run, compilation results are sent to the given requestor.
- *
- * @param environment org.eclipse.jdt.internal.compiler.api.env.INameEnvironment
- * Environment used by the compiler in order to resolve type and package
- * names. The name environment implements the actual connection of the compiler
- * to the outside world (e.g. in batch mode the name environment is performing
- * pure file accesses, reuse previous build state or connection to repositories).
- * Note: the name environment is responsible for implementing the actual classpath
- * rules.
- *
- * @param policy org.eclipse.jdt.internal.compiler.api.problem.IErrorHandlingPolicy
- * Configurable part for problem handling, allowing the compiler client to
- * specify the rules for handling problems (stop on first error or accumulate
- * them all) and at the same time perform some actions such as opening a dialog
- * in UI when compiling interactively.
- * @see org.eclipse.jdt.internal.compiler.api.problem.DefaultErrorHandlingPolicies
- *
- * @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
- * Component which will receive and persist all compilation results and is intended
- * to consume them as they are produced. Typically, in a batch compiler, it is
- * responsible for writing out the actual .class files to the file system.
- * @see org.eclipse.jdt.internal.compiler.api.CompilationResult
- *
- * @param problemFactory org.eclipse.jdt.internal.compiler.api.problem.IProblemFactory
- * Factory used inside the compiler to create problem descriptors. It allows the
- * compiler client to supply its own representation of compilation problems in
- * order to avoid object conversions. Note that the factory is not supposed
- * to accumulate the created problems, the compiler will gather them all and hand
- * them back as part of the compilation unit result.
- */
- public CompilationUnitVisitor(
- INameEnvironment environment,
- IErrorHandlingPolicy policy,
- ConfigurableOption[] settings,
- ICompilerRequestor requestor,
- IProblemFactory problemFactory) {
-
- super(environment, policy, settings, requestor, problemFactory);
+/**
+ * Answer a new CompilationUnitVisitor using the given name environment and compiler options.
+ * The environment and options will be in effect for the lifetime of the compiler.
+ * When the compiler is run, compilation results are sent to the given requestor.
+ *
+ * @param environment org.eclipse.jdt.internal.compiler.api.env.INameEnvironment
+ * Environment used by the compiler in order to resolve type and package
+ * names. The name environment implements the actual connection of the compiler
+ * to the outside world (e.g. in batch mode the name environment is performing
+ * pure file accesses, reuse previous build state or connection to repositories).
+ * Note: the name environment is responsible for implementing the actual classpath
+ * rules.
+ *
+ * @param policy org.eclipse.jdt.internal.compiler.api.problem.IErrorHandlingPolicy
+ * Configurable part for problem handling, allowing the compiler client to
+ * specify the rules for handling problems (stop on first error or accumulate
+ * them all) and at the same time perform some actions such as opening a dialog
+ * in UI when compiling interactively.
+ * @see org.eclipse.jdt.internal.compiler.api.problem.DefaultErrorHandlingPolicies
+ *
+ * @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
+ * Component which will receive and persist all compilation results and is intended
+ * to consume them as they are produced. Typically, in a batch compiler, it is
+ * responsible for writing out the actual .class files to the file system.
+ * @see org.eclipse.jdt.internal.compiler.api.CompilationResult
+ *
+ * @param problemFactory org.eclipse.jdt.internal.compiler.api.problem.IProblemFactory
+ * Factory used inside the compiler to create problem descriptors. It allows the
+ * compiler client to supply its own representation of compilation problems in
+ * order to avoid object conversions. Note that the factory is not supposed
+ * to accumulate the created problems, the compiler will gather them all and hand
+ * them back as part of the compilation unit result.
+ */
+public CompilationUnitVisitor(
+ INameEnvironment environment,
+ IErrorHandlingPolicy policy,
+ ConfigurableOption[] settings,
+ ICompilerRequestor requestor,
+ IProblemFactory problemFactory) {
+
+ super(environment, policy, settings, requestor, problemFactory);
+}
+/**
+ * Add an additional source type
+ */
+public void accept(ISourceType sourceType, PackageBinding packageBinding) {
+ CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1); // need to hold onto this
+ CompilationUnitDeclaration unit =
+ SourceTypeConverter.buildCompilationUnit(sourceType, true, true, lookupEnvironment.problemReporter, result);
+
+ if (unit != null) {
+ this.lookupEnvironment.buildTypeBindings(unit);
+ this.lookupEnvironment.completeTypeBindings(unit, true);
}
+}
+/*
+ * Low-level API performing the actual compilation
+ */
+protected static IErrorHandlingPolicy getHandlingPolicy() {
- /**
- * Add additional source types
- */
- public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
- CompilationResult result =
- new CompilationResult(sourceTypes[0].getFileName(), 1, 1);
- // need to hold onto this
- CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
- lookupEnvironment.problemReporter,
- result);
+ // passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match)
+ return new IErrorHandlingPolicy() {
+ public boolean stopOnFirstError() {
+ return false;
+ }
+ public boolean proceedOnErrors() {
+ return false; // stop if there are some errors
+ }
+ };
+}
+protected static INameEnvironment getNameEnvironment(ICompilationUnit sourceUnit) throws JavaModelException {
+ return (SearchableEnvironment) ((JavaProject) sourceUnit.getJavaProject())
+ .getSearchableNameEnvironment();
+}
+/*
+ * Low-level API performing the actual compilation
+ */
+protected static ConfigurableOption[] getOptions() {
+ CompilerOptions options = new CompilerOptions();
+ return options.getConfigurableOptions(Locale.getDefault());
+}
+/*
+ * Answer the component to which will be handed back compilation results from the compiler
+ */
+protected static ICompilerRequestor getRequestor() {
+ return new ICompilerRequestor() {
+ public void acceptResult(CompilationResult compilationResult) {
+ }
+ };
+}
+public static void visit(ICompilationUnit unitElement, IAbstractSyntaxTreeVisitor visitor) throws JavaModelException {
+
+ CompilationUnitVisitor compilationUnitVisitor = new CompilationUnitVisitor(
+ getNameEnvironment(unitElement),
+ getHandlingPolicy(),
+ getOptions(),
+ getRequestor(),
+ getProblemFactory(visitor));
+
+ CompilationUnitDeclaration unit = null;
+ try {
+ unit = compilationUnitVisitor.resolve(
+ new BasicCompilationUnit(
+ unitElement.getSource().toCharArray(),
+ unitElement.getElementName()));
if (unit != null) {
- this.lookupEnvironment.buildTypeBindings(unit);
- this.lookupEnvironment.completeTypeBindings(unit, true);
+ unit.traverse(visitor, unit.scope);
+ }
+ } finally {
+ if (unit != null) {
+ unit.cleanUp();
}
}
-
- /*
- * Low-level API performing the actual compilation
- */
- protected static IErrorHandlingPolicy getHandlingPolicy() {
-
- // passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match)
- return new IErrorHandlingPolicy() {
- public boolean stopOnFirstError() {
- return false;
- }
- public boolean proceedOnErrors() {
- return false; // stop if there are some errors
- }
- };
- }
-
- protected static INameEnvironment getNameEnvironment(ICompilationUnit sourceUnit)
- throws JavaModelException {
- return (SearchableEnvironment) ((JavaProject) sourceUnit.getJavaProject())
- .getSearchableNameEnvironment();
- }
-
- /*
- * Low-level API performing the actual compilation
- */
- protected static ConfigurableOption[] getOptions() {
- return JavaModelManager.getOptions();
- }
-
- /*
- * Answer the component to which will be handed back compilation results from the compiler
- */
- protected static ICompilerRequestor getRequestor() {
- return new ICompilerRequestor() {
- public void acceptResult(CompilationResult compilationResult) {
- }
- };
- }
-
- public static void visit(
- ICompilationUnit unitElement,
- IAbstractSyntaxTreeVisitor visitor)
- throws JavaModelException {
-
- CompilationUnitVisitor compilationUnitVisitor =
- new CompilationUnitVisitor(
- getNameEnvironment(unitElement),
- getHandlingPolicy(),
- getOptions(),
- getRequestor(),
- getProblemFactory(visitor));
-
- CompilationUnitDeclaration unit = null;
- try {
- unit =
- compilationUnitVisitor.resolve(
- new BasicCompilationUnit(
- unitElement.getSource().toCharArray(),
- unitElement.getElementName()));
- if (unit != null) {
- unit.traverse(visitor, unit.scope);
- }
- } finally {
- if (unit != null) {
- unit.cleanUp();
- }
+}
+
+protected static IProblemFactory getProblemFactory(final IAbstractSyntaxTreeVisitor visitor) {
+
+ return new DefaultProblemFactory(Locale.getDefault()){
+ public IProblem createProblem(char[] originatingFileName, int problemId, String[] arguments, int severity, int startPosition, int endPosition, int lineNumber) {
+
+ IProblem problem = super.createProblem(
+ originatingFileName,
+ problemId,
+ arguments,
+ severity,
+ startPosition,
+ endPosition,
+ lineNumber);
+ visitor.acceptProblem(problem);
+ return problem;
}
- }
-
- protected static IProblemFactory getProblemFactory(final IAbstractSyntaxTreeVisitor visitor) {
-
- return new DefaultProblemFactory(Locale.getDefault()) {
- public IProblem createProblem(
- char[] originatingFileName,
- int problemId,
- String[] arguments,
- int severity,
- int startPosition,
- int endPosition,
- int lineNumber) {
-
- IProblem problem =
- super.createProblem(
- originatingFileName,
- problemId,
- arguments,
- severity,
- startPosition,
- endPosition,
- lineNumber);
- visitor.acceptProblem(problem);
- return problem;
- }
- };
- }
-} \ No newline at end of file
+ };
+}
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
index 724206ef5b..4858baf980 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
@@ -68,7 +68,7 @@ public CopyElementsOperation(IJavaElement[] elementsToCopy, IJavaElement destCon
* for progress monitoring.
*/
protected String getMainTaskName() {
- return Util.bind("operation.copyElementProgress"); //$NON-NLS-1$
+ return Util.bind("operation.copyElementProgress"/*nonNLS*/);
}
/**
* Returns the nested operation to use for processing this element
@@ -83,7 +83,7 @@ protected JavaModelOperation getNestedOperation(IJavaElement element) {
return new CreateImportOperation(element.getElementName(), (ICompilationUnit) dest);
case IJavaElement.TYPE :
if (isRenamingMainType(element, dest)) {
- return new RenameResourceElementsOperation(new IJavaElement[] {dest}, new IJavaElement[] {dest.getParent()}, new String[]{getNewNameFor(element) + ".java"}, fForce); //$NON-NLS-1$
+ return new RenameResourceElementsOperation(new IJavaElement[] {dest}, new IJavaElement[] {dest.getParent()}, new String[]{getNewNameFor(element) + ".java"/*nonNLS*/}, fForce);
} else {
return new CreateTypeOperation(dest, getSourceFor(element) + JavaModelManager.LINE_SEPARATOR, fForce);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
index 4c4ae12c1c..3fe95cd814 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
@@ -159,7 +159,7 @@ private JavaElementDelta getDeltaFor(IJavaProject javaProject) {
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.copyResourceProgress"); //$NON-NLS-1$
+ return Util.bind("operation.copyResourceProgress"/*nonNLS*/);
}
/**
* Sets the deltas to register the changes resulting from this operation
@@ -342,7 +342,7 @@ private void processPackageFragmentResource(IPackageFragment source, IPackageFra
}
if (!newFrag.getElementName().equals(source.getElementName())) { // if package has been renamed, update the compilation units
for (int i = 0; i < resources.length; i++) {
- if (resources[i].getName().endsWith(".java")) { //$NON-NLS-1$
+ if (resources[i].getName().endsWith(".java"/*nonNLS*/)) {
// we only consider potential compilation units
ICompilationUnit cu = newFrag.getCompilationUnit(resources[i].getName());
IDOMCompilationUnit domCU = fFactory.createCompilationUnit(cu.getSource(), cu.getElementName());
@@ -428,7 +428,7 @@ private void updatePackageStatement(IDOMCompilationUnit domCU, String pkgName) t
if (!seenPackageNode && !defaultPackage) {
//the cu was in a default package...no package declaration
//create the new package declaration as the first child of the cu
- IDOMPackage pkg = fFactory.createPackage("package " + pkgName + ";" + JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ IDOMPackage pkg = fFactory.createPackage("package "/*nonNLS*/ + pkgName + ";"/*nonNLS*/ + JavaModelManager.LINE_SEPARATOR);
domCU.getFirstChild().insertSibling(pkg);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
index 8cf623a0e1..2a8ce5ffbe 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
@@ -54,7 +54,7 @@ public CreateCompilationUnitOperation(IPackageFragment parentElement, String nam
* @exception JavaModelException if unable to create the compilation unit.
*/
protected void executeOperation() throws JavaModelException {
- beginTask(Util.bind("operation.createUnitProgress"), 2); //$NON-NLS-1$
+ beginTask(Util.bind("operation.createUnitProgress"/*nonNLS*/), 2);
JavaElementDelta delta = newJavaElementDelta();
ICompilationUnit unit = getCompilationUnit();
IPackageFragment pkg = (IPackageFragment) getParentElement();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
index ff09cc85a8..79ab766ce7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
@@ -55,7 +55,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createFieldProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createFieldProgress"/*nonNLS*/);
}
/**
* By default the new field is positioned after the last existing field
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
index 9111d8d0a8..f40b1fb73a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
@@ -72,7 +72,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createImportsProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createImportsProgress"/*nonNLS*/);
}
/**
* Sets the correct position for the new import:<ul>
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
index b16e479082..436ee5ad48 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
@@ -78,7 +78,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createInitializerProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createInitializerProgress"/*nonNLS*/);
}
/**
* By default the new initializer is positioned after the last existing initializer
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
index 9ce66ac772..d99a852b86 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
@@ -79,7 +79,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createMethodProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createMethodProgress"/*nonNLS*/);
}
/**
* @see CreateTypeMemberOperation#verifyNameCollision
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
index 4d90298755..14fd9662ab 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
@@ -72,7 +72,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createPackageProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createPackageProgress"/*nonNLS*/);
}
/**
* Sets the correct position for new package declaration:<ul>
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
index 3be9920f1f..8e9c69ec77 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
@@ -54,9 +54,9 @@ protected void executeOperation() throws JavaModelException {
JavaElementDelta delta = newJavaElementDelta();
IPackageFragmentRoot root = (IPackageFragmentRoot) getParentElement();
String[] names = Signature.getSimpleNames(fName);
- beginTask(Util.bind("operation.createPackageFragmentProgress"), names.length); //$NON-NLS-1$
+ beginTask(Util.bind("operation.createPackageFragmentProgress"/*nonNLS*/), names.length);
IContainer parentFolder = (IContainer) root.getUnderlyingResource();
- String sideEffectPackageName = ""; //$NON-NLS-1$
+ String sideEffectPackageName = ""/*nonNLS*/;
Vector resultElements = new Vector(names.length);
int i;
for (i = 0; i < names.length; i++) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
index a0b02ced12..58e4d3c878 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
@@ -64,11 +64,11 @@ protected void generateNewCompilationUnitDOM(ICompilationUnit cu) throws JavaMod
protected IDOMNode generateSyntaxIncorrectDOM() throws JavaModelException {
//create some dummy source to generate a dom node
StringBuffer buff = new StringBuffer();
- buff.append(JavaModelManager.LINE_SEPARATOR + " public class A {" + JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buff.append(JavaModelManager.LINE_SEPARATOR + " public class A {"/*nonNLS*/ + JavaModelManager.LINE_SEPARATOR);
buff.append(fSource);
buff.append(JavaModelManager.LINE_SEPARATOR).append('}');
- IDOMCompilationUnit domCU = (new DOMFactory()).createCompilationUnit(buff.toString(), "A.java"); //$NON-NLS-1$
- IDOMNode node = (IDOMNode) domCU.getChild("A").getChildren().nextElement(); //$NON-NLS-1$
+ IDOMCompilationUnit domCU = (new DOMFactory()).createCompilationUnit(buff.toString(), "A.java"/*nonNLS*/);
+ IDOMNode node = (IDOMNode) domCU.getChild("A"/*nonNLS*/).getChildren().nextElement();
if (node != null) {
node.remove();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
index d3ac4f5a9f..9a1a08d0bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
@@ -58,7 +58,7 @@ protected IJavaElement generateResultHandle() {
* @see CreateElementInCUOperation#getMainTaskName
*/
public String getMainTaskName(){
- return Util.bind("operation.createTypeProgress"); //$NON-NLS-1$
+ return Util.bind("operation.createTypeProgress"/*nonNLS*/);
}
/**
* Returns the <code>IType</code> the member is to be created in.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
index 9b8474e228..1f1a2e7b71 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
@@ -60,7 +60,7 @@ protected void commitChanges(IDOMCompilationUnit cuDOM, ICompilationUnit cu) thr
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.deleteElementProgress"); //$NON-NLS-1$
+ return Util.bind("operation.deleteElementProgress"/*nonNLS*/);
}
/**
* Groups the elements to be processed by their compilation unit.
@@ -112,7 +112,7 @@ protected void processElement(IJavaElement element) throws JavaModelException {
if (e.exists()) {
IDOMNode node = ((JavaElement) e).findNode(cuDOM);
// TBD
- Assert.isTrue(node != null, Util.bind("element.cannotLocate", e.getElementName(), cuDOM.getName())); //$NON-NLS-1$
+ Assert.isTrue(node != null, Util.bind("element.cannotLocate"/*nonNLS*/, e.getElementName(), cuDOM.getName()));
node.remove();
delta.removed(e);
if (e.getElementType() == IJavaElement.IMPORT_DECLARATION) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
index 3bff201047..01cf6dbaf0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
@@ -87,7 +87,7 @@ private void deletePackageFragment(IPackageFragment frag)
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.deleteResourceProgress"); //$NON-NLS-1$
+ return Util.bind("operation.deleteResourceProgress"/*nonNLS*/);
}
/**
* @see MultiOperation. This method delegate to <code>deleteResource</code> or
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
index 1e25eb503c..5b36f6f281 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
@@ -314,7 +314,7 @@ protected Openable[] createElements(IResource resource) {
if (resource == null) return null;
String extension = resource.getFileExtension();
extension = extension == null ? null : extension.toLowerCase();
- if ("jar".equals(extension) || "zip".equals(extension)) { //$NON-NLS-2$ //$NON-NLS-1$
+ if ("jar"/*nonNLS*/.equals(extension) || "zip"/*nonNLS*/.equals(extension)) {
IJavaProject[] projects = null;
try {
projects = JavaModelManager.getJavaModel(resource.getWorkspace()).getJavaProjects();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
index c78edf90dd..99db352704 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.*;
*/
public class ImportContainer extends SourceRefElement implements IImportContainer {
protected ImportContainer(ICompilationUnit parent) {
- super(IMPORT_CONTAINER, parent, ""); //$NON-NLS-1$
+ super(IMPORT_CONTAINER, parent, ""/*nonNLS*/);
}
/**
* @see JavaElement#getHandleMemento()
@@ -25,7 +25,7 @@ public String getHandleMemento(){
* @see JavaElement#getHandleMemento()
*/
protected char getHandleMementoDelimiter() {
- Assert.isTrue(false, Util.bind("assert.shouldNotImplement")); //$NON-NLS-1$
+ Assert.isTrue(false, Util.bind("assert.shouldNotImplement"/*nonNLS*/));
return 0;
}
/**
@@ -65,7 +65,7 @@ protected void toString(int tab, StringBuffer buffer) {
if (info == null || !(info instanceof JavaElementInfo)) return;
IJavaElement[] children = ((JavaElementInfo)info).getChildren();
for (int i = 0; i < children.length; i++) {
- if (i > 0) buffer.append("\n"); //$NON-NLS-1$
+ if (i > 0) buffer.append("\n"/*nonNLS*/);
((JavaElement)children[i]).toString(tab, buffer);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
index bf4d453f20..bd6f12069c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
@@ -39,7 +39,7 @@ protected char getHandleMementoDelimiter() {
* Returns true if the import is on-demand (ends with ".*")
*/
public boolean isOnDemand() {
- return fName.endsWith(".*"); //$NON-NLS-1$
+ return fName.endsWith(".*"/*nonNLS*/);
}
/**
*/
@@ -51,10 +51,10 @@ public String readableName() {
* @private Debugging purposes
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
- buffer.append("import "); //$NON-NLS-1$
+ buffer.append("import "/*nonNLS*/);
buffer.append(getElementName());
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
index 9ac3a7dbc3..9bcbca58d5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
@@ -18,7 +18,7 @@ import org.eclipse.jdt.core.jdom.IDOMNode;
/* package */ class Initializer extends Member implements IInitializer {
protected Initializer(IType parent, int occurrenceCount) {
- super(INITIALIZER, parent, ""); //$NON-NLS-1$
+ super(INITIALIZER, parent, ""/*nonNLS*/);
// 0 is not valid: this first occurrence is occurrence 1.
if (occurrenceCount <= 0)
throw new IllegalArgumentException();
@@ -70,16 +70,16 @@ public void rename(String name, boolean force, IProgressMonitor monitor) throws
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (info == null) {
- buffer.append("<initializer>"); //$NON-NLS-1$
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append("<initializer>"/*nonNLS*/);
+ buffer.append(" (not open)"/*nonNLS*/);
} else {
try {
if (Flags.isStatic(this.getFlags())) {
- buffer.append("static "); //$NON-NLS-1$
+ buffer.append("static "/*nonNLS*/);
}
- buffer.append("initializer"); //$NON-NLS-1$
+ buffer.append("initializer"/*nonNLS*/);
} catch (JavaModelException e) {
- buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
+ buffer.append("<JavaModelException in toString of "/*nonNLS*/ + getElementName());
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
index 147314e3ed..72d09145f5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
@@ -62,6 +62,6 @@ public boolean isReadOnly() {
* @see IStorage#isReadOnly()
*/
public String toString() {
- return "JarEntryFile["+this.zipName+"::"+this.entryName+"]"; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ return "JarEntryFile["/*nonNLS*/+this.zipName+"::"/*nonNLS*/+this.entryName+"]"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
index 00a545db43..945ac02508 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
@@ -65,7 +65,7 @@ public class JarPackageFragmentRoot extends PackageFragmentRoot {
try {
verifyAttachSource(zipPath);
if (monitor != null) {
- monitor.beginTask(Util.bind("element.attachingSource"), 2); //$NON-NLS-1$
+ monitor.beginTask(Util.bind("element.attachingSource"/*nonNLS*/), 2);
}
SourceMapper mapper= null;
SourceMapper oldMapper= getSourceMapper();
@@ -377,14 +377,14 @@ public IClasspathEntry findSourceAttachmentRecommendation() {
Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
if (target instanceof IFile){
IFile file = (IFile) target;
- if ("jar".equalsIgnoreCase(file.getFileExtension()) || "zip".equalsIgnoreCase(file.getFileExtension())){ //$NON-NLS-2$ //$NON-NLS-1$
+ if ("jar"/*nonNLS*/.equalsIgnoreCase(file.getFileExtension()) || "zip"/*nonNLS*/.equalsIgnoreCase(file.getFileExtension())){
return entry;
}
}
if (target instanceof java.io.File){
java.io.File file = (java.io.File) target;
String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
+ if (Util.endsWithIgnoreCase(name, ".jar"/*nonNLS*/) || Util.endsWithIgnoreCase(name, ".zip"/*nonNLS*/)){
return entry;
}
}
@@ -405,14 +405,14 @@ public IClasspathEntry findSourceAttachmentRecommendation() {
if (target instanceof IFile){
IFile file = (IFile) target;
String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
+ if (Util.endsWithIgnoreCase(name, ".jar"/*nonNLS*/) || Util.endsWithIgnoreCase(name, ".zip"/*nonNLS*/)){
return entry;
}
}
if (target instanceof java.io.File){
java.io.File file = (java.io.File) target;
String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
+ if (Util.endsWithIgnoreCase(name, ".jar"/*nonNLS*/) || Util.endsWithIgnoreCase(name, ".zip"/*nonNLS*/)){
return entry;
}
}
@@ -503,7 +503,7 @@ public IClasspathEntry findSourceAttachmentRecommendation() {
if (recommendation != null){
propertyString = recommendation.getSourceAttachmentPath().toString()
+ ATTACHMENT_PROPERTY_DELIMITER
- + (recommendation.getSourceAttachmentRootPath() == null ? "" : recommendation.getSourceAttachmentRootPath().toString()); //$NON-NLS-1$
+ + (recommendation.getSourceAttachmentRootPath() == null ? ""/*nonNLS*/ : recommendation.getSourceAttachmentRootPath().toString());
getWorkspace().getRoot().setPersistentProperty(qName, propertyString);
}
}
@@ -520,7 +520,7 @@ public IClasspathEntry findSourceAttachmentRecommendation() {
ZipFile jarFile = null;
try {
jarFile = getJar();
- return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + jarFile.getName()); //$NON-NLS-1$
+ return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: "/*nonNLS*/ + jarFile.getName());
} catch (CoreException e) {
throw new JavaModelException(e);
} finally {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
index bc883d4625..286bcd3f32 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
@@ -77,7 +77,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement
*/
protected JavaElement(int type, IJavaElement parent, String name) throws IllegalArgumentException {
if (type < JAVA_MODEL || type > IMPORT_DECLARATION) {
- throw new IllegalArgumentException(Util.bind("element.invalidType")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.invalidType"/*nonNLS*/));
}
fLEType= type;
fParent= parent;
@@ -254,7 +254,7 @@ public ICompilationUnit getCompilationUnit() {
*
* @exception JavaModelException if the element is not present or not accessible
*/
-public JavaElementInfo getElementInfo() throws JavaModelException {
+protected JavaElementInfo getElementInfo() throws JavaModelException {
synchronized(fgJavaModelManager){
Object info = fgJavaModelManager.getInfo(this);
if (info == null) {
@@ -516,7 +516,7 @@ protected void setOccurrenceCount(int count) {
protected String tabString(int tab) {
StringBuffer buffer = new StringBuffer();
for (int i = tab; i > 0; i--)
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
return buffer.toString();
}
/**
@@ -554,11 +554,11 @@ protected void toString(int tab, StringBuffer buffer) {
protected void toStringAncestors(StringBuffer buffer) {
JavaElement parent = (JavaElement)this.getParent();
if (parent != null) {
- buffer.append(" [in "); //$NON-NLS-1$
+ buffer.append(" [in "/*nonNLS*/);
Object parentInfo = fgJavaModelManager.getInfo(parent);
parent.toStringInfo(0, buffer, parentInfo);
parent.toStringAncestors(buffer);
- buffer.append("]"); //$NON-NLS-1$
+ buffer.append("]"/*nonNLS*/);
}
}
/**
@@ -568,7 +568,7 @@ protected void toStringChildren(int tab, StringBuffer buffer, Object info) {
if (info == null || !(info instanceof JavaElementInfo)) return;
IJavaElement[] children = ((JavaElementInfo)info).getChildren();
for (int i = 0; i < children.length; i++) {
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
((JavaElement)children[i]).toString(tab + 1, buffer);
}
}
@@ -578,7 +578,7 @@ protected void toStringChildren(int tab, StringBuffer buffer, Object info) {
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
buffer.append(getElementName());
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
}
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
index 4722567ab2..35fd0e08dc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
@@ -477,7 +477,7 @@ public String toDebugString(int depth) {
buffer.append('\t');
}
buffer.append(((JavaElement)getElement()).toDebugString());
- buffer.append("["); //$NON-NLS-1$
+ buffer.append("["/*nonNLS*/);
switch (getKind()) {
case IJavaElementDelta.ADDED :
buffer.append('+');
@@ -492,68 +492,68 @@ public String toDebugString(int depth) {
buffer.append('?');
break;
}
- buffer.append("]: {"); //$NON-NLS-1$
+ buffer.append("]: {"/*nonNLS*/);
int changeFlags = getFlags();
boolean prev = false;
if ((changeFlags & IJavaElementDelta.F_CHILDREN) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("CHILDREN"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("CHILDREN"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_CONTENT) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("CONTENT"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("CONTENT"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_MOVED_FROM) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("MOVED_FROM(" + ((JavaElement)getMovedFromElement()).toDebugString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("MOVED_FROM("/*nonNLS*/ + ((JavaElement)getMovedFromElement()).toDebugString() + ")"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_MOVED_TO) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("MOVED_TO(" + ((JavaElement)getMovedToElement()).toDebugString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("MOVED_TO("/*nonNLS*/ + ((JavaElement)getMovedToElement()).toDebugString() + ")"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("ADDED TO CLASSPATH"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("ADDED TO CLASSPATH"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("REMOVED FROM CLASSPATH"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("REMOVED FROM CLASSPATH"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_CLASSPATH_REORDER) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("REORDERED IN CLASSPATH"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("REORDERED IN CLASSPATH"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_MODIFIERS) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("MODIFIERS CHANGED"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("MODIFIERS CHANGED"/*nonNLS*/);
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_SUPER_TYPES) != 0) {
if (prev)
- buffer.append(" | "); //$NON-NLS-1$
- buffer.append("SUPER TYPES CHANGED"); //$NON-NLS-1$
+ buffer.append(" | "/*nonNLS*/);
+ buffer.append("SUPER TYPES CHANGED"/*nonNLS*/);
prev = true;
}
- buffer.append("}"); //$NON-NLS-1$
+ buffer.append("}"/*nonNLS*/);
IJavaElementDelta[] children = getAffectedChildren();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
buffer.append(((JavaElementDelta) children[i]).toDebugString(depth + 1));
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
index d9621d5d84..3a9be1d0d8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
@@ -422,7 +422,7 @@ private void removeElementInfo(IJavaElement element) {
}
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("Built delta:\n"); //$NON-NLS-1$
+ buffer.append("Built delta:\n"/*nonNLS*/);
buffer.append(this.delta.toString());
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
index 37685b6849..a359be8acc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
@@ -35,7 +35,7 @@ public class JavaModel extends Openable implements IJavaModel {
* @exception Error if called more than once
*/
protected JavaModel(IWorkspace workspace) throws Error {
- super(JAVA_MODEL, null, "" /*workspace has empty name*/); //$NON-NLS-1$
+ super(JAVA_MODEL, null, ""/*nonNLS*/ /*workspace has empty name*/);
this.workspace = workspace;
}
private void cleanupCycleMarkers() {
@@ -102,9 +102,10 @@ protected int computeDepth(String projectName, StringHashtableOfInt depthTable,
if (generateMarkerOnError) {
try {
IMarker marker = this.workspace.getRoot().getProject(dependentProjectName).createMarker(IJavaModelMarker.TRANSIENT_PROBLEM);
- marker.setAttributes(
- new String[]{ IMarker.MESSAGE, IMarker.PRIORITY, IMarker.LOCATION, IJavaModelMarker.CYCLE_DETECTED},
- new Object[]{ Util.bind("classpath.cycle"), new Integer(IMarker.PRIORITY_HIGH), dependentProjectName, dependentProjectName}); //$NON-NLS-1$
+ marker.setAttribute(IMarker.MESSAGE, Util.bind("classpath.cycle"/*nonNLS*/));
+ marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
+ marker.setAttribute(IMarker.LOCATION, dependentProjectName);
+ marker.setAttribute(IJavaModelMarker.CYCLE_DETECTED, dependentProjectName);
} catch (CoreException e) {
e.printStackTrace();
}
@@ -373,7 +374,7 @@ public String getHandleMemento(){
* contribution to a memento.
*/
protected char getHandleMementoDelimiter(){
- Assert.isTrue(false, Util.bind("assert.shouldNotImplement")); //$NON-NLS-1$
+ Assert.isTrue(false, Util.bind("assert.shouldNotImplement"/*nonNLS*/));
return 0;
}
/**
@@ -410,7 +411,7 @@ public IJavaProject getJavaProject(IResource resource) {
} else if (resource.getType() == IResource.PROJECT) {
return new JavaProject((IProject)resource, this);
} else {
- throw new IllegalArgumentException(Util.bind("element.invalidResourceForProject")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.invalidResourceForProject"/*nonNLS*/));
}
}
/**
@@ -480,9 +481,9 @@ protected void runOperation(MultiOperation op, IJavaElement[] elements, IJavaEle
* @private Debugging purposes
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
- buffer.append("Java Model"); //$NON-NLS-1$
+ buffer.append("Java Model"/*nonNLS*/);
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 480efcba7f..7a88eb0ed6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -39,15 +39,6 @@ import org.eclipse.jdt.internal.core.builder.NotPresentException;
* the static method <code>JavaModelManager.getJavaModelManager()</code>.
*/
public class JavaModelManager implements IResourceChangeListener, ISaveParticipant {
- /**
- * JavaCore options (don't use this field to add an new option,
- * use JavaModelManager#addOption method.
- */
- public static Hashtable fOptions;
- /**
- * JavaCore options IDs
- */
- private static ArrayList fOptionIDs;
/**
* The singleton manager
@@ -102,12 +93,12 @@ public class JavaModelManager implements IResourceChangeListener, ISaveParticipa
/**
* Local Java workspace properties file name (generated inside JavaCore plugin state location)
*/
- private static final String WKS_PROP_FILENAME= "workspace.properties"; //$NON-NLS-1$
+ private static final String WKS_PROP_FILENAME= "workspace.properties"/*nonNLS*/;
/**
* Name of the handle id attribute in a Java marker
*/
- private static final String ATT_HANDLE_ID= "org.eclipse.jdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
+ private static final String ATT_HANDLE_ID= "org.eclipse.jdt.internal.core.JavaModelManager.handleId"/*nonNLS*/;
/**
* Table from IProject to PerProjectInfo.
@@ -138,7 +129,7 @@ public class JavaModelManager implements IResourceChangeListener, ISaveParticipa
/**
* Line separator to use throughout the JavaModel for any source edit operation
*/
- public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
+ public static String LINE_SEPARATOR = System.getProperty("line.separator"/*nonNLS*/);
/**
* Constructs a new JavaModelManager
*/
@@ -177,7 +168,212 @@ public void checkProjectBeingAdded(IResourceDelta delta) {
public void closeAffectedElements(IResourceDelta delta) {
fDeltaProcessor.closeAffectedElements(delta);
}
+/**
+ * Convert options Map into ConfigurableOption understood by the infrastructure
+ *
+ * Should be revisited
+ */
+public static ConfigurableOption[] convertConfigurableOptions(Hashtable optionMap) {
+
+ Enumeration optionNames = optionMap.keys();
+ CompilerOptions compilerOptions = new CompilerOptions();
+ int index = 0;
+
+ while (optionNames.hasMoreElements()){
+
+ String optionName = (String)optionNames.nextElement();
+ String optionValue = (String)optionMap.get(optionName);
+
+ if (optionName.equals(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR)){
+
+ if (optionValue.equals(JavaCore.GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() | CompilerOptions.Vars);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.DO_NOT_GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() & ~CompilerOptions.Vars);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_LINE_NUMBER_ATTR)){
+
+ if (optionValue.equals(JavaCore.GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() | CompilerOptions.Lines);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.DO_NOT_GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() & ~CompilerOptions.Lines);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_SOURCE_FILE_ATTR)){
+
+ if (optionValue.equals(JavaCore.GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() | CompilerOptions.Source);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.DO_NOT_GENERATE)){
+ compilerOptions.produceDebugAttributes(
+ compilerOptions.getDebugAttributesMask() & ~CompilerOptions.Source);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL)){
+ if (optionValue.equals(JavaCore.PRESERVE)){
+ compilerOptions.preserveAllLocalVariables(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.OPTIMIZE_OUT)){
+ compilerOptions.preserveAllLocalVariables(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)){
+
+ if (optionValue.equals(JavaCore.VERSION_1_1)){
+ compilerOptions.setTargetJDK(CompilerOptions.JDK1_1);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.VERSION_1_2)){
+ compilerOptions.setTargetJDK(CompilerOptions.JDK1_2);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_UNREACHABLE_CODE)){
+
+ if (optionValue.equals(JavaCore.ERROR)){
+ compilerOptions.handleUnreachableCodeAsError(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleUnreachableCodeAsError(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_INVALID_IMPORT)){
+
+ if (optionValue.equals(JavaCore.ERROR)){
+ compilerOptions.handleImportProblemAsError(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleImportProblemAsError(false);
+ continue;
+ }
+ continue;
+ }
+
+ if (optionName.equals(JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleOverriddenPackageDefaultMethodAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleOverriddenPackageDefaultMethodAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleMethodWithConstructorNameAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleMethodWithConstructorNameAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_DEPRECATION)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleDeprecationUseAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleDeprecationUseAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleMaskedCatchBlockAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleMaskedCatchBlockAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_UNUSED_LOCAL)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleUnusedLocalVariableAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleUnusedLocalVariableAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_UNUSED_PARAMETER)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleUnusedArgumentAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleUnusedArgumentAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleAccessEmulationAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleAccessEmulationAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ if (optionName.equals(JavaCore.COMPILER_PB_NON_EXTERNALIZED_STRING_LITERAL)){
+
+ if (optionValue.equals(JavaCore.WARNING)){
+ compilerOptions.handleNonExternalizedStringLiteralAsWarning(true);
+ continue;
+ }
+ if (optionValue.equals(JavaCore.IGNORE)){
+ compilerOptions.handleNonExternalizedStringLiteralAsWarning(false);
+ continue;
+ }
+ continue;
+ }
+ }
+ return compilerOptions.getConfigurableOptions(Locale.getDefault());
+}
/**
* Note that the project is now deleted.
*
@@ -287,7 +483,7 @@ public void doneSaving(ISaveContext context){
return null;
}
JavaModel model= (JavaModel) getJavaModel(workspace);
- if (memento.equals("")){ // workspace memento //$NON-NLS-1$
+ if (memento.equals(""/*nonNLS*/)){ // workspace memento
return model;
}
int modelEnd= memento.indexOf(JavaElement.JEM_JAVAPROJECT);
@@ -388,7 +584,7 @@ public void doneSaving(ISaveContext context){
try {
modelInfo.fJavaModel.close();
} catch (JavaModelException e) {
- Assert.isTrue(false, Util.bind("element.onlyOneJavaModel")); //$NON-NLS-1$
+ Assert.isTrue(false, Util.bind("element.onlyOneJavaModel"/*nonNLS*/));
return null;
}
}
@@ -396,7 +592,7 @@ public void doneSaving(ISaveContext context){
if (modelInfo == null || modelInfo.workspace.equals(workspace)) {
return new JavaModel(workspace);
} else {
- Assert.isTrue(false, Util.bind("element.onlyOneJavaModel")); //$NON-NLS-1$
+ Assert.isTrue(false, Util.bind("element.onlyOneJavaModel"/*nonNLS*/));
return null;
}
@@ -422,7 +618,7 @@ public void doneSaving(ISaveContext context){
if (state == null && JavaBuilder.SAVE_ENABLED && !info.triedRead) {
info.triedRead= true;
try {
- if (monitor != null) monitor.subTask(Util.bind("build.readStateProgress", project.getName())); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(Util.bind("build.readStateProgress"/*nonNLS*/, project.getName()));
state= readState(info);
info.setLastBuiltState(state);
} catch (CoreException e) {
@@ -467,12 +663,12 @@ public void doneSaving(ISaveContext context){
if (!project.exists()) return null;
IPluginDescriptor descr= JavaCore.getJavaCore().getDescriptor();
IPath workingLocation= project.getPluginWorkingLocation(descr);
- return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$
+ return workingLocation.append("state.dat"/*nonNLS*/).toFile();
}
public String getVariablesAsXMLString() throws CoreException {
Document document = new DocumentImpl();
- Element rootElement = document.createElement("variables"); //$NON-NLS-1$
+ Element rootElement = document.createElement("variables"/*nonNLS*/);
document.appendChild(rootElement);
String[] variables = JavaCore.getClasspathVariableNames();
@@ -480,9 +676,9 @@ public void doneSaving(ISaveContext context){
for (int i= 0; i < variables.length; ++i) {
String var = variables[i];
IPath varPath = JavaCore.getClasspathVariable(var);
- Element varElement= document.createElement("variable"); //$NON-NLS-1$
- varElement.setAttribute("name", var); //$NON-NLS-1$
- varElement.setAttribute("path", varPath.toString()); //$NON-NLS-1$
+ Element varElement= document.createElement("variable"/*nonNLS*/);
+ varElement.setAttribute("name"/*nonNLS*/, var);
+ varElement.setAttribute("path"/*nonNLS*/, varPath.toString());
rootElement.appendChild(varElement);
}
@@ -499,42 +695,6 @@ public void doneSaving(ISaveContext context){
return writer.toString();
}
-
- public String getOptionsAsXMLString() throws CoreException {
-
- Document document = new DocumentImpl();
- Element rootElement = document.createElement("options"); //$NON-NLS-1$
- document.appendChild(rootElement);
-
- String[] ids = JavaCore.getOptionIDs();
-
- for (int i= 0; i < ids.length; ++i) {
- ConfigurableOption option = (ConfigurableOption)fOptions.get(ids[i]);
-
- Element optionElement= document.createElement("option"); //$NON-NLS-1$
- optionElement.setAttribute("id", ids[i]); //$NON-NLS-1$
- if(option.getPossibleValues() == ConfigurableOption.NoDiscreteValue){
- optionElement.setAttribute("value", option.getValue()); //$NON-NLS-1$
- }
- else{
- optionElement.setAttribute("index", String.valueOf(option.getValueIndex())); //$NON-NLS-1$
- }
- rootElement.appendChild(optionElement);
- }
-
- // produce a String output
- StringWriter writer = new StringWriter();
- try {
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- Serializer serializer = SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(writer, format);
- serializer.asDOMSerializer().serialize(document);
- } catch (IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- }
- return writer.toString();
-
- }
/**
* Returns the open ZipFile at the given location. If the ZipFile
* does not yet exist, it is created, opened, and added to the cache
@@ -560,7 +720,7 @@ public void doneSaving(ISaveContext context){
} else if (!path.isAbsolute()) {
file= root.getFile(path);
if (file == null || file.getType() != IResource.FILE) {
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("file.notFound"), null)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("file.notFound"/*nonNLS*/), null));
}
ensureLocal(file);
fileSystemPath= file.getLocation().toOSString();
@@ -571,7 +731,7 @@ public void doneSaving(ISaveContext context){
try {
return new ZipFile(fileSystemPath);
} catch (IOException e) {
- throw new CoreException(new Status(Status.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("status.IOException"), e)); //$NON-NLS-1$
+ throw new CoreException(new Status(Status.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("status.IOException"/*nonNLS*/), e));
}
}
/**
@@ -591,23 +751,13 @@ public void doneSaving(ISaveContext context){
public void loadVariables() throws CoreException {
String xmlString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(
- new QualifiedName(JavaCore.PLUGIN_ID, "variables")); //$NON-NLS-1$
+ new QualifiedName(JavaCore.PLUGIN_ID, "variables"/*nonNLS*/));
try {
if (xmlString != null) readVariables(xmlString);
} catch(IOException e){
return;
}
}
-
- public void loadOptions() throws CoreException {
- String xmlString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(
- new QualifiedName(JavaCore.PLUGIN_ID, "options")); //$NON-NLS-1$
- try {
- if (xmlString != null) readOptions(xmlString);
- } catch(IOException e){
- return;
- }
- }
/**
* Merged all awaiting deltas.
*/
@@ -696,13 +846,13 @@ public void prepareToSave(ISaveContext context) throws CoreException {
try {
String pluginID= in.readUTF();
if (!pluginID.equals(JavaCore.PLUGIN_ID))
- throw new IOException(Util.bind("build.wrongFileFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("build.wrongFileFormat"/*nonNLS*/));
String kind= in.readUTF();
- if (!kind.equals("STATE")) //$NON-NLS-1$
- throw new IOException(Util.bind("build.wrongFileFormat")); //$NON-NLS-1$
+ if (!kind.equals("STATE"/*nonNLS*/))
+ throw new IOException(Util.bind("build.wrongFileFormat"/*nonNLS*/));
int version= in.readInt();
if (version != 0x0001)
- throw new IOException(Util.bind("build.unhandledVersionFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("build.unhandledVersionFormat"/*nonNLS*/));
boolean hasState= in.readBoolean();
IState state= null;
if (hasState) {
@@ -726,15 +876,15 @@ public void prepareToSave(ISaveContext context) throws CoreException {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
cpElement = parser.parse(new InputSource(reader)).getDocumentElement();
} catch(SAXException e) {
- return;
+ throw new IOException(Util.bind("variable.badFormat"/*nonNLS*/));
} catch(ParserConfigurationException e){
- return;
+ reader.close();
+ throw new IOException(Util.bind("variable.badFormat"/*nonNLS*/));
} finally {
reader.close();
}
- if (cpElement == null) return;
- if (!cpElement.getNodeName().equalsIgnoreCase("variables")) { //$NON-NLS-1$
- return;
+ if (!cpElement.getNodeName().equalsIgnoreCase("variables"/*nonNLS*/)) {
+ throw new IOException(Util.bind("variable.badFormat"/*nonNLS*/));
}
NodeList list= cpElement.getChildNodes();
Vector variables = new Vector();
@@ -744,9 +894,9 @@ public void prepareToSave(ISaveContext context) throws CoreException {
short type= node.getNodeType();
if (type == Node.ELEMENT_NODE) {
Element element= (Element) node;
- if (element.getNodeName().equalsIgnoreCase("variable")) { //$NON-NLS-1$
- String varName = element.getAttribute("name"); //$NON-NLS-1$
- String varPath = element.getAttribute("path"); //$NON-NLS-1$
+ if (element.getNodeName().equalsIgnoreCase("variable"/*nonNLS*/)) {
+ String varName = element.getAttribute("name"/*nonNLS*/);
+ String varPath = element.getAttribute("path"/*nonNLS*/);
try {
JavaCore.setClasspathVariable(varName, new Path(varPath), null);
} catch(JavaModelException e){
@@ -756,57 +906,7 @@ public void prepareToSave(ISaveContext context) throws CoreException {
}
}
- }
-
- public void readOptions(String xmlString) throws IOException {
- if(fOptions == null)
- JavaCore.resetOptions();
-
- StringReader reader = new StringReader(xmlString);
- Element cpElement;
- try {
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- cpElement = parser.parse(new InputSource(reader)).getDocumentElement();
- } catch(SAXException e) {
- return;
- } catch(ParserConfigurationException e){
- return;
- } finally {
- reader.close();
- }
- if (cpElement == null) return;
- if (!cpElement.getNodeName().equalsIgnoreCase("options")) { //$NON-NLS-1$
- return;
- }
- NodeList list= cpElement.getChildNodes();
- int length= list.getLength();
- for (int i= 0; i < length; ++i) {
- Node node= list.item(i);
- short type= node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element element= (Element) node;
- if (element.getNodeName().equalsIgnoreCase("option")) { //$NON-NLS-1$
- String id = element.getAttribute("id"); //$NON-NLS-1$
- ConfigurableOption option = (ConfigurableOption) fOptions.get(id);
-
- String[] possible = option.getPossibleValues();
- if(possible == ConfigurableOption.NoDiscreteValue){
- String value = element.getAttribute("value"); //$NON-NLS-1$
- option.setValue(value);
- }
- else {
- try {
- int valueIndex = Integer.parseInt(element.getAttribute("index")); //$NON-NLS-1$
- option.setValueIndex(valueIndex);
- } catch(NumberFormatException e){
- }
- }
-
- }
-
- }
- }
- }
+ }
/**
* Registers the given delta with this manager. This API is to be
* used to registerd deltas that are created explicitly by the Java
@@ -957,7 +1057,7 @@ public void rollback(ISaveContext context){
if (vStats != null) {
IStatus[] stats= new IStatus[vStats.size()];
vStats.copyInto(stats);
- throw new CoreException(new MultiStatus(JavaCore.PLUGIN_ID, IStatus.ERROR, stats, Util.bind("build.cannotSaveStates"), null)); //$NON-NLS-1$
+ throw new CoreException(new MultiStatus(JavaCore.PLUGIN_ID, IStatus.ERROR, stats, Util.bind("build.cannotSaveStates"/*nonNLS*/), null));
}
}
/**
@@ -965,7 +1065,7 @@ public void rollback(ISaveContext context){
*/
private void saveState(PerProjectInfo info) throws CoreException {
- if (VERBOSE) System.out.println(Util.bind("build.saveStateProgress", info.project.getName())); //$NON-NLS-1$
+ if (VERBOSE) System.out.println(Util.bind("build.saveStateProgress"/*nonNLS*/, info.project.getName()));
long t= System.currentTimeMillis();
File file= getSerializationFile(info.project);
if (file == null) return;
@@ -973,7 +1073,7 @@ public void rollback(ISaveContext context){
DataOutputStream out= new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
try {
out.writeUTF(JavaCore.PLUGIN_ID);
- out.writeUTF("STATE"); //$NON-NLS-1$
+ out.writeUTF("STATE"/*nonNLS*/);
out.writeInt(0x0001);
IState state= info.getLastBuiltState();
if (state == null) {
@@ -990,16 +1090,16 @@ public void rollback(ISaveContext context){
file.delete();
} catch(SecurityException se){
}
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("build.cannotSaveState", info.project.getName()), e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("build.cannotSaveState"/*nonNLS*/, info.project.getName()), e));
} catch (IOException e) {
try {
file.delete();
} catch(SecurityException se){
}
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("build.cannotSaveState", info.project.getName()), e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("build.cannotSaveState"/*nonNLS*/, info.project.getName()), e));
}
t= System.currentTimeMillis() - t;
- if (VERBOSE) System.out.println(Util.bind("build.saveStateComplete", String.valueOf(t))); //$NON-NLS-1$
+ if (VERBOSE) System.out.println(Util.bind("build.saveStateComplete"/*nonNLS*/, String.valueOf(t)));
}
/**
* Saves the built state for the project if it has been changed since last save.
@@ -1019,22 +1119,15 @@ public void rollback(ISaveContext context){
}
public void saveVariables() throws CoreException {
ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(
- new QualifiedName(JavaCore.PLUGIN_ID, "variables"), //$NON-NLS-1$
+ new QualifiedName(JavaCore.PLUGIN_ID, "variables"/*nonNLS*/),
getVariablesAsXMLString());
}
-
- public void saveOptions() throws CoreException {
- ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(
- new QualifiedName(JavaCore.PLUGIN_ID, "options"), //$NON-NLS-1$
- getOptionsAsXMLString());
- }
/**
* @see ISaveParticipant
*/
public void saving(ISaveContext context) throws CoreException {
this.saveVariables();
- this.saveOptions();
if (context.getKind() == ISaveContext.FULL_SAVE){
this.saveBuildState(); // build state
@@ -1047,9 +1140,8 @@ public void saving(ISaveContext context) throws CoreException {
protected void setBuildOrder(String[] javaBuildOrder) throws JavaModelException {
// optional behaviour
- // possible value of index 0 is Compute
- if (!JavaCore.getOptionPossibleValues(JavaCore.OPTION_ComputeBuildOrder)[0].equals(JavaCore.getOptionValue(JavaCore.OPTION_ComputeBuildOrder))) return;
-
+ if (!JavaCore.COMPUTE.equals(JavaCore.getOptions().get(JavaCore.CORE_JAVA_BUILD_ORDER))) return;
+
if (javaBuildOrder == null || javaBuildOrder.length <= 1) return;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -1129,38 +1221,4 @@ public void saving(ISaveContext context) throws CoreException {
public void stopDeltas() {
fFire= false;
}
-
- /**
- * Answers a copy of the current set of options supported by the Java core.
- * These options allow to configure the behavior of the underlying components.
- *
- * Changes on the set of options are not committed until invoking <code>JavaCore.setOptionValue</code>
- */
- public static ConfigurableOption[] getOptions(){
- if(fOptions == null)
- JavaCore.resetOptions();
-
- return (ConfigurableOption[])fOptions.values().toArray(new ConfigurableOption[0]);
- }
-
- /**
- * Answers a set of option'IDs which are in option set of JavaCore
- */
- public static String[] getOptionIDs(){
- if(fOptionIDs == null)
- JavaCore.resetOptions();
-
- return (String [])fOptionIDs.toArray(new String[0]);
- }
-
- public static void initializeOptions(){
- fOptions = new Hashtable(10);
- fOptionIDs = new ArrayList(10);
- }
-
- public static void addOption(ConfigurableOption option){
- String id = option.getID();
- fOptions.put(id,option);
- fOptionIDs.add(id);
- }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
index ea18ad69d2..822686bbcd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
@@ -135,7 +135,7 @@ public void beginTask(String name, int totalWork) {
*/
protected void checkCanceled() {
if (isCanceled()) {
- throw new OperationCanceledException(Util.bind("operation.cancelled")); //$NON-NLS-1$
+ throw new OperationCanceledException(Util.bind("operation.cancelled"/*nonNLS*/));
}
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
index b63aa41778..c868e21682 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
@@ -52,13 +52,13 @@ public class JavaModelStatus extends Status implements IJavaModelStatus, IJavaMo
*/
public JavaModelStatus() {
// no code for an multi-status
- super(ERROR, JavaCore.PLUGIN_ID, 0, "JavaModelStatus", null); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, 0, "JavaModelStatus"/*nonNLS*/, null);
}
/**
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(int code) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus"/*nonNLS*/, null);
fElements= JavaElementInfo.fgEmptyChildren;
}
/**
@@ -66,7 +66,7 @@ public JavaModelStatus(int code) {
* elements.
*/
public JavaModelStatus(int code, IJavaElement[] elements) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus"/*nonNLS*/, null);
fElements= elements;
fPath= null;
}
@@ -74,7 +74,7 @@ public JavaModelStatus(int code, IJavaElement[] elements) {
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(int code, String string) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus"/*nonNLS*/, null);
fElements= JavaElementInfo.fgEmptyChildren;
fPath= null;
fString = string;
@@ -83,14 +83,14 @@ public JavaModelStatus(int code, String string) {
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(int code, Throwable throwable) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", throwable); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus"/*nonNLS*/, throwable);
fElements= JavaElementInfo.fgEmptyChildren;
}
/**
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(int code, IPath path) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus"/*nonNLS*/, null);
fElements= JavaElementInfo.fgEmptyChildren;
fPath= path;
}
@@ -113,7 +113,7 @@ public JavaModelStatus(int code, IJavaElement element, String string) {
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(CoreException coreException) {
- super(ERROR, JavaCore.PLUGIN_ID, CORE_EXCEPTION, "JavaModelStatus", coreException); //$NON-NLS-1$
+ super(ERROR, JavaCore.PLUGIN_ID, CORE_EXCEPTION, "JavaModelStatus"/*nonNLS*/, coreException);
fElements= JavaElementInfo.fgEmptyChildren;
}
protected int getBits() {
@@ -140,89 +140,89 @@ public String getMessage() {
if (getException() == null) {
switch (getCode()) {
case CORE_EXCEPTION :
- return Util.bind("status.coreException"); //$NON-NLS-1$
+ return Util.bind("status.coreException"/*nonNLS*/);
case BUILDER_INITIALIZATION_ERROR:
- return Util.bind("build.initializationError"); //$NON-NLS-1$
+ return Util.bind("build.initializationError"/*nonNLS*/);
case BUILDER_SERIALIZATION_ERROR:
- return Util.bind("build.serializationError"); //$NON-NLS-1$
+ return Util.bind("build.serializationError"/*nonNLS*/);
case DEVICE_PATH:
- return Util.bind("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
+ return Util.bind("status.cannotUseDeviceOnPath"/*nonNLS*/, getPath().toString());
case DOM_EXCEPTION:
- return Util.bind("status.JDOMError"); //$NON-NLS-1$
+ return Util.bind("status.JDOMError"/*nonNLS*/);
case ELEMENT_DOES_NOT_EXIST:
- return Util.bind("element.doesNotExist",fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("element.doesNotExist"/*nonNLS*/,fElements[0].getElementName());
case EVALUATION_ERROR:
- return Util.bind("status.evaluationError", getString()); //$NON-NLS-1$
+ return Util.bind("status.evaluationError"/*nonNLS*/, getString());
case INDEX_OUT_OF_BOUNDS:
- return Util.bind("status.indexOutOfBounds"); //$NON-NLS-1$
+ return Util.bind("status.indexOutOfBounds"/*nonNLS*/);
case INVALID_CONTENTS:
- return Util.bind("status.invalidContents"); //$NON-NLS-1$
+ return Util.bind("status.invalidContents"/*nonNLS*/);
case INVALID_DESTINATION:
- return Util.bind("status.invalidDestination", fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("status.invalidDestination"/*nonNLS*/, fElements[0].getElementName());
case INVALID_ELEMENT_TYPES:
- StringBuffer buff= new StringBuffer(Util.bind("operation.notSupported")); //$NON-NLS-1$
+ StringBuffer buff= new StringBuffer(Util.bind("operation.notSupported"/*nonNLS*/));
for (int i= 0; i < fElements.length; i++) {
if (i > 0) {
- buff.append(", "); //$NON-NLS-1$
+ buff.append(", "/*nonNLS*/);
}
buff.append(fElements[0].getElementName());
}
return buff.toString();
case INVALID_NAME:
- return Util.bind("status.invalidName", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidName"/*nonNLS*/, getString());
case INVALID_PACKAGE:
- return Util.bind("status.invalidPackage", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidPackage"/*nonNLS*/, getString());
case INVALID_PATH:
- return Util.bind("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ return Util.bind("status.invalidPath"/*nonNLS*/, getPath() == null ? "null"/*nonNLS*/ : getPath().toString());
case INVALID_PROJECT:
- return Util.bind("status.invalidProject", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidProject"/*nonNLS*/, getString());
case INVALID_RESOURCE:
- return Util.bind("status.invalidResource", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidResource"/*nonNLS*/, getString());
case INVALID_RESOURCE_TYPE:
- return Util.bind("status.invalidResourceType", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidResourceType"/*nonNLS*/, getString());
case INVALID_SIBLING:
- return Util.bind("status.invalidSibling", fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("status.invalidSibling"/*nonNLS*/, fElements[0].getElementName());
case IO_EXCEPTION:
- return Util.bind("status.IOException"); //$NON-NLS-1$
+ return Util.bind("status.IOException"/*nonNLS*/);
case NAME_COLLISION:
if (fElements != null && fElements.length > 0) {
IJavaElement element = fElements[0];
String name = element.getElementName();
if (element instanceof IPackageFragment && name.equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) {
- return Util.bind("operation.cannotRenameDefaultPackage"); //$NON-NLS-1$
+ return Util.bind("operation.cannotRenameDefaultPackage"/*nonNLS*/);
}
}
- return Util.bind("status.nameCollision"); //$NON-NLS-1$
+ return Util.bind("status.nameCollision"/*nonNLS*/);
case NO_ELEMENTS_TO_PROCESS:
- return Util.bind("operation.needElements"); //$NON-NLS-1$
+ return Util.bind("operation.needElements"/*nonNLS*/);
case NULL_NAME:
- return Util.bind("operation.needName"); //$NON-NLS-1$
+ return Util.bind("operation.needName"/*nonNLS*/);
case NULL_PATH:
- return Util.bind("operation.needPath"); //$NON-NLS-1$
+ return Util.bind("operation.needPath"/*nonNLS*/);
case NULL_STRING:
- return Util.bind("operation.needString"); //$NON-NLS-1$
+ return Util.bind("operation.needString"/*nonNLS*/);
case PATH_OUTSIDE_PROJECT:
- return Util.bind("operation.pathOutsideProject", getString(), fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("operation.pathOutsideProject"/*nonNLS*/, getString(), fElements[0].getElementName());
case READ_ONLY:
IJavaElement element = fElements[0];
String name = element.getElementName();
if (element instanceof IPackageFragment && name.equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) {
- return Util.bind("status.defaultPackageReadOnly"); //$NON-NLS-1$
+ return Util.bind("status.defaultPackageReadOnly"/*nonNLS*/);
}
- return Util.bind("status.readOnly", name); //$NON-NLS-1$
+ return Util.bind("status.readOnly"/*nonNLS*/, name);
case RELATIVE_PATH:
- return Util.bind("operation.needAbsolutePath", getPath().toString()); //$NON-NLS-1$
+ return Util.bind("operation.needAbsolutePath"/*nonNLS*/, getPath().toString());
case TARGET_EXCEPTION:
- return Util.bind("status.targetException"); //$NON-NLS-1$
+ return Util.bind("status.targetException"/*nonNLS*/);
case UPDATE_CONFLICT:
- return Util.bind("status.updateConflict"); //$NON-NLS-1$
+ return Util.bind("status.updateConflict"/*nonNLS*/);
case NO_LOCAL_CONTENTS :
- return Util.bind("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
+ return Util.bind("status.noLocalContents"/*nonNLS*/, getPath().toString());
}
return getString();
} else {
if (getCode() == CORE_EXCEPTION){
- return Util.bind("status.coreExceptionWithArg", getException().getMessage()); //$NON-NLS-1$
+ return Util.bind("status.coreExceptionWithArg"/*nonNLS*/, getException().getMessage());
}
return getException().getMessage();
}
@@ -311,9 +311,9 @@ public static IJavaModelStatus newMultiStatus(IJavaModelStatus[] children) {
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("Java Model Status ["); //$NON-NLS-1$
+ buffer.append("Java Model Status ["/*nonNLS*/);
buffer.append(getMessage());
- buffer.append("]"); //$NON-NLS-1$
+ buffer.append("]"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index c3b890234a..0dda92591e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -202,7 +202,7 @@ public static IPath canonicalizedPath(IPath externalPath) {
* This is the project bin folder
*/
protected IPath defaultOutputLocation() throws JavaModelException {
- return getProject().getFullPath().append("bin"); //$NON-NLS-1$
+ return getProject().getFullPath().append("bin"/*nonNLS*/);
}
/**
* Returns true if this handle represents the same Java project
@@ -245,14 +245,14 @@ public static IPath canonicalizedPath(IPath externalPath) {
// default to the first one
return pkgFragments[0];
}
- } else if (extension.equalsIgnoreCase("java") || extension.equalsIgnoreCase("class")) { //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (extension.equalsIgnoreCase("java"/*nonNLS*/) || extension.equalsIgnoreCase("class"/*nonNLS*/)) {
IPath packagePath= path.removeLastSegments(1);
String packageName= packagePath.toString().replace(IPath.SEPARATOR, '.');
String typeName= path.lastSegment();
typeName= typeName.substring(0, typeName.length() - extension.length() - 1);
String qualifiedName= null;
if (packageName.length() > 0) {
- qualifiedName= packageName + "." + typeName; //$NON-NLS-1$
+ qualifiedName= packageName + "."/*nonNLS*/ + typeName;
} else {
qualifiedName= typeName;
}
@@ -437,11 +437,18 @@ public static IPath canonicalizedPath(IPath externalPath) {
return getPackageFragmentRoots();
}
/**
+ * @see IJavaProject
+ * @deprecated
+ */
+ public IClasspathEntry[] getClasspath() throws JavaModelException {
+ return getRawClasspath();
+ }
+ /**
* Returns the XML String encoding of the class path.
*/
protected String getClasspathAsXMLString(IClasspathEntry[] classpath, IPath outputLocation) throws JavaModelException {
Document doc= new DocumentImpl();
- Element cpElement= doc.createElement("classpath"); //$NON-NLS-1$
+ Element cpElement= doc.createElement("classpath"/*nonNLS*/);
doc.appendChild(cpElement);
for (int i= 0; i < classpath.length; ++i) {
@@ -452,9 +459,9 @@ public static IPath canonicalizedPath(IPath externalPath) {
if (outputLocation != null) {
outputLocation= outputLocation.removeFirstSegments(1);
outputLocation= outputLocation.makeRelative();
- Element oElement= doc.createElement("classpathentry"); //$NON-NLS-1$
- oElement.setAttribute("kind", kindToString(ClasspathEntry.K_OUTPUT)); //$NON-NLS-1$
- oElement.setAttribute("path", outputLocation.toOSString()); //$NON-NLS-1$
+ Element oElement= doc.createElement("classpathentry"/*nonNLS*/);
+ oElement.setAttribute("kind"/*nonNLS*/, kindToString(ClasspathEntry.K_OUTPUT));
+ oElement.setAttribute("path"/*nonNLS*/, outputLocation.toOSString());
cpElement.appendChild(oElement);
}
@@ -488,15 +495,15 @@ public static IPath canonicalizedPath(IPath externalPath) {
* of this project
*/
public QualifiedName getClasspathPropertyName() {
- return new QualifiedName(JavaCore.PLUGIN_ID, "classpath"); //$NON-NLS-1$
+ return new QualifiedName(JavaCore.PLUGIN_ID, "classpath"/*nonNLS*/);
}
/**
* Returns the XML String encoding of the class path.
*/
protected static Element getEntryAsXMLElement(Document document, IClasspathEntry entry, IPath prefixPath) throws JavaModelException {
- Element element= document.createElement("classpathentry"); //$NON-NLS-1$
- element.setAttribute("kind", kindToString(entry.getEntryKind())); //$NON-NLS-1$
+ Element element= document.createElement("classpathentry"/*nonNLS*/);
+ element.setAttribute("kind"/*nonNLS*/, kindToString(entry.getEntryKind()));
IPath path= entry.getPath();
if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE){
// translate to project relative from absolute (unless a device path)
@@ -511,12 +518,12 @@ public static IPath canonicalizedPath(IPath externalPath) {
}
}
}
- element.setAttribute("path", path.toString()); //$NON-NLS-1$
+ element.setAttribute("path"/*nonNLS*/, path.toString());
if (entry.getSourceAttachmentPath() != null){
- element.setAttribute("sourcepath", entry.getSourceAttachmentPath().toString()); //$NON-NLS-1$
+ element.setAttribute("sourcepath"/*nonNLS*/, entry.getSourceAttachmentPath().toString());
}
if (entry.getSourceAttachmentRootPath() != null){
- element.setAttribute("rootpath", entry.getSourceAttachmentRootPath().toString()); //$NON-NLS-1$
+ element.setAttribute("rootpath"/*nonNLS*/, entry.getSourceAttachmentRootPath().toString());
}
return element;
}
@@ -590,7 +597,7 @@ public static IPath canonicalizedPath(IPath externalPath) {
*/
public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
String name= resource.getName();
- if (Util.endsWithIgnoreCase(name,".jar") || Util.endsWithIgnoreCase(name,".zip")) { //$NON-NLS-2$ //$NON-NLS-1$
+ if (Util.endsWithIgnoreCase(name,".jar"/*nonNLS*/) || Util.endsWithIgnoreCase(name,".zip"/*nonNLS*/)) {
return new JarPackageFragmentRoot(resource, this);
} else {
return new PackageFragmentRoot(resource, this);
@@ -676,7 +683,7 @@ public static IPath canonicalizedPath(IPath externalPath) {
if (entry.getContentKind() == IPackageFragmentRoot.K_BINARY) {
String ext= path.getFileExtension();
IPackageFragmentRoot root= null;
- if (ext != null && (ext.equalsIgnoreCase("zip") || ext.equalsIgnoreCase("jar"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (ext != null && (ext.equalsIgnoreCase("zip"/*nonNLS*/) || ext.equalsIgnoreCase("jar"/*nonNLS*/))) {
// jar
// removeFirstSegment removes the part relative to the project which is retrieve
// through workspace.getDefaultContentLocation
@@ -931,15 +938,15 @@ public String[] getRequiredProjectNames() throws JavaModelException {
* Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form.
*/
static int kindFromString(String kindStr) {
- if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
+ if (kindStr.equalsIgnoreCase("prj"/*nonNLS*/))
return IClasspathEntry.CPE_PROJECT;
- if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
+ if (kindStr.equalsIgnoreCase("var"/*nonNLS*/))
return IClasspathEntry.CPE_VARIABLE;
- if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
+ if (kindStr.equalsIgnoreCase("src"/*nonNLS*/))
return IClasspathEntry.CPE_SOURCE;
- if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
+ if (kindStr.equalsIgnoreCase("lib"/*nonNLS*/))
return IClasspathEntry.CPE_LIBRARY;
- if (kindStr.equalsIgnoreCase("output")) //$NON-NLS-1$
+ if (kindStr.equalsIgnoreCase("output"/*nonNLS*/))
return ClasspathEntry.K_OUTPUT;
return -1;
}
@@ -951,17 +958,17 @@ public String[] getRequiredProjectNames() throws JavaModelException {
static String kindToString(int kind) {
switch (kind) {
case IClasspathEntry.CPE_PROJECT :
- return "src"; // backward compatibility //$NON-NLS-1$
+ return "src"/*nonNLS*/; // backward compatibility
case IClasspathEntry.CPE_SOURCE :
- return "src"; //$NON-NLS-1$
+ return "src"/*nonNLS*/;
case IClasspathEntry.CPE_LIBRARY :
- return "lib"; //$NON-NLS-1$
+ return "lib"/*nonNLS*/;
case IClasspathEntry.CPE_VARIABLE :
- return "var"; //$NON-NLS-1$
+ return "var"/*nonNLS*/;
case ClasspathEntry.K_OUTPUT :
- return "output"; //$NON-NLS-1$
+ return "output"/*nonNLS*/;
default :
- return "unknown"; //$NON-NLS-1$
+ return "unknown"/*nonNLS*/;
}
}
/**
@@ -983,10 +990,31 @@ public String[] getRequiredProjectNames() throws JavaModelException {
}
/**
* @see IJavaProject
+ * @deprecated
+ */
+ public IClasspathEntry newLibraryEntry(IPath path) {
+ return JavaCore.newLibraryEntry(path, null, null);
+ }
+ /**
+ * @see IJavaProject
+ * @deprecated
+ */
+ public IClasspathEntry newProjectEntry(IPath path) {
+ return JavaCore.newProjectEntry(path);
+ }
+ /**
+ * @see IJavaProject
+ * @deprecated
+ */
+ public IClasspathEntry newSourceEntry(IPath path) {
+ return JavaCore.newSourceEntry(path);
+ }
+ /**
+ * @see IJavaProject
*/
public ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor) throws JavaModelException {
if (region == null) {
- throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion"/*nonNLS*/));
}
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(null, region, this, true);
runOperation(op, monitor);
@@ -997,10 +1025,10 @@ public String[] getRequiredProjectNames() throws JavaModelException {
*/
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor) throws JavaModelException {
if (type == null) {
- throw new IllegalArgumentException(Util.bind("hierarchy.nullFocusType")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("hierarchy.nullFocusType"/*nonNLS*/));
}
if (region == null) {
- throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion"/*nonNLS*/));
}
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(type, region, this, true);
runOperation(op, monitor);
@@ -1067,15 +1095,15 @@ public String[] getRequiredProjectNames() throws JavaModelException {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
cpElement = parser.parse(new InputSource(reader)).getDocumentElement();
} catch(SAXException e) {
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("file.badFormat"/*nonNLS*/));
} catch(ParserConfigurationException e){
reader.close();
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("file.badFormat"/*nonNLS*/));
} finally {
reader.close();
}
- if (!cpElement.getNodeName().equalsIgnoreCase("classpath")) { //$NON-NLS-1$
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ if (!cpElement.getNodeName().equalsIgnoreCase("classpath"/*nonNLS*/)) {
+ throw new IOException(Util.bind("file.badFormat"/*nonNLS*/));
}
NodeList list= cpElement.getChildNodes();
Vector paths= new Vector();
@@ -1085,9 +1113,9 @@ public String[] getRequiredProjectNames() throws JavaModelException {
short type= node.getNodeType();
if (type == Node.ELEMENT_NODE) {
Element cpeElement= (Element) node;
- if (cpeElement.getNodeName().equalsIgnoreCase("classpathentry")) { //$NON-NLS-1$
- String cpeElementKind = cpeElement.getAttribute("kind"); //$NON-NLS-1$
- String pathStr = cpeElement.getAttribute("path"); //$NON-NLS-1$
+ if (cpeElement.getNodeName().equalsIgnoreCase("classpathentry"/*nonNLS*/)) {
+ String cpeElementKind = cpeElement.getAttribute("kind"/*nonNLS*/);
+ String pathStr = cpeElement.getAttribute("path"/*nonNLS*/);
// ensure path is absolute
IPath path= new Path(pathStr);
int kind= kindFromString(cpeElementKind);
@@ -1095,10 +1123,10 @@ public String[] getRequiredProjectNames() throws JavaModelException {
path= projectPath.append(path);
}
// source attachment info (optional)
- String sourceAttachmentPathStr = cpeElement.getAttribute("sourcepath"); //$NON-NLS-1$
- IPath sourceAttachmentPath = sourceAttachmentPathStr.equals("") ? null : new Path(sourceAttachmentPathStr); //$NON-NLS-1$
- String sourceAttachmentRootPathStr = cpeElement.getAttribute("rootpath"); //$NON-NLS-1$
- IPath sourceAttachmentRootPath = sourceAttachmentRootPathStr.equals("") ? null : new Path(sourceAttachmentRootPathStr); //$NON-NLS-1$
+ String sourceAttachmentPathStr = cpeElement.getAttribute("sourcepath"/*nonNLS*/);
+ IPath sourceAttachmentPath = sourceAttachmentPathStr.equals(""/*nonNLS*/) ? null : new Path(sourceAttachmentPathStr);
+ String sourceAttachmentRootPathStr = cpeElement.getAttribute("rootpath"/*nonNLS*/);
+ IPath sourceAttachmentRootPath = sourceAttachmentRootPathStr.equals(""/*nonNLS*/) ? null : new Path(sourceAttachmentRootPathStr);
IClasspathEntry entry= createClasspathEntry(path, kind, sourceAttachmentPath, sourceAttachmentRootPath);
if (entry == null) return null;
@@ -1223,6 +1251,13 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
}
}
/**
+ * @see IJavaProject
+ * @deprecated
+ */
+ public void setClasspath(IClasspathEntry[] entries, IProgressMonitor monitor) throws JavaModelException {
+ setRawClasspath(entries, monitor, true);
+ }
+ /**
* Update the Java command in the build spec (replace existing one if present,
* add one first if none).
*/
@@ -1257,7 +1292,7 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
*/
public void setOutputLocation(IPath outputLocation, IProgressMonitor monitor) throws JavaModelException {
if (outputLocation == null) {
- throw new IllegalArgumentException(Util.bind("path.nullpath")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("path.nullpath"/*nonNLS*/));
}
if (outputLocation.equals(getOutputLocation())) {
return;
@@ -1426,9 +1461,9 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
private void createClasspathProblemMarker(IClasspathEntry entry, String message){
try {
IMarker marker = getProject().createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
- marker.setAttributes(
- new String[]{ IMarker.MESSAGE, IMarker.SEVERITY, IMarker.LOCATION},
- new Object[]{message, new Integer(IMarker.SEVERITY_WARNING), Util.bind("classpath.buildPath")}); //$NON-NLS-1$
+ marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.LOCATION, Util.bind("classpath.buildPath"/*nonNLS*/));
} catch (CoreException e) {
}
}
@@ -1447,6 +1482,98 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
}
/**
+ * Returns a message describing the problem related to this classpath entry if any, or null if entry is fine
+ * (i.e. if the given classpath entry denotes a valid element to be referenced onto a classpath).
+ */
+ private String getClasspathEntryErrorMessage(IClasspathEntry entry, boolean checkSourceAttachment){
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath path = entry.getPath();
+
+ switch(entry.getEntryKind()){
+
+ // variable entry check
+ case IClasspathEntry.CPE_VARIABLE :
+ entry = JavaCore.getResolvedClasspathEntry(entry);
+ if (entry == null){
+ return Util.bind("classpath.unboundVariablePath"/*nonNLS*/, path.toString());
+ }
+ return getClasspathEntryErrorMessage(entry, checkSourceAttachment);
+
+
+ // library entry check
+ case IClasspathEntry.CPE_LIBRARY :
+ if (path != null && path.isAbsolute() && !path.isEmpty()) {
+ IPath sourceAttachment = entry.getSourceAttachmentPath();
+ Object target = JavaModel.getTarget(workspaceRoot, path, true);
+ if (target instanceof IResource){
+ IResource resolvedResource = (IResource) target;
+ switch(resolvedResource.getType()){
+ case IResource.FILE :
+ String extension = resolvedResource.getFileExtension();
+ if ("jar"/*nonNLS*/.equalsIgnoreCase(extension) || "zip"/*nonNLS*/.equalsIgnoreCase(extension)){ // internal binary archive
+ if (checkSourceAttachment
+ && sourceAttachment != null
+ && !sourceAttachment.isEmpty()
+ && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
+ return Util.bind("classpath.unboundSourceAttachment"/*nonNLS*/, sourceAttachment.toString());
+ }
+ }
+ break;
+ case IResource.FOLDER : // internal binary folder
+ if (checkSourceAttachment
+ && sourceAttachment != null
+ && !sourceAttachment.isEmpty()
+ && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
+ return Util.bind("classpath.unboundSourceAttachment"/*nonNLS*/, sourceAttachment.toString());
+ }
+ }
+ } else if (target instanceof File){
+ if (checkSourceAttachment
+ && sourceAttachment != null
+ && !sourceAttachment.isEmpty()
+ && JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
+ return Util.bind("classpath.unboundSourceAttachment"/*nonNLS*/, sourceAttachment.toString());
+ }
+ } else {
+ return Util.bind("classpath.unboundLibrary"/*nonNLS*/, path.toString());
+ }
+ } else {
+ return Util.bind("classpath.illegalLibraryPath"/*nonNLS*/, path.toString());
+ }
+ break;
+
+ // project entry check
+ case IClasspathEntry.CPE_PROJECT :
+ if (path != null && path.isAbsolute() && !path.isEmpty()) {
+ IProject project = workspaceRoot.getProject(path.segment(0));
+ try {
+ if (!project.exists() || !project.hasNature(JavaCore.NATURE_ID)){
+ return Util.bind("classpath.unboundProject"/*nonNLS*/, path.segment(0).toString());
+ }
+ } catch (CoreException e){
+ return Util.bind("classpath.unboundProject"/*nonNLS*/, path.segment(0).toString());
+ }
+ } else {
+ return Util.bind("classpath.illegalProjectPath"/*nonNLS*/, path.segment(0).toString());
+ }
+ break;
+
+ // project source folder
+ case IClasspathEntry.CPE_SOURCE :
+ if (path != null && path.isAbsolute() && !path.isEmpty()) {
+ IPath projectPath= getProject().getFullPath();
+ if (!projectPath.isPrefixOf(path) || JavaModel.getTarget(workspaceRoot, path, true) == null){
+ return Util.bind("classpath.unboundSourceFolder"/*nonNLS*/, path.toString());
+ }
+ } else {
+ return Util.bind("classpath.illegalSourceFolderPath"/*nonNLS*/, path.toString());
+ }
+ break;
+ }
+ return null;
+ }
+
+ /**
* Internal variant which can create marker on project for invalid entries
*/
public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedVariable, boolean generateMarkerOnError) throws JavaModelException {
@@ -1460,12 +1587,6 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
IClasspathEntry entry = classpath[i];
- /* validation if needed */
- if (generateMarkerOnError){
- IJavaModelStatus status = JavaConventions.validateClasspathEntry(this, entry, false);
- if (!status.isOK()) createClasspathProblemMarker(entry, status.getMessage());
- }
-
/* resolve variables if any, unresolved ones are ignored */
if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
@@ -1477,12 +1598,15 @@ protected void resetNonJavaResourcesForPackageFragmentRoots() throws JavaModelEx
IPath variablePath = entry.getPath(); // for error reporting
entry = JavaCore.getResolvedClasspathEntry(entry);
if (entry == null){
+ if (generateMarkerOnError) createClasspathProblemMarker(classpath[i], Util.bind("classpath.unboundVariablePath"/*nonNLS*/, variablePath.toString()));
if (!ignoreUnresolvedVariable){
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, variablePath.toString()));
}
}
}
if (entry != null){
+ String msg;
+ if (generateMarkerOnError && (msg = getClasspathEntryErrorMessage(entry, false)) != null) createClasspathProblemMarker(classpath[i], msg);
resolvedPath[index++] = entry;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
index c405379d48..e9cbfbf3f1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
@@ -28,7 +28,7 @@ public MoveElementsOperation(IJavaElement[] elementsToMove, IJavaElement[] destC
* for progress monitoring.
*/
protected String getMainTaskName() {
- return Util.bind("operation.moveElementProgress"); //$NON-NLS-1$
+ return Util.bind("operation.moveElementProgress"/*nonNLS*/);
}
/**
* @see CopyElementsOperation#isMove()
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
index cfbf9ae9ea..895def8ebd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
@@ -27,7 +27,7 @@ public MoveResourceElementsOperation(IJavaElement[] elementsToMove, IJavaElement
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.moveResourceProgress"); //$NON-NLS-1$
+ return Util.bind("operation.moveResourceProgress"/*nonNLS*/);
}
/**
* @see CopyResourceElementsOperation#isMove()
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
index 9b0c5b6359..8ebdbe1ca6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
@@ -152,7 +152,7 @@ public class NameLookup implements INameLookup {
if (index != -1) {
cuName= cuName.substring(0, index);
}
- cuName += ".java"; //$NON-NLS-1$
+ cuName += ".java"/*nonNLS*/;
IPackageFragment[] frags= (IPackageFragment[]) fPackageFragments.get(pkgName);
if (frags != null) {
@@ -173,7 +173,7 @@ public class NameLookup implements INameLookup {
*/
public IPackageFragment findPackageFragment(IPath path) {
if (!path.isAbsolute()) {
- throw new IllegalArgumentException(Util.bind("path.mustBeAbsolute")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("path.mustBeAbsolute"/*nonNLS*/));
}
IResource possibleFragment = workspace.getRoot().findMember(path);
if (possibleFragment == null) {
@@ -244,7 +244,7 @@ public IPackageFragment findPackageFragment(IPath path) {
*/
public IPackageFragmentRoot findPackageFragmentRoot(IPath path) {
if (!path.isAbsolute()) {
- throw new IllegalArgumentException(Util.bind("path.mustBeAbsolute")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("path.mustBeAbsolute"/*nonNLS*/));
}
for (int i= 0; i < fPackageFragmentRoots.length; i++) {
IPackageFragmentRoot classpathRoot= fPackageFragmentRoots[i];
@@ -532,7 +532,7 @@ public IPackageFragment findPackageFragment(IPath path) {
* the compilationUnits always will. So add it if we're looking for
* an exact match.
*/
- String unitName= partialMatch ? matchName.toLowerCase() : matchName + ".java"; //$NON-NLS-1$
+ String unitName= partialMatch ? matchName.toLowerCase() : matchName + ".java"/*nonNLS*/;
for (int i= 0; i < length; i++) {
if (requestor.isCanceled())
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java
index ea97f45c28..e79947fcca 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java
@@ -25,7 +25,7 @@ public NonVoidMethodRequestor(ISearchRequestor requestor) {
}
public void acceptMethod(IMethod method) {
try {
- if (!Signature.getReturnType(method.getSignature()).equals("V")) { //$NON-NLS-1$
+ if (!Signature.getReturnType(method.getSignature()).equals("V"/*nonNLS*/)) {
super.acceptMethod(method);
}
} catch (JavaModelException npe) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
index a36fb8c1fd..cc6944b475 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
@@ -21,7 +21,6 @@ import org.eclipse.jdt.internal.core.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
-import java.util.Map;
/**
@@ -96,7 +95,7 @@ protected void closing(Object info) throws JavaModelException {
*/
protected void codeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit cu, org.eclipse.jdt.internal.compiler.env.ICompilationUnit unitToSkip, int position, ICodeCompletionRequestor requestor) throws JavaModelException {
if (requestor == null) {
- throw new IllegalArgumentException(Util.bind("codeAssist.nullRequestor")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("codeAssist.nullRequestor"/*nonNLS*/));
}
if (position < -1 || position > getBuffer().getLength()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
@@ -104,7 +103,7 @@ protected void codeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUn
SearchableEnvironment environment = (SearchableEnvironment) ((JavaProject) getJavaProject()).getSearchableNameEnvironment();
environment.unitToSkip = unitToSkip;
- CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor), JavaModelManager.getOptions());
+ CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor), JavaModelManager.convertConfigurableOptions(JavaCore.getOptions()));
engine.complete(cu, position);
environment.unitToSkip = null;
}
@@ -135,7 +134,7 @@ protected void codeSelect(org.eclipse.jdt.internal.compiler.env.ICompilationUnit
ISearchableNameEnvironment environment = ((JavaProject)getJavaProject()).getSearchableNameEnvironment();
// fix for 1FVXGDK
- SelectionEngine engine = new SelectionEngine(environment, requestor, JavaModelManager.getOptions());
+ SelectionEngine engine = new SelectionEngine(environment, requestor, JavaModelManager.convertConfigurableOptions(JavaCore.getOptions()));
engine.select(cu, offset, offset + length - 1);
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
index 6f1cd7884f..2d49198720 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
@@ -212,7 +212,7 @@ public void printStats() {
forwardListLength++;
entry = entry._fNext;
}
- System.out.println("Forward length: " + forwardListLength); //$NON-NLS-1$
+ System.out.println("Forward length: "/*nonNLS*/ + forwardListLength);
int backwardListLength = 0;
entry = fEntryQueueTail;
@@ -220,7 +220,7 @@ public void printStats() {
backwardListLength++;
entry = entry._fPrevious;
}
- System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
+ System.out.println("Backward length: "/*nonNLS*/ + backwardListLength);
Enumeration keys = fEntryTable.keys();
java.util.Vector v = new java.util.Vector();
@@ -232,7 +232,7 @@ public void printStats() {
fCount = 1;
}
public String toString() {
- return "Class: " + fClass + " has " + fCount + " entries."; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ return "Class: "/*nonNLS*/ + fClass + " has "/*nonNLS*/ + fCount + " entries."/*nonNLS*/;
}
}
java.util.Hashtable h = new java.util.Hashtable();
@@ -369,7 +369,7 @@ public void setLoadFactor(double newLoadFactor) throws IllegalArgumentException
if(newLoadFactor <= 1.0 && newLoadFactor > 0.0)
fLoadFactor = newLoadFactor;
else
- throw new IllegalArgumentException(Util.bind("cache.invalidLoadFactor")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("cache.invalidLoadFactor"/*nonNLS*/));
}
/**
* Sets the maximum amount of space that the cache can store
@@ -397,7 +397,7 @@ public void setLoadFactor(double newLoadFactor) throws IllegalArgumentException
*/
public String toString() {
return
- "OverflowingLRUCache " + ((fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit) + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "OverflowingLRUCache "/*nonNLS*/ + ((fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit) + "% full\n"/*nonNLS*/ +
this.toStringContents();
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
index c046e5180f..c774187aab 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
@@ -33,10 +33,10 @@ protected char getHandleMementoDelimiter() {
* @private Debugging purposes
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
- buffer.append("package "); //$NON-NLS-1$
+ buffer.append("package "/*nonNLS*/);
buffer.append(getElementName());
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
index 9cec2b6735..9ab3bb1c45 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
@@ -45,9 +45,9 @@ protected boolean computeChildren(OpenableElementInfo info, IResource resource)
int kind = getKind();
String extType;
if (kind == IPackageFragmentRoot.K_SOURCE) {
- extType = "java"; //$NON-NLS-1$
+ extType = "java"/*nonNLS*/;
} else {
- extType = "class"; //$NON-NLS-1$
+ extType = "class"/*nonNLS*/;
}
try {
IResource[] members = ((IContainer) resource).members();
@@ -89,7 +89,7 @@ public boolean containsJavaResources() throws JavaModelException {
*/
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] containers= new IJavaElement[] {container};
@@ -229,7 +229,7 @@ public boolean hasSubpackages() throws JavaModelException {
IJavaElement[] packages= ((IPackageFragmentRoot)getParent()).getChildren();
String name = getElementName();
int nameLength = name.length();
- String packageName = isDefaultPackage() ? name : name+"."; //$NON-NLS-1$
+ String packageName = isDefaultPackage() ? name : name+"."/*nonNLS*/;
for (int i= 0; i < packages.length; i++) {
String otherName = packages[i].getElementName();
if (otherName.length() > nameLength && otherName.startsWith(packageName)) {
@@ -249,7 +249,7 @@ public boolean isDefaultPackage() {
*/
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] containers= new IJavaElement[] {container};
@@ -280,7 +280,7 @@ public void refreshChildren() {
*/
public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] dests= new IJavaElement[] {this.getParent()};
@@ -300,15 +300,15 @@ protected void toStringChildren(int tab, StringBuffer buffer, Object info) {
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (getElementName().length() == 0) {
- buffer.append("[default]"); //$NON-NLS-1$
+ buffer.append("[default]"/*nonNLS*/);
} else {
buffer.append(getElementName());
}
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
} else {
if (tab > 0) {
- buffer.append(" (...)"); //$NON-NLS-1$
+ buffer.append(" (...)"/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
index d34c2cc0f5..6dc504d686 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
@@ -43,7 +43,7 @@ private Object[] computeNonJavaResources(IResource resource) {
IResource child = members[i];
if (child.getType() != IResource.FOLDER) {
String extension = child.getProjectRelativePath().getFileExtension();
- if (!"java".equalsIgnoreCase(extension) && !"class".equalsIgnoreCase(extension)) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (!"java"/*nonNLS*/.equalsIgnoreCase(extension) && !"class"/*nonNLS*/.equalsIgnoreCase(extension)) {
if (nonJavaResources.length == nonJavaResourcesCounter) {
// resize
System.arraycopy(
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
index 4fd6366a53..5de8071e79 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
@@ -55,7 +55,7 @@ protected boolean computeChildren(OpenableElementInfo info) throws JavaModelExce
// is actually the package fragment root)
if (fResource.getType() == IResource.FOLDER || fResource.getType() == IResource.PROJECT) {
Vector vChildren = new Vector(5);
- computeFolderChildren((IContainer) fResource, "", vChildren); //$NON-NLS-1$
+ computeFolderChildren((IContainer) fResource, ""/*nonNLS*/, vChildren);
IJavaElement[] children = new IJavaElement[vChildren.size()];
vChildren.copyInto(children);
info.setChildren(children);
@@ -86,7 +86,7 @@ protected void computeFolderChildren(IContainer folder, String prefix, Vector vC
if (prefix.length() == 0) {
newPrefix = member.getName();
} else {
- newPrefix = prefix + "." + member.getName(); //$NON-NLS-1$
+ newPrefix = prefix + "."/*nonNLS*/ + member.getName();
}
// eliminate binary output only if nested inside direct subfolders
if (!member.getFullPath().equals(outputLocationPath)) {
@@ -296,12 +296,12 @@ public void refreshChildren() {
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (getElementName().length() == 0) {
- buffer.append("[project root]"); //$NON-NLS-1$
+ buffer.append("[project root]"/*nonNLS*/);
} else {
buffer.append(getElementName());
}
if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
index 083ce1d6e8..ff1c197991 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
@@ -52,7 +52,7 @@ private Object[] computeFolderNonJavaResources(IJavaProject project, IContainer
IResource member = members[i];
if (member.getType() == IResource.FILE) {
String extension = member.getProjectRelativePath().getFileExtension();
- if (!"java".equalsIgnoreCase(extension) && !"class".equalsIgnoreCase(extension)) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (!"java"/*nonNLS*/.equalsIgnoreCase(extension) && !"class"/*nonNLS*/.equalsIgnoreCase(extension)) {
if (project.findPackageFragmentRoot(member.getFullPath()) == null) {
if (nonJavaResources.length == nonJavaResourcesCounter) {
// resize
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Problem.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Problem.java
index e7fed9615d..cbcafc5f4f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Problem.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Problem.java
@@ -137,13 +137,13 @@ public void setSourceStart(int sourceStart) {
public String toString() {
- String s = "Pb(" + (id & IgnoreCategoriesMask) + ") "; //$NON-NLS-1$ //$NON-NLS-2$
+ String s = "Pb("/*nonNLS*/ + (id & IgnoreCategoriesMask) + ") "/*nonNLS*/;
if (message != null) {
s += message;
} else {
if (arguments != null)
for (int i = 0; i < arguments.length; i++)
- s += " " + arguments[i]; //$NON-NLS-1$
+ s += " "/*nonNLS*/ + arguments[i];
}
return s;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
index 848fd31990..15b66de75b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
@@ -137,7 +137,7 @@ public String toString() {
for (int i= 0; i < roots.length; i++) {
buffer.append(roots[i].getElementName());
if (i < (roots.length - 1)) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
}
buffer.append(']');
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
index b2f6e7d91e..50a35bf09e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
@@ -38,7 +38,7 @@ public RenameElementsOperation(IJavaElement[] elements, IJavaElement[] destinati
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.renameElementProgress"); //$NON-NLS-1$
+ return Util.bind("operation.renameElementProgress"/*nonNLS*/);
}
/**
* @see CopyElementsOperation#isRename()
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
index d1dea29ed4..f26666bfec 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
@@ -34,7 +34,7 @@ public RenameResourceElementsOperation(IJavaElement[] elements, IJavaElement[] d
* @see MultiOperation
*/
protected String getMainTaskName() {
- return Util.bind("operation.renameResourceProgress"); //$NON-NLS-1$
+ return Util.bind("operation.renameResourceProgress"/*nonNLS*/);
}
/**
* @see CopyResourceElementsOperation#isRename()
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
index d69cbf5e26..745ff1af97 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
@@ -6,373 +6,282 @@ package org.eclipse.jdt.internal.core;
*/
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
-import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.search.*;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.util.*;
import org.eclipse.jdt.internal.codeassist.*;
-import org.eclipse.jdt.internal.core.SourceTypeElementInfo;;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
/**
* This class provides a <code>SearchableBuilderEnvironment</code> for code assist which
* uses the Java model as a search tool.
*/
-public class SearchableEnvironment
- implements ISearchableNameEnvironment, IJavaSearchConstants {
+
+public class SearchableEnvironment implements ISearchableNameEnvironment, IJavaSearchConstants {
protected NameLookup nameLookup;
protected ICompilationUnit unitToSkip;
public CompilationUnit unitToLookInside;
protected IJavaProject project;
-
- /**
- * Creates a SearchableEnvironment on the given project
- */
- public SearchableEnvironment(IJavaProject project) throws JavaModelException {
- this.project = project;
- this.nameLookup = (NameLookup) ((JavaProject) project).getNameLookup();
- }
-
- /**
- * Returns the given type in the the given package if it exists,
- * otherwise <code>null</code>.
- */
- protected NameEnvironmentAnswer find(String typeName, String packageName) {
- if (packageName == null)
- packageName = IPackageFragment.DEFAULT_PACKAGE_NAME;
- IType type =
- this.nameLookup.findType(
- typeName,
- packageName,
- false,
- INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
- if (type == null) {
- // look inside the compilation unit that is being searched currently
- //for a non-public or inner type.
- if (this.unitToLookInside != null) {
- if (this.unitToLookInside.getParent().getElementName().equals(packageName)) {
- try {
- IType[] allTypes = this.unitToLookInside.getTypes();
- for (int i = 0; i < allTypes.length; i++) {
- if (allTypes[i].getElementName().equals(typeName)) {
- type = allTypes[i];
- break;
- }
+/**
+ * Creates a SearchableEnvironment on the given project
+ */
+public SearchableEnvironment(IJavaProject project) throws JavaModelException {
+ this.project = project;
+ this.nameLookup = (NameLookup)((JavaProject)project).getNameLookup();
+}
+/**
+ * Returns the given type in the the given package if it exists,
+ * otherwise <code>null</code>.
+ */
+protected NameEnvironmentAnswer find(String typeName, String packageName) {
+ if (packageName == null)
+ packageName = IPackageFragment.DEFAULT_PACKAGE_NAME;
+ IType type = this.nameLookup.findType(typeName, packageName, false, INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
+ if (type == null) {
+ // look inside the compilation unit that is being searched currently
+ //for a non-public or inner type.
+ if (this.unitToLookInside != null) {
+ if (this.unitToLookInside.getParent().getElementName().equals(packageName)) {
+ try {
+ IType[] allTypes = this.unitToLookInside.getTypes();
+ for (int i= 0; i < allTypes.length; i++) {
+ if (allTypes[i].getElementName().equals(typeName)) {
+ type = allTypes[i];
+ break;
}
- } catch (JavaModelException e) {
}
+ } catch (JavaModelException e) {
}
}
}
- if (type != null) {
- if (type instanceof BinaryType) {
- try {
- return new NameEnvironmentAnswer(
- (IBinaryType) ((BinaryType) type).getRawInfo());
- } catch (JavaModelException npe) {
- return null;
- }
- } else { //SourceType
- try {
- // retrieve the requested type
- SourceTypeElementInfo sourceType = (SourceTypeElementInfo)((SourceType)type).getRawInfo();
- ISourceType topLevelType = sourceType;
- while (topLevelType.getEnclosingType() != null) {
- topLevelType = topLevelType.getEnclosingType();
- }
- // find all siblings (other types declared in same unit, since may be used for name resolution)
- IType[] types = sourceType.getHandle().getCompilationUnit().getTypes();
- ISourceType[] sourceTypes = new ISourceType[types.length];
-
- // in the resulting collection, ensure the requested type is the first one
- sourceTypes[0] = sourceType;
- for (int i = 0, index = 1; i < types.length; i++) {
- ISourceType otherType =
- (ISourceType) ((JavaElement) types[i]).getRawInfo();
- if (!otherType.equals(topLevelType))
- sourceTypes[index++] = otherType;
- }
- return new NameEnvironmentAnswer(sourceTypes);
- } catch (JavaModelException npe) {
- return null;
- }
+ }
+ if (type != null) {
+ if (type instanceof BinaryType) {
+ try {
+ return new NameEnvironmentAnswer((IBinaryType) ((BinaryType) type).getRawInfo());
+ } catch (JavaModelException npe) {
+ return null;
+ }
+ } else { //SourceType
+ try {
+ return new NameEnvironmentAnswer((ISourceType)((SourceType)type).getRawInfo());
+ } catch (JavaModelException npe) {
+ return null;
}
}
- return null;
}
-
- /**
- * @see SearchableBuilderEnvironment
- */
- public void findPackages(char[] prefix, ISearchRequestor requestor) {
- this.nameLookup.seekPackageFragments(
- new String(prefix),
- true,
- new SearchableEnvironmentRequestor(requestor));
+ return null;
+}
+/**
+ * @see SearchableBuilderEnvironment
+ */
+public void findPackages(char[] prefix, ISearchRequestor requestor) {
+ this.nameLookup.seekPackageFragments(new String(prefix), true, new SearchableEnvironmentRequestor(requestor));
+}
+/**
+ * @see INameEnvironment
+ */
+public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
+ if (compoundTypeName == null)
+ return null;
+ int length = compoundTypeName.length;
+ if (length == 1)
+ return find(new String(compoundTypeName[0]), null);
+ StringBuffer buffer = new StringBuffer(length * 6);
+ int lengthM1 = length - 1;
+ for(int i = 0; i < lengthM1; i++) {
+ buffer.append(compoundTypeName[i]);
+ if (i + 1 != lengthM1)
+ buffer.append('.');
}
+ String className = new String(compoundTypeName[lengthM1]);
+ return find(className, buffer.toString());
+}
+/**
+ * @see INameEnvironment
+ */
+public NameEnvironmentAnswer findType(char[] name, char[][] packages) {
+ if (name == null)
+ return null;
- /**
- * @see INameEnvironment
- */
- public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
- if (compoundTypeName == null)
- return null;
- int length = compoundTypeName.length;
- if (length == 1)
- return find(new String(compoundTypeName[0]), null);
- StringBuffer buffer = new StringBuffer(length * 6);
- int lengthM1 = length - 1;
- for (int i = 0; i < lengthM1; i++) {
- buffer.append(compoundTypeName[i]);
- if (i + 1 != lengthM1)
- buffer.append('.');
- }
- String className = new String(compoundTypeName[lengthM1]);
- return find(className, buffer.toString());
+ if (packages == null || packages.length == 0)
+ return find(new String(name), null);
+
+ int length = packages.length;
+ StringBuffer buffer = new StringBuffer(length * 6);
+ for(int i = 0; i < length; i++) {
+ buffer.append(packages[i]);
+ if (i + 1 != length)
+ buffer.append('.');
}
+ String className = new String(name);
+ return find(className, buffer.toString());
+}
+/**
+ * @see ISearchableNameEnvironment
+ */
+public void findTypes(char[] prefix, final ISearchRequestor storage) {
- /**
- * @see INameEnvironment
- */
- public NameEnvironmentAnswer findType(char[] name, char[][] packages) {
- if (name == null)
- return null;
-
- if (packages == null || packages.length == 0)
- return find(new String(name), null);
-
- int length = packages.length;
- StringBuffer buffer = new StringBuffer(length * 6);
- for (int i = 0; i < length; i++) {
- buffer.append(packages[i]);
- if (i + 1 != length)
- buffer.append('.');
- }
- String className = new String(name);
- return find(className, buffer.toString());
+/*
+ if (true){
+ findTypes(new String(prefix), storage, INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
+ return;
}
-
- /**
- * @see ISearchableNameEnvironment
- */
- public void findTypes(char[] prefix, final ISearchRequestor storage) {
-
- /*
- if (true){
+*/
+ try {
+ final String excludePath;
+ if (this.unitToSkip != null){
+ if (!(this.unitToSkip instanceof IJavaElement)){ // revert to model investigation
findTypes(new String(prefix), storage, INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
return;
}
- */
- try {
- final String excludePath;
- if (this.unitToSkip != null) {
- if (!(this.unitToSkip instanceof IJavaElement)) {
- // revert to model investigation
- findTypes(
- new String(prefix),
- storage,
- INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
- return;
- }
- excludePath =
- ((IJavaElement) this.unitToSkip)
- .getUnderlyingResource()
- .getFullPath()
- .toString();
- } else {
- excludePath = null;
- }
- int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
- char[] qualification, simpleName;
- if (lastDotIndex < 0) {
- qualification = null;
- simpleName = CharOperation.toLowerCase(prefix);
- } else {
- qualification = CharOperation.subarray(prefix, 0, lastDotIndex);
- simpleName =
- CharOperation.toLowerCase(
- CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length));
- }
-
- SearchEngine searchEngine = new SearchEngine();
+ excludePath = ((IJavaElement)this.unitToSkip).getUnderlyingResource().getFullPath().toString();
+ } else {
+ excludePath = null;
+ }
+ int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
+ char[] qualification, simpleName;
+ if (lastDotIndex < 0){
+ qualification = null;
+ simpleName = CharOperation.toLowerCase(prefix);
+ } else {
+ qualification = CharOperation.subarray(prefix, 0, lastDotIndex);
+ simpleName = CharOperation.toLowerCase(CharOperation.subarray(prefix, lastDotIndex+1, prefix.length));
+ }
+
+ SearchEngine searchEngine = new SearchEngine();
- IProject projectRsc = (IProject) this.project.getUnderlyingResource();
- IJavaSearchScope scope =
- searchEngine.createJavaSearchScope(new IResource[] { projectRsc });
+ IProject projectRsc = (IProject) this.project.getUnderlyingResource();
+ IJavaSearchScope scope = searchEngine.createJavaSearchScope(new IResource[]{ projectRsc});
- IProgressMonitor progressMonitor = new IProgressMonitor() {
- boolean isCanceled = false;
- public void beginTask(String name, int totalWork) {
- }
- public void done() {
- }
- public void internalWorked(double work) {
- }
- public boolean isCanceled() {
- return isCanceled;
- }
- public void setCanceled(boolean value) {
- isCanceled = value;
- }
- public void setTaskName(String name) {
- }
- public void subTask(String name) {
- }
- public void worked(int work) {
- }
- };
- ITypeNameRequestor nameRequestor = new ITypeNameRequestor() {
- public void acceptClass(
- char[] packageName,
- char[] simpleTypeName,
- char[][] enclosingTypeNames,
- String path) {
- if (excludePath != null && excludePath.equals(path))
- return;
- if (enclosingTypeNames != null && enclosingTypeNames.length > 0)
- return; // accept only top level types
- storage.acceptClass(packageName, simpleTypeName, IConstants.AccPublic);
- }
- public void acceptInterface(
- char[] packageName,
- char[] simpleTypeName,
- char[][] enclosingTypeNames,
- String path) {
- if (excludePath != null && excludePath.equals(path))
- return;
- if (enclosingTypeNames != null && enclosingTypeNames.length > 0)
- return; // accept only top level types
- storage.acceptInterface(packageName, simpleTypeName, IConstants.AccPublic);
- }
- };
- try {
- searchEngine.searchAllTypeNames(
- projectRsc.getWorkspace(),
- qualification,
- simpleName,
- PREFIX_MATCH,
- CASE_INSENSITIVE,
- IJavaSearchConstants.TYPE,
- scope,
- nameRequestor,
- CANCEL_IF_NOT_READY_TO_SEARCH,
- progressMonitor);
- } catch (OperationCanceledException e) {
- findTypes(
- new String(prefix),
- storage,
- INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
+ IProgressMonitor progressMonitor = new IProgressMonitor(){
+ boolean isCanceled = false;
+ public void beginTask(String name, int totalWork){}
+ public void done(){}
+ public void internalWorked(double work){}
+ public boolean isCanceled(){ return isCanceled; }
+ public void setCanceled(boolean value){ isCanceled = value; }
+ public void setTaskName(String name){}
+ public void subTask(String name){}
+ public void worked(int work){}
+ };
+ ITypeNameRequestor nameRequestor = new ITypeNameRequestor(){
+ public void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path){
+ if (excludePath != null && excludePath.equals(path)) return;
+ if (enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types
+ storage.acceptClass(packageName, simpleTypeName, 0);
}
- } catch (JavaModelException e) {
- findTypes(
- new String(prefix),
- storage,
- INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
- }
- }
-
- /**
- * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
- *
- * If the <code>prefix</code> is unqualified, all types whose simple name matches
- * the <code>prefix</code> are returned.
- */
- private void findTypes(String prefix, ISearchRequestor storage, int type) {
- SearchableEnvironmentRequestor requestor =
- new SearchableEnvironmentRequestor(storage, this.unitToSkip);
- int index = prefix.lastIndexOf('.');
- if (index == -1) {
- this.nameLookup.seekTypes(prefix, null, true, type, requestor);
- } else {
- String packageName = prefix.substring(0, index);
- String className = prefix.substring(index + 1);
- JavaElementRequestor javaElementRequestor = new JavaElementRequestor();
- this.nameLookup.seekPackageFragments(packageName, false, javaElementRequestor);
- IPackageFragment[] packageFragments =
- javaElementRequestor.getPackageFragments();
- if (packageFragments == null)
- return;
- for (int i = 0, packagesLength = packageFragments.length;
- i < packagesLength;
- i++) {
- if (packageFragments[i] == null)
- continue;
- this.nameLookup.seekTypes(
- className,
- packageFragments[i],
- true,
- type,
- requestor);
+ public void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path){
+ if (excludePath != null && excludePath.equals(path)) return;
+ if (enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types
+ storage.acceptInterface(packageName, simpleTypeName, 0);
}
+ };
+ try {
+ searchEngine.searchAllTypeNames(
+ projectRsc.getWorkspace(),
+ qualification,
+ simpleName,
+ PREFIX_MATCH,
+ CASE_INSENSITIVE,
+ IJavaSearchConstants.TYPE,
+ scope,
+ nameRequestor,
+ CANCEL_IF_NOT_READY_TO_SEARCH,
+ progressMonitor);
+ } catch (OperationCanceledException e) {
+ findTypes(new String(prefix), storage, INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
}
+ } catch(JavaModelException e){
+ findTypes(new String(prefix), storage, INameLookup.ACCEPT_CLASSES | INameLookup.ACCEPT_INTERFACES);
}
-
- /**
- * @see SearchableBuilderEnvironment
- */
- public boolean isPackage(char[][] parentPackageName, char[] subPackageName) {
- if (parentPackageName == null || parentPackageName.length == 0)
- return isTopLevelPackage(subPackageName);
- if (subPackageName == null)
- return false;
- int length = parentPackageName.length;
- StringBuffer buffer = new StringBuffer((length + 1) * 6);
- for (int i = 0; i < length; i++) {
- if (parentPackageName[i] == null || isQualified(parentPackageName[i]))
- return false;
- buffer.append(parentPackageName[i]);
- buffer.append('.');
- }
- if (isQualified(subPackageName)) {
- return false;
+}
+/**
+ * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
+ *
+ * If the <code>prefix</code> is unqualified, all types whose simple name matches
+ * the <code>prefix</code> are returned.
+ */
+private void findTypes(String prefix, ISearchRequestor storage, int type) {
+ SearchableEnvironmentRequestor requestor = new SearchableEnvironmentRequestor(storage, this.unitToSkip);
+ int index = prefix.lastIndexOf('.');
+ if (index == -1) {
+ this.nameLookup.seekTypes(prefix, null, true, type, requestor);
+ } else {
+ String packageName = prefix.substring(0, index);
+ String className = prefix.substring(index + 1);
+ JavaElementRequestor javaElementRequestor = new JavaElementRequestor();
+ this.nameLookup.seekPackageFragments(packageName, false, javaElementRequestor);
+ IPackageFragment[] packageFragments = javaElementRequestor.getPackageFragments();
+ if (packageFragments == null)
+ return;
+ for (int i = 0, packagesLength = packageFragments.length; i < packagesLength; i++) {
+ if (packageFragments[i] == null)
+ continue;
+ this.nameLookup.seekTypes(className, packageFragments[i], true, type, requestor);
}
- buffer.append(subPackageName);
- boolean result =
- this.nameLookup.findPackageFragments(buffer.toString(), false) != null;
- return result;
-
}
-
- /**
- * Returns true if there are no '.' characters in the given name.
- */
- protected boolean isQualified(char[] name) {
- if (name != null) {
- return CharOperation.indexOf('.', name) > -1;
- }
+}
+/**
+ * @see SearchableBuilderEnvironment
+ */
+public boolean isPackage(char[][] parentPackageName, char[] subPackageName) {
+ if (parentPackageName == null || parentPackageName.length == 0)
+ return isTopLevelPackage(subPackageName);
+ if (subPackageName == null)
return false;
- }
-
- /**
- * @see SearchableBuilderEnvironment
- */
- public boolean isTopLevelPackage(char[] packageName) {
- if (packageName == null)
+ int length = parentPackageName.length;
+ StringBuffer buffer = new StringBuffer((length + 1) * 6);
+ for(int i = 0; i < length; i++) {
+ if (parentPackageName[i] == null || isQualified(parentPackageName[i]))
return false;
- boolean result =
- !isQualified(packageName)
- && this.nameLookup.findPackageFragments(new String(packageName), false) != null;
- return result;
-
+ buffer.append(parentPackageName[i]);
+ buffer.append('.');
}
-
- /**
- * Returns a printable string for the array.
- */
- protected String toStringChar(char[] name) {
- return "[" //$NON-NLS-1$
- + new String(name) + "]" ; //$NON-NLS-1$
+ if (isQualified(subPackageName)) {
+ return false;
+ }
+ buffer.append(subPackageName);
+ boolean result= this.nameLookup.findPackageFragments(buffer.toString(), false) != null;
+ return result;
+
+}
+/**
+ * Returns true if there are no '.' characters in the given name.
+ */
+protected boolean isQualified(char[] name) {
+ if (name != null) {
+ return CharOperation.indexOf('.', name) > -1;
}
+ return false;
+}
+/**
+ * @see SearchableBuilderEnvironment
+ */
+public boolean isTopLevelPackage(char[] packageName) {
+ if (packageName == null)
+ return false;
+ boolean result= !isQualified(packageName)
+ && this.nameLookup.findPackageFragments(new String(packageName), false) != null;
+ return result;
- /**
- * Returns a printable string for the array.
- */
- protected String toStringCharChar(char[][] names) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < names.length; i++) {
- result.append(toStringChar(names[i]));
- }
- return result.toString();
+}
+/**
+ * Returns a printable string for the array.
+ */
+protected String toStringChar(char[] name) {
+ return "["/*nonNLS*/ + new String(name) + "]"/*nonNLS*/;
+}
+/**
+ * Returns a printable string for the array.
+ */
+protected String toStringCharChar(char[][] names) {
+ StringBuffer result= new StringBuffer();
+ for (int i= 0; i < names.length; i++) {
+ result.append(toStringChar(names[i]));
}
-} \ No newline at end of file
+ return result.toString();
+}
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
index cbbe9420fc..bc94fbc0b3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
@@ -60,7 +60,7 @@ protected void acceptBinaryMethod(IType type, char[] selector, char[][] paramete
for (int i= 0, max = parameterTypeNames.length; i < max; i++) {
String pkg = IPackageFragment.DEFAULT_PACKAGE_NAME;
if (parameterPackageNames[i] != null && parameterPackageNames[i].length > 0) {
- pkg = new String(parameterPackageNames[i]) + "."; //$NON-NLS-1$
+ pkg = new String(parameterPackageNames[i]) + "."/*nonNLS*/;
}
parameterTypes[i]= Signature.createTypeSignature(
pkg + new String(parameterTypeNames[i]), true);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
index 2cd405cff7..a945598be8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
@@ -57,7 +57,7 @@ public SetClasspathOperation(IJavaProject project, IClasspathEntry[] oldResolved
* Sets the classpath of the pre-specified project.
*/
protected void executeOperation() throws JavaModelException {
- beginTask(Util.bind("classpath.settingProgress"), 2); //$NON-NLS-1$
+ beginTask(Util.bind("classpath.settingProgress"/*nonNLS*/), 2);
JavaProject project= ((JavaProject) getElementsToProcess()[0]);
project.setRawClasspath0(this.newRawPath);
@@ -164,7 +164,9 @@ public IJavaModelStatus verify() {
if (!status.isOK()) {
return status;
}
+ IClasspathEntry[] classpath = this.newRawPath;
IJavaProject javaProject = (IJavaProject)getElementToProcess();
+ IPath projectPath= javaProject.getProject().getFullPath();
// retrieve output location
IPath outputLocation;
@@ -174,7 +176,49 @@ public IJavaModelStatus verify() {
return e.getJavaModelStatus();
}
- return JavaConventions.validateClasspath(javaProject, this.newRawPath, outputLocation);
+ // check if any source entries coincidates with binary output - in which case nesting inside output is legal
+ boolean allowNestingInOutput = false;
+ boolean hasSource = false;
+ for (int i = 0 ; i < classpath.length; i++) {
+ if (classpath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) hasSource = true;
+ if (classpath[i].getPath().equals(outputLocation)){
+ allowNestingInOutput = true;
+ break;
+ }
+ }
+ if (!hasSource) allowNestingInOutput = true; // if no source, then allowed
+
+ // check all entries
+ for (int i = 0 ; i < classpath.length; i++) {
+ IClasspathEntry entry = classpath[i];
+ IPath entryPath = entry.getPath();
+
+ // no further check if entry coincidates with project or output location
+ if (entryPath.equals(projectPath)) continue;
+ if (entryPath.equals(outputLocation)) continue;
+
+ // prevent nesting source entries in each other
+ if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
+ for (int j = 0; j < classpath.length; j++){
+ IClasspathEntry otherEntry = classpath[j];
+ if (entry != otherEntry && otherEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
+ if (entryPath.isPrefixOf(otherEntry.getPath())){
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, entryPath);
+ }
+ }
+ }
+ }
+ // prevent nesting output location inside entry
+ if (entryPath.isPrefixOf(outputLocation)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, entryPath);
+ }
+
+ // prevent nesting entry inside output location - when distinct from project or a source folder
+ if (!allowNestingInOutput && outputLocation.isPrefixOf(entryPath)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, entryPath);
+ }
+ }
+ return JavaModelStatus.VERIFIED_OK;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetOutputLocationOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetOutputLocationOperation.java
index 591a6cf085..3ea30489fc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetOutputLocationOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetOutputLocationOperation.java
@@ -85,7 +85,7 @@ protected Vector determineAffectedPackageFragments(IPath location) throws JavaMo
IPath relativePath = f.getFullPath().removeFirstSegments(segments);
String name = relativePath.toOSString();
name = name.replace(File.pathSeparatorChar, '.');
- if (name.endsWith(".")) { //$NON-NLS-1$
+ if (name.endsWith("."/*nonNLS*/)) {
name = name.substring(0, name.length() - 1);
}
IPackageFragment pkg = root.getPackageFragment(name);
@@ -104,7 +104,7 @@ protected Vector determineAffectedPackageFragments(IPath location) throws JavaMo
* a package fragment.
*/
protected void executeOperation() throws JavaModelException {
- beginTask(Util.bind("classpath.settingOutputLocationProgress"), 2); //$NON-NLS-1$
+ beginTask(Util.bind("classpath.settingOutputLocationProgress"/*nonNLS*/), 2);
JavaProject project= ((JavaProject) getElementsToProcess()[0]);
IPath oldLocation= project.getOutputLocation();
@@ -166,6 +166,27 @@ public IJavaModelStatus verify() {
if (!status.isOK()) {
return status;
}
+ if (fOutputLocation == null) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NULL_PATH);
+ }
+
+ if (fOutputLocation.isAbsolute()) {
+ IProject project = ((IJavaProject) fElementsToProcess[0]).getProject();
+
+ if (project.getFullPath().isPrefixOf(fOutputLocation)) {
+ //project relative path
+ String projectName = fOutputLocation.segment(0);
+ if (!projectName.equals(fElementsToProcess[0].getElementName())) {
+ //a workspace relative path outside of this project
+ return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, fOutputLocation);
+ }
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.DEVICE_PATH, fOutputLocation);
+ }
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, fOutputLocation);
+ }
+
// retrieve classpath
IClasspathEntry[] classpath = null;
IJavaProject javaProject= (IJavaProject)getElementToProcess();
@@ -175,6 +196,38 @@ public IJavaModelStatus verify() {
} catch (JavaModelException e) {
return e.getJavaModelStatus();
}
- return JavaConventions.validateClasspath((IJavaProject) fElementsToProcess[0], classpath, fOutputLocation);
+
+ // check if any source entries coincidates with binary output - in which case nesting inside output is legal
+ boolean allowNestingInOutput = false;
+ boolean hasSource = false;
+ for (int i = 0 ; i < classpath.length; i++) {
+ if (classpath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) hasSource = true;
+ if (classpath[i].getPath().equals(fOutputLocation)){
+ allowNestingInOutput = true;
+ break;
+ }
+ }
+ if (!hasSource) allowNestingInOutput = true; // if no source, then allowed
+
+ // check all entries
+ for (int i = 0 ; i < classpath.length; i++) {
+ IClasspathEntry entry = classpath[i];
+ IPath entryPath = entry.getPath();
+
+ // no further check if entry coincidates with project or output location
+ if (entryPath.equals(projectPath)) continue;
+ if (entryPath.equals(fOutputLocation)) continue;
+
+ // prevent nesting output location inside entry
+ if (entryPath.isPrefixOf(fOutputLocation)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, fOutputLocation);
+ }
+
+ // prevent nesting entry inside output location - when distinct from project or a source folder
+ if (!allowNestingInOutput && fOutputLocation.isPrefixOf(entryPath)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, fOutputLocation);
+ }
+ }
+ return JavaModelStatus.VERIFIED_OK;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
index 388b019eb2..00d5b06bd1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
@@ -53,14 +53,14 @@ public String getTypeSignature() throws JavaModelException {
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (info == null) {
buffer.append(getElementName());
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
} else {
try {
buffer.append(Signature.toString(this.getTypeSignature()));
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
buffer.append(this.getElementName());
} catch (JavaModelException e) {
- buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
+ buffer.append("<JavaModelException in toString of "/*nonNLS*/ + getElementName());
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
index 5272368335..ffeceb9999 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
@@ -31,9 +31,7 @@ import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
* @see AttachSourceOperation
* @see JarPackageFragment
*/
-public class SourceMapper
- extends ReferenceInfoAdapter
- implements ISourceElementRequestor {
+public class SourceMapper extends ReferenceInfoAdapter implements ISourceElementRequestor {
/**
* The binary type source is being mapped for
@@ -72,7 +70,7 @@ public class SourceMapper
/**
* The unknown source range {-1, 0}
*/
- protected static SourceRange fgUnknownRange = new SourceRange(-1, 0);
+ protected static SourceRange fgUnknownRange= new SourceRange(-1, 0);
/**
* The position within the source of the start of the
@@ -98,602 +96,420 @@ public class SourceMapper
protected IJavaElement searchedElement;
/**
- * imports references
- */
- private Hashtable importsTable;
- private Hashtable importsCounterTable;
-
- /**
* Enclosing type information
*/
- IType[] types;
- int[] typeDeclarationStarts;
- SourceRange[] typeNameRanges;
- int typeDepth;
- /**
- * Creates a <code>SourceMapper</code> that locates source in the zip file
- * at the given location in the specified package fragment root.
- */
- public SourceMapper(IPath zipPath, String rootPath, JavaModel model) {
- fZipPath = zipPath;
- fRootPath = rootPath.replace('\\', '/');
- if (fRootPath.endsWith("/" )) { //$NON-NLS-1$
- fRootPath = fRootPath.substring(0, fRootPath.lastIndexOf('/'));
- }
- fJavaModel = model;
- fSourceRanges = new Hashtable();
- importsTable = new Hashtable();
- importsCounterTable = new Hashtable();
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void acceptImport(
- int declarationStart,
- int declarationEnd,
- char[] name,
- boolean onDemand) {
- char[][] imports = (char[][]) this.importsTable.get(fType);
- int importsCounter;
- if (imports == null) {
- imports = new char[5][];
- importsCounter = 0;
- } else {
- importsCounter = ((Integer) this.importsCounterTable.get(fType)).intValue();
- }
- if (imports.length == importsCounter) {
- System.arraycopy(
- imports,
- 0,
- (imports = new char[importsCounter * 2][]),
- 0,
- importsCounter);
- }
- imports[importsCounter++] = name;
- this.importsTable.put(fType, imports);
- this.importsCounterTable.put(fType, new Integer(importsCounter));
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void acceptInitializer(
- int modifiers,
- int declarationSourceStart,
- int declarationSourceEnd) {
- //do nothing
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void acceptLineSeparatorPositions(int[] positions) {
- //do nothing
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void acceptPackage(
- int declarationStart,
- int declarationEnd,
- char[] name) {
- //do nothing
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void acceptProblem(IProblem problem) {
- //do nothing
- }
-
- /**
- * Closes this <code>SourceMapper</code>'s zip file. Once this is done, this
- * <code>SourceMapper</code> cannot be used again.
- */
- public void close() throws JavaModelException {
- fSourceRanges = null;
- }
-
- /**
- * Converts these type names to signatures.
- * @see Signature.
- */
- public String[] convertTypeNamesToSigs(char[][] typeNames) {
- if (typeNames == null)
- return fgEmptyStringArray;
- int n = typeNames.length;
- if (n == 0)
- return fgEmptyStringArray;
- String[] typeSigs = new String[n];
- for (int i = 0; i < n; ++i) {
- typeSigs[i] = Signature.createTypeSignature(typeNames[i], false);
- }
- return typeSigs;
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterClass(
- int declarationStart,
- int modifiers,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[] superclass,
- char[][] superinterfaces) {
+ IType[] types;
+ int[] typeDeclarationStarts;
+ SourceRange[] typeNameRanges;
+ int typeDepth;
+/**
+ * Creates a <code>SourceMapper</code> that locates source in the zip file
+ * at the given location in the specified package fragment root.
+ */
+public SourceMapper(IPath zipPath, String rootPath, JavaModel model) {
+ fZipPath= zipPath;
+ fRootPath= rootPath.replace('\\', '/');
+ if (fRootPath.endsWith("/"/*nonNLS*/)) {
+ fRootPath = fRootPath.substring(0, fRootPath.lastIndexOf('/'));
+ }
+ fJavaModel= model;
+ fSourceRanges= new Hashtable();
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
+ //do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptInitializer(int modifiers, int declarationSourceStart, int declarationSourceEnd) {
+ //do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptLineSeparatorPositions(int[] positions) {
+ //do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptPackage(int declarationStart, int declarationEnd, char[] name) {
+ //do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void acceptProblem(IProblem problem) {
+ //do nothing
+}
+/**
+ * Closes this <code>SourceMapper</code>'s zip file. Once this is done, this
+ * <code>SourceMapper</code> cannot be used again.
+ */
+public void close() throws JavaModelException {
+ fSourceRanges= null;
+}
+/**
+ * Converts these type names to signatures.
+ * @see Signature.
+ */
+public String[] convertTypeNamesToSigs(char[][] typeNames) {
+ if (typeNames == null)
+ return fgEmptyStringArray;
+ int n = typeNames.length;
+ if (n == 0)
+ return fgEmptyStringArray;
+ String[] typeSigs = new String[n];
+ for (int i = 0; i < n; ++i) {
+ typeSigs[i] = Signature.createTypeSignature(typeNames[i], false);
+ }
+ return typeSigs;
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces) {
- this.typeDepth++;
- if (this.typeDepth == this.types.length) { // need to grow
- System.arraycopy(
- this.types,
- 0,
- this.types = new IType[this.typeDepth * 2],
- 0,
- this.typeDepth);
- System.arraycopy(
- this.typeNameRanges,
- 0,
- this.typeNameRanges = new SourceRange[this.typeDepth * 2],
- 0,
- this.typeDepth);
- System.arraycopy(
- this.typeDeclarationStarts,
- 0,
- this.typeDeclarationStarts = new int[this.typeDepth * 2],
- 0,
- this.typeDepth);
- }
- this.types[typeDepth] = this.getType(new String(name));
- this.typeNameRanges[typeDepth] =
- new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- this.typeDeclarationStarts[typeDepth] = declarationStart;
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterCompilationUnit() {
- // do nothing
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterConstructor(
- int declarationStart,
- int modifiers,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes) {
- enterMethod(
- declarationStart,
- modifiers,
- null,
- name,
- nameSourceStart,
- nameSourceEnd,
- parameterTypes,
- parameterNames,
- exceptionTypes);
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterField(
- int declarationStart,
- int modifiers,
- char[] type,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd) {
- if (typeDepth >= 0
- && fMemberDeclarationStart == -1) {
- // don't allow nested member (can only happen with anonymous inner classes)
- fMemberDeclarationStart = declarationStart;
- fMemberNameRange =
- new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- fMemberName = new String(name);
- }
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterInterface(
- int declarationStart,
- int modifiers,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] superinterfaces) {
- enterClass(
- declarationStart,
- modifiers,
- name,
- nameSourceStart,
- nameSourceEnd,
- null,
- superinterfaces);
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void enterMethod(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes) {
- if (typeDepth >= 0
- && fMemberDeclarationStart == -1) {
- // don't allow nested member (can only happen with anonymous inner classes)
- fMemberName = new String(name);
- fMemberNameRange =
- new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- fMemberDeclarationStart = declarationStart;
- fMethodParameterTypes = parameterTypes;
- }
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitClass(int declarationEnd) {
- if (typeDepth >= 0) {
- IType currentType = this.types[typeDepth];
- setSourceRange(
- currentType,
- new SourceRange(
- this.typeDeclarationStarts[typeDepth],
- declarationEnd - this.typeDeclarationStarts[typeDepth] + 1),
- this.typeNameRanges[typeDepth]);
- this.typeDepth--;
- }
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitCompilationUnit(int declarationEnd) {
- //do nothing
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitConstructor(int declarationEnd) {
- exitMethod(declarationEnd);
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitField(int declarationEnd) {
- if (typeDepth >= 0 && fMemberDeclarationStart != -1) {
- IType currentType = this.types[typeDepth];
- setSourceRange(
- currentType.getField(fMemberName),
- new SourceRange(
- fMemberDeclarationStart,
- declarationEnd - fMemberDeclarationStart + 1),
- fMemberNameRange);
- fMemberDeclarationStart = -1;
- }
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitInterface(int declarationEnd) {
- exitClass(declarationEnd);
- }
-
- /**
- * @see ISourceElementRequestor
- */
- public void exitMethod(int declarationEnd) {
- if (typeDepth >= 0 && fMemberDeclarationStart != -1) {
- IType currentType = this.types[typeDepth];
- SourceRange sourceRange =
- new SourceRange(
- fMemberDeclarationStart,
- declarationEnd - fMemberDeclarationStart + 1);
- setSourceRange(
- currentType.getMethod(
- fMemberName,
- convertTypeNamesToSigs(fMethodParameterTypes)),
- sourceRange,
- fMemberNameRange);
- fMemberDeclarationStart = -1;
- }
- }
-
- /**
- * Locates and returns source code for the given (binary) type, in this
- * SourceMapper's ZIP file, or returns <code>null</code> if source
- * code cannot be found.
- */
- public char[] findSource(IType type) {
- if (!type.isBinary()) {
- return null;
- }
- BinaryType parent = (BinaryType) type.getDeclaringType();
- BinaryType declType = (BinaryType) type;
- while (parent != null) {
- declType = parent;
- parent = (BinaryType) declType.getDeclaringType();
- }
- IBinaryType info = null;
- try {
- info = (IBinaryType) declType.getRawInfo();
- } catch (JavaModelException e) {
- return null;
- }
- return this.findSource(type, info);
+ this.typeDepth++;
+ if (this.typeDepth == this.types.length){ // need to grow
+ System.arraycopy(this.types, 0, this.types = new IType[this.typeDepth*2], 0, this.typeDepth);
+ System.arraycopy(this.typeNameRanges, 0, this.typeNameRanges = new SourceRange[this.typeDepth*2], 0, this.typeDepth);
+ System.arraycopy(this.typeDeclarationStarts, 0, this.typeDeclarationStarts = new int[this.typeDepth*2], 0, this.typeDepth);
+ }
+ this.types[typeDepth] = this.getType(new String(name));
+ this.typeNameRanges[typeDepth] = new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
+ this.typeDeclarationStarts[typeDepth] = declarationStart;
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterCompilationUnit() {
+ // do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterConstructor(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {
+ enterMethod(declarationStart, modifiers, null, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes);
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterField(int declarationStart, int modifiers, char[] type, char[] name, int nameSourceStart, int nameSourceEnd) {
+ if (typeDepth >= 0 && fMemberDeclarationStart == -1) { // don't allow nested member (can only happen with anonymous inner classes)
+ fMemberDeclarationStart= declarationStart;
+ fMemberNameRange= new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
+ fMemberName= new String(name);
+ }
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces) {
+ enterClass(declarationStart, modifiers, name, nameSourceStart, nameSourceEnd, null, superinterfaces);
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void enterMethod(int declarationStart, int modifiers, char[] returnType, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {
+ if (typeDepth >= 0 && fMemberDeclarationStart == -1) { // don't allow nested member (can only happen with anonymous inner classes)
+ fMemberName= new String(name);
+ fMemberNameRange= new SourceRange(nameSourceStart, nameSourceEnd - nameSourceStart + 1);
+ fMemberDeclarationStart= declarationStart;
+ fMethodParameterTypes= parameterTypes;
+ }
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitClass(int declarationEnd) {
+ if (typeDepth >= 0) {
+ IType currentType = this.types[typeDepth];
+ setSourceRange(
+ currentType,
+ new SourceRange(
+ this.typeDeclarationStarts[typeDepth] ,
+ declarationEnd - this.typeDeclarationStarts[typeDepth] + 1),
+ this.typeNameRanges[typeDepth]);
+ this.typeDepth--;
+ }
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitCompilationUnit(int declarationEnd) {
+ //do nothing
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitConstructor(int declarationEnd) {
+ exitMethod(declarationEnd);
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitField(int declarationEnd) {
+ if (typeDepth >= 0 && fMemberDeclarationStart != -1) {
+ IType currentType = this.types[typeDepth];
+ setSourceRange(currentType.getField(fMemberName), new SourceRange(fMemberDeclarationStart, declarationEnd - fMemberDeclarationStart + 1), fMemberNameRange);
+ fMemberDeclarationStart = -1;
}
-
- /**
- * Locates and returns source code for the given (binary) type, in this
- * SourceMapper's ZIP file, or returns <code>null</code> if source
- * code cannot be found.
- */
- public char[] findSource(IType type, IBinaryType info) {
- char[] sourceFileName = info.sourceFileName();
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitInterface(int declarationEnd) {
+ exitClass(declarationEnd);
+}
+/**
+ * @see ISourceElementRequestor
+ */
+public void exitMethod(int declarationEnd) {
+ if (typeDepth >= 0 && fMemberDeclarationStart != -1) {
+ IType currentType = this.types[typeDepth];
+ SourceRange sourceRange= new SourceRange(fMemberDeclarationStart, declarationEnd - fMemberDeclarationStart + 1);
+ setSourceRange(currentType.getMethod(fMemberName, convertTypeNamesToSigs(fMethodParameterTypes)), sourceRange, fMemberNameRange);
+ fMemberDeclarationStart = -1;
+ }
+}
+/**
+ * Locates and returns source code for the given (binary) type, in this
+ * SourceMapper's ZIP file, or returns <code>null</code> if source
+ * code cannot be found.
+ */
+public char[] findSource(IType type) {
+ if (!type.isBinary()) {
+ return null;
+ }
+ BinaryType parent= (BinaryType)type.getDeclaringType();
+ BinaryType declType= (BinaryType)type;
+ while (parent != null) {
+ declType= parent;
+ parent= (BinaryType)declType.getDeclaringType();
+ }
+ IBinaryType info= null;
+ try {
+ info= (IBinaryType)declType.getRawInfo();
+ } catch (JavaModelException e) {
+ return null;
+ }
+ return this.findSource(type, info);
+}
+/**
+ * Locates and returns source code for the given (binary) type, in this
+ * SourceMapper's ZIP file, or returns <code>null</code> if source
+ * code cannot be found.
+ */
+public char[] findSource(IType type, IBinaryType info) {
+ String name = null;
+ // see 1FVVWZT
+ if (info instanceof ClassFileReader) {
+ char[] sourceFileName = ((ClassFileReader) info).sourceFileName();
if (sourceFileName == null)
return null; // no source file attribute
- String name = new String(sourceFileName);
+ name = new String(sourceFileName);
+ } else {
+ return null;
+ }
- IPackageFragment pkgFrag = type.getPackageFragment();
- if (!pkgFrag.isDefaultPackage()) {
- String pkg = type.getPackageFragment().getElementName().replace('.', '/');
- name = pkg + '/' + name;
+ IPackageFragment pkgFrag = type.getPackageFragment();
+ if (!pkgFrag.isDefaultPackage()) {
+ String pkg= type.getPackageFragment().getElementName().replace('.', '/');
+ name= pkg + '/' + name;
+ }
+ // try to get the entry
+ ZipEntry entry= null;
+ ZipFile zip = null;
+ char[] source= null;
+ try {
+ String fullName;
+ //add the root path if specified
+ if (!fRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
+ fullName= fRootPath + '/' + name;
+ } else {
+ fullName= name;
}
- // try to get the entry
- ZipEntry entry = null;
- ZipFile zip = null;
- char[] source = null;
- try {
- String fullName;
- //add the root path if specified
- if (!fRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
- fullName = fRootPath + '/' + name;
- } else {
- fullName = name;
- }
- zip = getZip();
- entry = zip.getEntry(fullName);
- if (entry != null) {
- // now read the source code
- byte[] bytes = readEntry(zip, entry);
- if (bytes != null) {
- try {
- source = BufferManager.bytesToChar(bytes);
- } catch (JavaModelException e) {
- source = null;
- }
- }
- }
- } catch (CoreException e) {
- return null;
- } finally {
- if (zip != null) {
+ zip = getZip();
+ entry= zip.getEntry(fullName);
+ if (entry != null) {
+ // now read the source code
+ byte[] bytes= readEntry(zip, entry);
+ if (bytes != null) {
try {
- zip.close();
- } catch (IOException e) {
+ source= BufferManager.bytesToChar(bytes);
+ } catch (JavaModelException e) {
+ source= null;
}
}
}
- return source;
- }
-
- /**
- * Returns the SourceRange for the name of the given element, or
- * {-1, -1} if no source range is known for the name of the element.
- */
- public SourceRange getNameRange(IJavaElement element) {
- if (element.getElementType() == IJavaElement.METHOD
- && ((IMember) element).isBinary()) {
- element = getUnqualifiedMethodHandle((IMethod) element);
- }
- SourceRange[] ranges = (SourceRange[]) fSourceRanges.get(element);
- if (ranges == null) {
- return fgUnknownRange;
- } else {
- return ranges[1];
+ } catch (CoreException e) {
+ return null;
+ } finally {
+ if (zip != null) {
+ try {
+ zip.close();
+ } catch(IOException e) {}
}
}
-
- /**
- * Returns the <code>SourceRange</code> for the given element, or
- * {-1, -1} if no source range is known for the element.
- */
- public SourceRange getSourceRange(IJavaElement element) {
- if (element.getElementType() == IJavaElement.METHOD
- && ((IMember) element).isBinary()) {
- element = getUnqualifiedMethodHandle((IMethod) element);
- }
- SourceRange[] ranges = (SourceRange[]) fSourceRanges.get(element);
- if (ranges == null) {
- return fgUnknownRange;
- } else {
- return ranges[0];
- }
- }
-
- /**
- * Returns the type with the given <code>typeName</code>. Returns inner classes
- * as well.
- */
- protected IType getType(String typeName) {
- if (fType.getElementName().equals(typeName))
- return fType;
- else
- return fType.getType(typeName);
+ return source;
+}
+/**
+ * Returns the SourceRange for the name of the given element, or
+ * {-1, -1} if no source range is known for the name of the element.
+ */
+public SourceRange getNameRange(IJavaElement element) {
+ if (element.getElementType() == IJavaElement.METHOD && ((IMember)element).isBinary()) {
+ element= getUnqualifiedMethodHandle((IMethod)element);
}
-
- /**
- * Creates a handle that has parameter types that are not
- * fully qualified so that the correct source is found.
- */
- protected IJavaElement getUnqualifiedMethodHandle(IMethod method) {
-
- String[] qualifiedParameterTypes = method.getParameterTypes();
- String[] unqualifiedParameterTypes = new String[qualifiedParameterTypes.length];
- for (int i = 0; i < qualifiedParameterTypes.length; i++) {
- StringBuffer unqualifiedName = new StringBuffer();
- String qualifiedName = qualifiedParameterTypes[i];
- int count = 0;
- while (qualifiedName.charAt(count) == Signature.C_ARRAY) {
- unqualifiedName.append(Signature.C_ARRAY);
- ++count;
- }
- if (qualifiedName.charAt(count) == Signature.C_RESOLVED) {
- unqualifiedName.append(Signature.C_UNRESOLVED);
- unqualifiedName.append(Signature.getSimpleName(qualifiedName));
- } else {
- unqualifiedName.append(qualifiedName.substring(count, qualifiedName.length()));
- }
- unqualifiedParameterTypes[i] = unqualifiedName.toString();
- }
- return ((IType) method.getParent()).getMethod(
- method.getElementName(),
- unqualifiedParameterTypes);
+ SourceRange[] ranges= (SourceRange[])fSourceRanges.get(element);
+ if (ranges == null) {
+ return fgUnknownRange;
+ } else {
+ return ranges[1];
}
-
- /**
- * Returns the <code>ZipFile</code> that source is located in.
- */
- public ZipFile getZip() throws CoreException {
- return fJavaModel.fgJavaModelManager.getZipFile(fZipPath);
+}
+/**
+ * Returns the <code>SourceRange</code> for the given element, or
+ * {-1, -1} if no source range is known for the element.
+ */
+public SourceRange getSourceRange(IJavaElement element) {
+ if (element.getElementType() == IJavaElement.METHOD && ((IMember)element).isBinary()) {
+ element= getUnqualifiedMethodHandle((IMethod)element);
}
-
- /**
- * Maps the given source code to the given binary type and its children.
- */
- public void mapSource(IType type, char[] contents) {
- this.mapSource(type, contents, null);
+ SourceRange[] ranges= (SourceRange[])fSourceRanges.get(element);
+ if (ranges == null) {
+ return fgUnknownRange;
+ } else {
+ return ranges[0];
}
-
- /**
- * Maps the given source code to the given binary type and its children.
- * If a non-null java element is passed, finds the name range for the
- * given java element without storing it.
- */
- public ISourceRange mapSource(
- IType type,
- char[] contents,
- IJavaElement searchedElement) {
- fType = (BinaryType) type;
-
- this.importsTable.remove(fType);
- this.importsCounterTable.remove(fType);
- this.searchedElement = searchedElement;
- this.types = new IType[1];
- this.typeDeclarationStarts = new int[1];
- this.typeNameRanges = new SourceRange[1];
- this.typeDepth = -1;
+}
+/**
+ * Returns the type with the given <code>typeName</code>. Returns inner classes
+ * as well.
+ */
+protected IType getType(String typeName) {
+ if (fType.getElementName().equals(typeName))
+ return fType;
+ else
+ return fType.getType(typeName);
+}
+/**
+ * Creates a handle that has parameter types that are not
+ * fully qualified so that the correct source is found.
+ */
+protected IJavaElement getUnqualifiedMethodHandle(IMethod method) {
- Hashtable oldSourceRanges = (Hashtable) fSourceRanges.clone();
- try {
- IProblemFactory factory = new DefaultProblemFactory();
- SourceElementParser parser = new SourceElementParser(this, factory);
- parser.parseCompilationUnit(
- new BasicCompilationUnit(contents, type.getElementName() + ".java" ), //$NON-NLS-1$
- false);
- if (searchedElement != null) {
- ISourceRange range = this.getNameRange(searchedElement);
- return range;
- } else {
- return null;
- }
- } finally {
- if (searchedElement != null) {
- fSourceRanges = oldSourceRanges;
- }
- fType = null;
- this.searchedElement = null;
- this.types = null;
- this.typeDeclarationStarts = null;
- this.typeNameRanges = null;
- this.typeDepth = -1;
+ String[] qualifiedParameterTypes = method.getParameterTypes();
+ String[] unqualifiedParameterTypes = new String[qualifiedParameterTypes.length];
+ for (int i = 0; i < qualifiedParameterTypes.length; i++) {
+ StringBuffer unqualifiedName= new StringBuffer();
+ String qualifiedName= qualifiedParameterTypes[i];
+ int count = 0;
+ while (qualifiedName.charAt(count) == Signature.C_ARRAY) {
+ unqualifiedName.append(Signature.C_ARRAY);
+ ++count;
+ }
+ if (qualifiedName.charAt(count) == Signature.C_RESOLVED) {
+ unqualifiedName.append(Signature.C_UNRESOLVED);
+ unqualifiedName.append(Signature.getSimpleName(qualifiedName));
+ } else {
+ unqualifiedName.append(qualifiedName.substring(count, qualifiedName.length()));
}
+ unqualifiedParameterTypes[i]= unqualifiedName.toString();
}
-
- /**
- * Returns the contents of the specified zip entry
- */
- protected byte[] readEntry(ZipFile zip, ZipEntry entry) {
- InputStream stream = null;
- try {
- stream = zip.getInputStream(entry);
- int remaining = (int) entry.getSize();
- byte[] bytes = new byte[remaining];
- int offset = 0;
- while (remaining > 0) {
- int read = stream.read(bytes, offset, remaining);
- if (read == -1)
- break;
- remaining -= read;
- offset += read;
- }
- return bytes;
- } catch (IOException e) {
- return null;
- } catch (ArrayIndexOutOfBoundsException e) {
+ return ((IType) method.getParent()).getMethod(method.getElementName(), unqualifiedParameterTypes);
+}
+/**
+ * Returns the <code>ZipFile</code> that source is located in.
+ */
+public ZipFile getZip() throws CoreException {
+ return fJavaModel.fgJavaModelManager.getZipFile(fZipPath);
+}
+/**
+ * Maps the given source code to the given binary type and its children.
+ */
+public void mapSource(IType type, char[] contents) {
+ this.mapSource(type, contents, null);
+}
+/**
+ * Maps the given source code to the given binary type and its children.
+ * If a non-null java element is passed, finds the name range for the
+ * given java element without storing it.
+ */
+public ISourceRange mapSource(IType type, char[] contents, IJavaElement searchedElement) {
+ fType= (BinaryType)type;
+
+ this.searchedElement = searchedElement;
+ this.types = new IType[1];
+ this.typeDeclarationStarts = new int[1];
+ this.typeNameRanges = new SourceRange[1];
+ this.typeDepth = -1;
+
+ Hashtable oldSourceRanges = (Hashtable)fSourceRanges.clone();
+ try {
+ IProblemFactory factory= new DefaultProblemFactory();
+ SourceElementParser parser = new SourceElementParser(this, factory);
+ parser.parseCompilationUnit(new BasicCompilationUnit(contents, type.getElementName() + ".java"/*nonNLS*/), false);
+ if (searchedElement != null) {
+ ISourceRange range = this.getNameRange(searchedElement);
+ return range;
+ } else {
return null;
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException ioe) {
- }
- }
}
+ } finally {
+ if (searchedElement != null) {
+ fSourceRanges = oldSourceRanges;
+ }
+ fType= null;
+ this.searchedElement = null;
+ this.types = null;
+ this.typeDeclarationStarts = null;
+ this.typeNameRanges = null;
+ this.typeDepth = -1;
}
-
- /**
- * Sets the mapping for this element to its source ranges for its source range
- * and name range.
- *
- * @see fSourceRanges
- */
- protected void setSourceRange(
- IJavaElement element,
- SourceRange sourceRange,
- SourceRange nameRange) {
- fSourceRanges.put(element, new SourceRange[] { sourceRange, nameRange });
- }
-
- /**
- * Return a char[][] array containing the imports of the attached source for the fType binary
- */
- public char[][] getImports(BinaryType type) {
- char[][] imports = (char[][]) this.importsTable.get(type);
- if (imports != null) {
- int importsCounter = ((Integer) this.importsCounterTable.get(type)).intValue();
- if (imports.length != importsCounter) {
- System.arraycopy(
- imports,
- 0,
- (imports = new char[importsCounter][]),
- 0,
- importsCounter);
+}
+/**
+ * Returns the contents of the specified zip entry
+ */
+protected byte[] readEntry(ZipFile zip, ZipEntry entry) {
+ InputStream stream = null;
+ try {
+ stream = zip.getInputStream(entry);
+ int remaining = (int) entry.getSize();
+ byte[] bytes = new byte[remaining];
+ int offset = 0;
+ while (remaining > 0) {
+ int read = stream.read(bytes, offset, remaining);
+ if (read == -1)
+ break;
+ remaining -= read;
+ offset += read;
+ }
+ return bytes;
+ } catch (IOException e) {
+ return null;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException ioe) {
}
}
- this.importsTable.put(type, imports);
- return imports;
}
-} \ No newline at end of file
+}
+/**
+ * Sets the mapping for this element to its source ranges for its source range
+ * and name range.
+ *
+ * @see fSourceRanges
+ */
+protected void setSourceRange(IJavaElement element, SourceRange sourceRange, SourceRange nameRange) {
+ fSourceRanges.put(element, new SourceRange[] {sourceRange, nameRange});
+}
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
index d8cad208ed..e522c94da0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
@@ -145,7 +145,7 @@ public String readableName() {
for (int i = 0; i < length; i++) {
buffer.append(Signature.toString(parameterTypes[i]));
if (i < length - 1) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
}
}
@@ -192,11 +192,11 @@ protected boolean signatureEquals(IDOMMethod method) throws JavaModelException {
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (info == null) {
buffer.append(getElementName());
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
} else {
try {
if (Flags.isStatic(this.getFlags())) {
- buffer.append("static "); //$NON-NLS-1$
+ buffer.append("static "/*nonNLS*/);
}
if (!this.isConstructor()) {
buffer.append(Signature.toString(this.getReturnType()));
@@ -210,13 +210,13 @@ protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
for (int i = 0; i < length; i++) {
buffer.append(Signature.toString(parameterTypes[i]));
if (i < length - 1) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
}
}
buffer.append(')');
} catch (JavaModelException e) {
- buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
+ buffer.append("<JavaModelException in toString of "/*nonNLS*/ + getElementName());
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
index 22ad270995..e0aa4054a3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
@@ -33,11 +33,11 @@ public int getOffset() {
}
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("[offset="); //$NON-NLS-1$
+ buffer.append("[offset="/*nonNLS*/);
buffer.append(this.offset);
- buffer.append(", length="); //$NON-NLS-1$
+ buffer.append(", length="/*nonNLS*/);
buffer.append(this.length);
- buffer.append("]"); //$NON-NLS-1$
+ buffer.append("]"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
index c1ee0d573b..c0f0f428ab 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
@@ -23,7 +23,7 @@ protected SourceRefElement(int type, IJavaElement parent, String name) {
*/
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] containers= new IJavaElement[] {container};
@@ -104,7 +104,7 @@ public IResource getUnderlyingResource() throws JavaModelException {
*/
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (container == null) {
- throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("operation.nullContainer"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] containers= new IJavaElement[] {container};
@@ -163,7 +163,7 @@ public void offsetSourceRange(int amount) {
*/
public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
}
IJavaElement[] elements= new IJavaElement[] {this};
IJavaElement[] dests= new IJavaElement[] {this.getParent()};
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
index e94abc998c..3fffc3fa6f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
@@ -263,7 +263,7 @@ public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaMode
*/
public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
if (project == null) {
- throw new IllegalArgumentException(Util.bind("hierarchy.nullProject")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("hierarchy.nullProject"/*nonNLS*/));
}
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(
@@ -306,7 +306,7 @@ public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor mo
}
TypeResolveRequestor requestor = new TypeResolveRequestor();
SelectionEngine engine =
- new SelectionEngine(environment, requestor, JavaModelManager.getOptions());
+ new SelectionEngine(environment, requestor, JavaModelManager.convertConfigurableOptions(JavaCore.getOptions()));
engine.selectType(info, typeName.toCharArray());
return requestor.answers;
@@ -317,17 +317,17 @@ public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor mo
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
if (info == null) {
buffer.append(this.getElementName());
- buffer.append(" (not open)"); //$NON-NLS-1$
+ buffer.append(" (not open)"/*nonNLS*/);
} else {
try {
if (this.isInterface()) {
- buffer.append("interface "); //$NON-NLS-1$
+ buffer.append("interface "/*nonNLS*/);
} else {
- buffer.append("class "); //$NON-NLS-1$
+ buffer.append("class "/*nonNLS*/);
}
buffer.append(this.getElementName());
} catch (JavaModelException e) {
- buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
+ buffer.append("<JavaModelException in toString of "/*nonNLS*/ + getElementName());
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
index bc8facf788..11c365754f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
@@ -89,12 +89,12 @@ public void removeAll() {
size = 0;
}
public String toString() {
- StringBuffer buffer = new StringBuffer("["); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("["/*nonNLS*/);
for (int i = 0; i < size; i++) {
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
buffer.append(elements[i]);
}
- buffer.append("\n]"); //$NON-NLS-1$
+ buffer.append("\n]"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
index 179bd21717..4c39fff104 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
@@ -42,16 +42,16 @@ public class Util {
/* Bundle containing messages */
protected static ResourceBundle bundle;
- private final static String bundleName = "org.eclipse.jdt.internal.core.Messages"; //$NON-NLS-1$
+ private final static String bundleName = "org.eclipse.jdt.internal.core.Messages"/*nonNLS*/;
- public final static char[] SUFFIX_class = ".class".toCharArray(); //$NON-NLS-1$
- public final static char[] SUFFIX_CLASS = ".CLASS".toCharArray(); //$NON-NLS-1$
- public final static char[] SUFFIX_java = ".java".toCharArray(); //$NON-NLS-1$
- public final static char[] SUFFIX_JAVA = ".JAVA".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_class = ".class"/*nonNLS*/.toCharArray();
+ public final static char[] SUFFIX_CLASS = ".CLASS"/*nonNLS*/.toCharArray();
+ public final static char[] SUFFIX_java = ".java"/*nonNLS*/.toCharArray();
+ public final static char[] SUFFIX_JAVA = ".JAVA"/*nonNLS*/.toCharArray();
static {
- String ver = System.getProperty("java.version"); //$NON-NLS-1$
- JDK1_1 = ((ver != null) && ver.startsWith("1.1")); //$NON-NLS-1$
+ String ver = System.getProperty("java.version"/*nonNLS*/);
+ JDK1_1 = ((ver != null) && ver.startsWith("1.1"/*nonNLS*/));
relocalize();
}
/**
@@ -155,8 +155,8 @@ public static int compare(char[] v1, char[] v2) {
* @see concat(String, String)
*/
public static String concat(String s1, char c, String s2) {
- if (s1 == null) s1 = "null"; //$NON-NLS-1$
- if (s2 == null) s2 = "null"; //$NON-NLS-1$
+ if (s1 == null) s1 = "null"/*nonNLS*/;
+ if (s2 == null) s2 = "null"/*nonNLS*/;
int l1 = s1.length();
int l2 = s2.length();
char[] buf = new char[l1 + 1 + l2];
@@ -176,8 +176,8 @@ public static int compare(char[] v1, char[] v2) {
* String constructor copies its argument, but there's no way around this.
*/
public static String concat(String s1, String s2) {
- if (s1 == null) s1 = "null"; //$NON-NLS-1$
- if (s2 == null) s2 = "null"; //$NON-NLS-1$
+ if (s1 == null) s1 = "null"/*nonNLS*/;
+ if (s2 == null) s2 = "null"/*nonNLS*/;
int l1 = s1.length();
int l2 = s2.length();
char[] buf = new char[l1 + l2];
@@ -190,9 +190,9 @@ public static int compare(char[] v1, char[] v2) {
* @see concat(String, String)
*/
public static String concat(String s1, String s2, String s3) {
- if (s1 == null) s1 = "null"; //$NON-NLS-1$
- if (s2 == null) s2 = "null"; //$NON-NLS-1$
- if (s3 == null) s3 = "null"; //$NON-NLS-1$
+ if (s1 == null) s1 = "null"/*nonNLS*/;
+ if (s2 == null) s2 = "null"/*nonNLS*/;
+ if (s3 == null) s3 = "null"/*nonNLS*/;
int l1 = s1.length();
int l2 = s2.length();
int l3 = s3.length();
@@ -772,14 +772,14 @@ public static String bind(String id) {
*/
public static String bind(String id, String[] bindings) {
if (id == null)
- return "No message available"; //$NON-NLS-1$
+ return "No message available"/*nonNLS*/;
String message = null;
try {
message = bundle.getString(id);
} catch (MissingResourceException e) {
// If we got an exception looking for the message, fail gracefully by just returning
// the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
+ return "Missing message: "/*nonNLS*/ + id + " in: "/*nonNLS*/ + bundleName;
}
if (bindings == null)
return message;
@@ -798,7 +798,7 @@ public static String bind(String id, String[] bindings) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
+ output.append("{missing "/*nonNLS*/ + Integer.toString(index) + "}"/*nonNLS*/);
}
} else {
output.append(message.substring(end, length));
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
index a3e0388669..d2dde904a8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
@@ -306,7 +306,7 @@ public void restore() throws JavaModelException {
*/
protected void toString(int tab, StringBuffer buffer) {
buffer.append(this.tabString(tab));
- buffer.append("(working copy)\n"); //$NON-NLS-1$
+ buffer.append("(working copy)\n"/*nonNLS*/);
super.toString(tab, buffer);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/DeltaKey.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/DeltaKey.java
index e2d57f388b..4810cf9d22 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/DeltaKey.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/DeltaKey.java
@@ -340,15 +340,15 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
public String toString () {
StringBuffer buffer = new StringBuffer();
- buffer.append("DeltaKey("); //$NON-NLS-1$
+ buffer.append("DeltaKey("/*nonNLS*/);
for (int i = 0; i < this.fLocalNames.length; i++) {
buffer.append(this.fLocalNames[i]);
if (i < this.fLocalNames.length - 1) {
- buffer.append("/"); //$NON-NLS-1$
+ buffer.append("/"/*nonNLS*/);
}
}
- buffer.append(")"); //$NON-NLS-1$
+ buffer.append(")"/*nonNLS*/);
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMemberHandle.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMemberHandle.java
index 657031b40b..3440f6455c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMemberHandle.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMemberHandle.java
@@ -24,7 +24,7 @@ public abstract class AbstractMemberHandle extends NonStateSpecificHandleImpl im
String computeSignature(String name, IType[] parameterTypes) {
if (parameterTypes.length == 0) {
- return name + "()"; //$NON-NLS-1$
+ return name + "()"/*nonNLS*/;
}
StringBuffer sb = new StringBuffer(name);
@@ -33,7 +33,7 @@ public abstract class AbstractMemberHandle extends NonStateSpecificHandleImpl im
try {
((TypeImpl)parameterTypes[i]).appendSignature(sb, true);
} catch (ClassCastException e) {
- throw new StateSpecificException("Incompatible parameter types"); //$NON-NLS-1$
+ throw new StateSpecificException("Incompatible parameter types"/*nonNLS*/);
}
}
sb.append(')');
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMethodCollaboratorIndictment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMethodCollaboratorIndictment.java
index 59418a235e..b6c4016445 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMethodCollaboratorIndictment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractMethodCollaboratorIndictment.java
@@ -41,6 +41,6 @@ protected AbstractMethodCollaboratorIndictment(IType type) {
*/
public String toString() {
// don't use + with char[]
- return new StringBuffer("AbstractMethodCollaboratorIndictment(").append(fName).append(")").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ return new StringBuffer("AbstractMethodCollaboratorIndictment("/*nonNLS*/).append(fName).append(")"/*nonNLS*/).toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractNode.java
index 4d61463b45..bb54ba75d5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/AbstractNode.java
@@ -119,7 +119,7 @@ try {
/* add the dependent */
fDependents[min] = nodeThatDependsOnMe;
} catch (ArrayIndexOutOfBoundsException e) {
- System.out.println("ArrayIndexOutOfBoundsException in AbstractNode.copyAddDependent()"); //$NON-NLS-1$
+ System.out.println("ArrayIndexOutOfBoundsException in AbstractNode.copyAddDependent()"/*nonNLS*/);
}
}
/**
@@ -148,28 +148,28 @@ try {
* For debugging only.
*/
public void dump(Dumper dumper) {
- dumper.dump("element", getElement()); //$NON-NLS-1$
+ dumper.dump("element"/*nonNLS*/, getElement());
if (getKind() == JCU_NODE)
- dumper.dump("types", getTypes()); //$NON-NLS-1$
+ dumper.dump("types"/*nonNLS*/, getTypes());
Object[] dependencies = new Object[fDependencies.length];
for (int i = 0; i < fDependencies.length; ++i) {
dependencies[i] = fDependencies[i].getElement();
}
- dumper.dump("dependencies", dependencies); //$NON-NLS-1$
+ dumper.dump("dependencies"/*nonNLS*/, dependencies);
Object[] dependents = new Object[fNumDependents];
for (int i = 0; i < fDependents.length; ++i) {
dependents[i] = fDependents[i].getElement();
}
- dumper.dump("dependents", dependents); //$NON-NLS-1$
+ dumper.dump("dependents"/*nonNLS*/, dependents);
}
/**
* Make sure equality tests are never carried out on nodes
*/
public boolean equals(Object o) {
- Assert.isTrue(false, "Internal Error - Equality not defined for dependency graph nodes"); //$NON-NLS-1$
+ Assert.isTrue(false, "Internal Error - Equality not defined for dependency graph nodes"/*nonNLS*/);
return false;
}
/**
@@ -338,7 +338,7 @@ public void dump(Dumper dumper) {
for (int i = 0; i < recursionLevel; ++i)
sb.append(' ');
sb.append(this);
- sb.append(": "); //$NON-NLS-1$
+ sb.append(": "/*nonNLS*/);
sb.append(refCount);
System.out.println(sb.toString());
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ArrayTypeHandleImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ArrayTypeHandleImpl.java
index 12c57b273a..ac15d5b35f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ArrayTypeHandleImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ArrayTypeHandleImpl.java
@@ -96,7 +96,7 @@ TypeImpl getElementType() {
public String getName() {
String name = fElementType.getName();
for (int i = 0; i < fNestingDepth; i++)
- name += "[]"; //$NON-NLS-1$
+ name += "[]"/*nonNLS*/;
return name;
}
/**
@@ -111,7 +111,7 @@ int getNestingDepth() {
public String getSimpleName() {
String simpleName = fElementType.getSimpleName();
for (int i = 0; i < fNestingDepth; i++)
- simpleName += "[]"; //$NON-NLS-1$
+ simpleName += "[]"/*nonNLS*/;
return simpleName;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BatchImageBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BatchImageBuilder.java
index 4b6e2c2b90..453d8b1799 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BatchImageBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BatchImageBuilder.java
@@ -39,6 +39,7 @@ public BatchImageBuilder(StateImpl state) {
*/
protected BatchImageBuilder(StateImpl state, ConfigurableOption[] options) {
fDC = (JavaDevelopmentContextImpl) state.getDevelopmentContext();
+ state.setCompilerOptions(options);
fCompilerOptions = options;
fNewState = state;
fWorkQueue = new WorkQueue();
@@ -53,15 +54,15 @@ public void build() {
fNotifier.begin();
try {
fNewState.readClassPath();
- fNotifier.subTask(Util.bind("build.scrubbingOutput")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.scrubbingOutput"/*nonNLS*/));
fNewState.getBinaryOutput().scrubOutput();
fNotifier.updateProgressDelta(0.05f);
- fNotifier.subTask(Util.bind("build.analyzingPackages")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzingPackages"/*nonNLS*/));
fNewState.buildInitialPackageMap();
fNotifier.updateProgressDelta(0.05f);
/* Force build all in build context */
- fNotifier.subTask(Util.bind("build.analyzingSources")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzingSources"/*nonNLS*/));
IPackage[] pkgs = fNewState.getPackageMap().getAllPackagesAsArray();
for (int i = 0; i < pkgs.length; ++i) {
fNotifier.checkCancel();
@@ -104,13 +105,13 @@ public IDelta getImageDelta(IImageContext imageContext) {
public void lazyBuild(PackageElement unit) {
// String msg = "Attempt to lazy build " + unit.getPackage().getName() + "." + unit.getFileName();
// System.err.println(msg + ". " + "Lazy building has been disabled.");
- Assert.isTrue(false, "Internal Error - Lazy building has been disabled"); //$NON-NLS-1$
+ Assert.isTrue(false, "Internal Error - Lazy building has been disabled"/*nonNLS*/);
}
/**
* Returns a string describe the builder
* @see IImageBuilder
*/
public String toString() {
- return "batch image builder for:\n\tnew state: " + getNewState(); //$NON-NLS-1$
+ return "batch image builder for:\n\tnew state: "/*nonNLS*/ + getNewState();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BuildNotifier.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BuildNotifier.java
index 1e84777f42..fb4f4c9251 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BuildNotifier.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/BuildNotifier.java
@@ -46,10 +46,10 @@ public BuildNotifier(JavaDevelopmentContextImpl dc, boolean isBatch) {
}
public void begin() {
if (fBuildMonitor != null) {
- fBuildMonitor.beginBuild(fIsBatch ? Util.bind("build.beginBatch") : Util.bind("build.beginIncremental")); //$NON-NLS-2$ //$NON-NLS-1$
+ fBuildMonitor.beginBuild(fIsBatch ? Util.bind("build.beginBatch"/*nonNLS*/) : Util.bind("build.beginIncremental"/*nonNLS*/));
}
if (fProgress != null) {
- fProgress.beginTask("", fTotalWork); //$NON-NLS-1$
+ fProgress.beginTask(""/*nonNLS*/, fTotalWork);
}
this.previousSubtask = null;
}
@@ -90,9 +90,9 @@ public void compiling(CompilerCompilationUnit unit) {
int start = message.indexOf('/', 1);
int end = message.lastIndexOf('/');
if (end <= start){
- message = Util.bind("build.compiling", message.substring(start+1)); //$NON-NLS-1$
+ message = Util.bind("build.compiling"/*nonNLS*/, message.substring(start+1));
} else {
- message = Util.bind("build.compilingContent", message.substring(start+1, end)); //$NON-NLS-1$
+ message = Util.bind("build.compilingContent"/*nonNLS*/, message.substring(start+1, end));
}
subTask(message);
updateProgressDelta(fProgressPerCompilationUnit/2);
@@ -100,12 +100,12 @@ public void compiling(CompilerCompilationUnit unit) {
}
public void done() {
updateProgress(1.0f);
- subTask(Util.bind("build.done")); //$NON-NLS-1$
+ subTask(Util.bind("build.done"/*nonNLS*/));
if (fProgress != null) {
fProgress.done();
}
if (fBuildMonitor != null) {
- fBuildMonitor.endBuild(fIsBatch ? Util.bind("build.endBatch") : Util.bind("build.endIncremental")); //$NON-NLS-2$ //$NON-NLS-1$
+ fBuildMonitor.endBuild(fIsBatch ? Util.bind("build.endBatch"/*nonNLS*/) : Util.bind("build.endIncremental"/*nonNLS*/));
}
this.previousSubtask = null;
}
@@ -154,16 +154,16 @@ protected String problemsMessage() {
int numNew = fNewErrorCount + fNewWarningCount;
int numFixed = fFixedErrorCount + fFixedWarningCount;
if (numNew == 0 && numFixed == 0) {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
if (numFixed == 0) {
- return '(' + numNew == 1 ? Util.bind("build.oneProblemFound", String.valueOf(numNew)) : Util.bind("build.problemsFound", String.valueOf(numNew)) +')'; //$NON-NLS-2$ //$NON-NLS-1$
+ return '(' + numNew == 1 ? Util.bind("build.oneProblemFound"/*nonNLS*/, String.valueOf(numNew)) : Util.bind("build.problemsFound"/*nonNLS*/, String.valueOf(numNew)) +')';
} else
if (numNew == 0) {
- return '(' + numFixed == 1 ? Util.bind("build.oneProblemFixed", String.valueOf(numFixed)) : Util.bind("build.problemsFixed", String.valueOf(numFixed)) + ')'; //$NON-NLS-2$ //$NON-NLS-1$
+ return '(' + numFixed == 1 ? Util.bind("build.oneProblemFixed"/*nonNLS*/, String.valueOf(numFixed)) : Util.bind("build.problemsFixed"/*nonNLS*/, String.valueOf(numFixed)) + ')';
} else {
- return '(' + (numFixed == 1 ? Util.bind("build.oneProblemFixed", String.valueOf(numFixed)) : Util.bind("build.problemsFixed", String.valueOf(numFixed))) //$NON-NLS-2$ //$NON-NLS-1$
- + (numNew == 1 ? Util.bind("build.oneProblemFound", String.valueOf(numNew)) : Util.bind("build.problemsFound", String.valueOf(numNew))) + ')'; //$NON-NLS-2$ //$NON-NLS-1$
+ return '(' + (numFixed == 1 ? Util.bind("build.oneProblemFixed"/*nonNLS*/, String.valueOf(numFixed)) : Util.bind("build.problemsFixed"/*nonNLS*/, String.valueOf(numFixed)))
+ + (numNew == 1 ? Util.bind("build.oneProblemFound"/*nonNLS*/, String.valueOf(numNew)) : Util.bind("build.problemsFound"/*nonNLS*/, String.valueOf(numNew))) + ')';
}
}
/**
@@ -183,7 +183,7 @@ public void setProgressPerCompilationUnit(float progress) {
}
public void subTask(String message) {
String pm = problemsMessage();
- String msg = pm.length() == 0 ? message : pm + " " + message; //$NON-NLS-1$
+ String msg = pm.length() == 0 ? message : pm + " "/*nonNLS*/ + message;
if (msg.equals(this.previousSubtask)) return; // avoid refreshing with same one
if (DEBUG) System.out.println(msg);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ClassOrInterfaceHandleImplSWH.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ClassOrInterfaceHandleImplSWH.java
index d4dadea883..6f5d52fc72 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ClassOrInterfaceHandleImplSWH.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ClassOrInterfaceHandleImplSWH.java
@@ -206,7 +206,7 @@ public int getDeclaredModifiers() throws NotPresentException {
public String getDeclaredName() throws NotPresentException {
if (isAnonymous()) {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
String name = fHandle.getSimpleName();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/CompilerCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/CompilerCompilationUnit.java
index a56bd4af4c..37a55091c4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/CompilerCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/CompilerCompilationUnit.java
@@ -64,6 +64,6 @@ public SourceEntry getSourceEntry() {
}
public String toString() {
// don't use append(char[]) due to JDK1.2 problems
- return new StringBuffer("CompilationUnit(").append(getFileName()).append(")").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ return new StringBuffer("CompilationUnit("/*nonNLS*/).append(getFileName()).append(")"/*nonNLS*/).toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConstructorImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConstructorImpl.java
index fe2ac0be92..260240acea 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConstructorImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConstructorImpl.java
@@ -9,7 +9,7 @@ import org.eclipse.jdt.internal.core.builder.*;
public class ConstructorImpl extends AbstractMemberHandle implements IConstructor {
ConstructorImpl (ClassOrInterfaceHandleImpl owner, IType[] paramTypes) {
fOwner = owner;
- fSignature = computeSignature("", paramTypes); //$NON-NLS-1$
+ fSignature = computeSignature(""/*nonNLS*/, paramTypes);
}
public ConstructorImpl(ClassOrInterfaceHandleImpl owner, String signature) {
fOwner = owner;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConvertedCompilationResult.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConvertedCompilationResult.java
index e2afe9c68c..d023e60cd2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConvertedCompilationResult.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ConvertedCompilationResult.java
@@ -38,6 +38,6 @@ ConvertedCompilationResult(
return fTypes;
}
public String toString() {
- return (fProblems.length == 0 ? "" : "*") + "ConvertedCompilationResult(" + fPackageElement + ")"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ return (fProblems.length == 0 ? ""/*nonNLS*/ : "*"/*nonNLS*/) + "ConvertedCompilationResult("/*nonNLS*/ + fPackageElement + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
index 7d0040a654..5407ba1f24 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
@@ -28,17 +28,17 @@ class DeltaImpl implements IDelta {
protected IImageContext fContext;
/* names for checklist items */
- public static final String fgImage = "Image"; //$NON-NLS-1$
+ public static final String fgImage = "Image"/*nonNLS*/;
- public static final String fgPackageCategory = "Packages"; //$NON-NLS-1$
- public static final String fgTypeCategory = "Types"; //$NON-NLS-1$
- public static final String fgBinaryCategory = "Binaries"; //$NON-NLS-1$
- public static final String fgMethodCategory = "Methods"; //$NON-NLS-1$
+ public static final String fgPackageCategory = "Packages"/*nonNLS*/;
+ public static final String fgTypeCategory = "Types"/*nonNLS*/;
+ public static final String fgBinaryCategory = "Binaries"/*nonNLS*/;
+ public static final String fgMethodCategory = "Methods"/*nonNLS*/;
- public static final String fgPackage = "Package"; //$NON-NLS-1$
- public static final String fgType = "Type"; //$NON-NLS-1$
- public static final String fgBinary = "Binary"; //$NON-NLS-1$
- public static final String fgMethod = "Method"; //$NON-NLS-1$
+ public static final String fgPackage = "Package"/*nonNLS*/;
+ public static final String fgType = "Type"/*nonNLS*/;
+ public static final String fgBinary = "Binary"/*nonNLS*/;
+ public static final String fgMethod = "Method"/*nonNLS*/;
/* convenience structure for delta calculation process */
class DeltaInfo {
@@ -99,7 +99,7 @@ class DeltaImpl implements IDelta {
fNewState = (StateImpl)newState;
fOldState = (StateImpl)oldState;
} catch (ClassCastException cce) {
- Assert.isTrue(false, "Internal Error - Invalid states"); //$NON-NLS-1$
+ Assert.isTrue(false, "Internal Error - Invalid states"/*nonNLS*/);
}
fStatus = CHANGED;
fName = fgImage;
@@ -200,7 +200,7 @@ protected int compareBuilderType(BuilderType type) {
*/
public int compareTo(IDelta anotherDelta) {
/* is this used? */
- Assert.isTrue(false, "TBD"); //$NON-NLS-1$
+ Assert.isTrue(false, "TBD"/*nonNLS*/);
return 0;
}
/**
@@ -606,7 +606,7 @@ protected int compareTypes(IType handle) {
}
protected static void dump(IDelta delta, int depth) {
for (int i = 0; i < depth; ++i)
- System.out.print(" "); //$NON-NLS-1$
+ System.out.print(" "/*nonNLS*/);
System.out.println(delta);
IDelta[] children = delta.getAffectedSubdeltas();
for (int i = 0; i < children.length; ++i) {
@@ -893,23 +893,23 @@ public Enumeration getAffectedPackages() {
* @return java.lang.String
*/
public String toString() {
- StringBuffer sb = new StringBuffer("DeltaImpl("); //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer("DeltaImpl("/*nonNLS*/);
switch (fStatus) {
- case ADDED: sb.append("+"); //$NON-NLS-1$
+ case ADDED: sb.append("+"/*nonNLS*/);
break;
- case REMOVED: sb.append("-"); //$NON-NLS-1$
+ case REMOVED: sb.append("-"/*nonNLS*/);
break;
- case CHANGED: sb.append("*"); //$NON-NLS-1$
+ case CHANGED: sb.append("*"/*nonNLS*/);
break;
- case SAME: sb.append("="); //$NON-NLS-1$
+ case SAME: sb.append("="/*nonNLS*/);
break;
- case UNKNOWN: sb.append("?"); //$NON-NLS-1$
+ case UNKNOWN: sb.append("?"/*nonNLS*/);
break;
- default: sb.append("(ERROR)"); //$NON-NLS-1$
+ default: sb.append("(ERROR)"/*nonNLS*/);
}
if (fKey.isRoot()) {
sb.append(fOldState);
- sb.append("-->"); //$NON-NLS-1$
+ sb.append("-->"/*nonNLS*/);
sb.append(fNewState);
}
else {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DependencyGraph.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DependencyGraph.java
index 2ffce7be21..feeaac13a6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DependencyGraph.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DependencyGraph.java
@@ -106,7 +106,7 @@ public void add(PackageElement resultUnit, IType[] types, Vector vDependencies)
}
catch (CloneNotSupportedException e) {
// Should not happen since we implement Cloneable
- Assert.isTrue(false, "Unexpected clone exception in DependencyGraph.clone()"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unexpected clone exception in DependencyGraph.clone()"/*nonNLS*/);
return null;
}
}
@@ -186,7 +186,7 @@ public void add(PackageElement resultUnit, IType[] types, Vector vDependencies)
value = fZips.remove(((ZipNode)toRemove).getZipFile());
break;
default:
- Assert.isTrue(false, "Attempt to delete unknown node type from dependency graph"); //$NON-NLS-1$
+ Assert.isTrue(false, "Attempt to delete unknown node type from dependency graph"/*nonNLS*/);
}
return (INode)value;
}
@@ -194,7 +194,7 @@ public void add(PackageElement resultUnit, IType[] types, Vector vDependencies)
* For debugging only. Dump the graph in readable form.
*/
public void dump(Dumper dumper) {
- dumper.dumpMessage("Namespaces", ""); //$NON-NLS-2$ //$NON-NLS-1$
+ dumper.dumpMessage("Namespaces"/*nonNLS*/, ""/*nonNLS*/);
dumper.indent();
for (Enumeration e = fNamespaces.elements(); e.hasMoreElements();) {
AbstractNode node = (AbstractNode) e.nextElement();
@@ -202,7 +202,7 @@ public void dump(Dumper dumper) {
}
dumper.outdent();
- dumper.dumpMessage("JCUs", ""); //$NON-NLS-2$ //$NON-NLS-1$
+ dumper.dumpMessage("JCUs"/*nonNLS*/, ""/*nonNLS*/);
dumper.indent();
for (Enumeration e = fCompilationUnits.elements(); e.hasMoreElements();) {
AbstractNode node = (AbstractNode) e.nextElement();
@@ -210,7 +210,7 @@ public void dump(Dumper dumper) {
}
dumper.outdent();
- dumper.dumpMessage("ZIPs", ""); //$NON-NLS-2$ //$NON-NLS-1$
+ dumper.dumpMessage("ZIPs"/*nonNLS*/, ""/*nonNLS*/);
dumper.indent();
for (Enumeration e = fZips.elements(); e.hasMoreElements();) {
AbstractNode node = (AbstractNode) e.nextElement();
@@ -312,7 +312,7 @@ public Enumeration getJCUNodes() {
return getNodeFor((IPath)o, create);
}
else {
- Assert.isTrue(false, "Unknown kind of node"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unknown kind of node"/*nonNLS*/);
return null;
}
}
@@ -477,7 +477,7 @@ public Vector getUnusedNamespaceNodes() {
* For debugging only -- asserts graph integrity
*/
public void integrityCheck(Dictionary table) {
- String msg = "Internal Error: the dependency graph is corrupt, do a full build to workaround error"; //$NON-NLS-1$
+ String msg = "Internal Error: the dependency graph is corrupt, do a full build to workaround error"/*nonNLS*/;
for (Enumeration e = table.elements(); e.hasMoreElements();) {
AbstractNode node = (AbstractNode) e.nextElement();
@@ -564,6 +564,6 @@ public void removePackage(IPackage pkg) {
return fNamespaces.size() + fTypes.size() + fCompilationUnits.size();
}
public String toString() {
- return "a DependencyGraph"; //$NON-NLS-1$
+ return "a DependencyGraph"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldCollaboratorIndictment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldCollaboratorIndictment.java
index a838444518..9f30f029a4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldCollaboratorIndictment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldCollaboratorIndictment.java
@@ -24,6 +24,6 @@ protected FieldCollaboratorIndictment(char[] name) {
*/
public String toString() {
// don't use + with char[]
- return new StringBuffer("FieldIndictment(").append(fName).append(")").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ return new StringBuffer("FieldIndictment("/*nonNLS*/).append(fName).append(")"/*nonNLS*/).toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldImpl.java
index f5bbc14bfa..c2762ae8c0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/FieldImpl.java
@@ -44,6 +44,6 @@ public IHandle inState(IState s) throws org.eclipse.jdt.internal.core.builder.St
* toString method comment.
*/
public String toString() {
- return getDeclaringClass().getName() + "." + getName(); //$NON-NLS-1$
+ return getDeclaringClass().getName() + "."/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageBuilderInternalException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageBuilderInternalException.java
index 0f16b2f909..3c67b9ee96 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageBuilderInternalException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageBuilderInternalException.java
@@ -40,7 +40,7 @@ public Throwable getThrowable() {
public void printStackTrace() {
if (fThrowable != null) {
System.err.println(this);
- System.err.println("Stack trace of embedded throwable:"); //$NON-NLS-1$
+ System.err.println("Stack trace of embedded throwable:"/*nonNLS*/);
fThrowable.printStackTrace();
} else {
super.printStackTrace();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageContextImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageContextImpl.java
index 5a4fd511a0..210df5cc37 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageContextImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageContextImpl.java
@@ -88,9 +88,9 @@ public class ImageContextImpl implements IImageContext {
* purposes only.
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ImageContext with packages: \n"); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("ImageContext with packages: \n"/*nonNLS*/);
for (int i = 0; i < fPackages.length; i++)
- buf.append(" " + fPackages[i].getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(" "/*nonNLS*/ + fPackages[i].getName() + "\n"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImpl.java
index 41a3091b13..1bf30c241f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImpl.java
@@ -199,7 +199,7 @@ public org.eclipse.jdt.internal.core.builder.IType shortType() {
* Returns a string representation of the image handle.
*/
public String toString() {
- return "image"; //$NON-NLS-1$
+ return "image"/*nonNLS*/;
}
/**
* Returns the Type representing the primitive type void
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImplSWH.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImplSWH.java
index 6c8569537e..1d35cebf32 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImplSWH.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ImageImplSWH.java
@@ -114,7 +114,7 @@ public IType[] getAllClasses(IImageContext context) {
Vector vResult = new Vector();
// try {
String extension = path.getFileExtension().toLowerCase();
- if (extension.equals("java") || extension.equals("class")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (extension.equals("java"/*nonNLS*/) || extension.equals("class"/*nonNLS*/)) {
IPath pkgPath = path.removeLastSegments(1);
IPackage pkg = fState.getPathMap().packageHandleFromPath(pkgPath);
TypeStructureEntry[] tsEntries = fState.getAllTypesForPackage(pkg);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IncrementalImageBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IncrementalImageBuilder.java
index 398878fa64..224ee43ae6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IncrementalImageBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IncrementalImageBuilder.java
@@ -155,7 +155,7 @@ protected void addChangedFileNamesFromChangedPackage(IResourceDelta pkgDelta, Ha
IPath path = elementDelta.getFullPath();
String extension = path.getFileExtension();
if (extension != null) {
- if (extension.equalsIgnoreCase("java") || extension.equalsIgnoreCase("class")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (extension.equalsIgnoreCase("java"/*nonNLS*/) || extension.equalsIgnoreCase("class"/*nonNLS*/)) {
SourceEntry entry = new SourceEntry(path, null, null);
PackageElement element = new PackageElement(pkg, entry);
pkgTable.put(entry.getFileName(), element);
@@ -198,16 +198,17 @@ protected void addSourceElement(SourceEntry newEntry) {
public void applySourceDelta(Hashtable deltas) {
fNotifier = new BuildNotifier(fDC, false);
fNotifier.begin();
- fNotifier.subTask(Util.bind("build.preparingBuild")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.preparingBuild"/*nonNLS*/));
fSourceDeltas = deltas;
fNewState = fOldState.copy(fNewProject, fImageContext);
// options might have changed since last builder run, thus refresh them
- fCompilerOptions = JavaModelManager.getOptions();
+ fCompilerOptions = JavaModelManager.convertConfigurableOptions(JavaCore.getOptions());
+ fNewState.setCompilerOptions(fCompilerOptions);
try {
/* find out what has changed at the package level */
- fNotifier.subTask(Util.bind("build.analyzingPackages")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzingPackages"/*nonNLS*/));
computeAllPackages();
checkCancel();
@@ -235,7 +236,7 @@ public void applySourceDelta(Hashtable deltas) {
}
/* find out what has changed at the package element level */
- fNotifier.subTask(Util.bind("build.analyzingSources")); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzingSources"/*nonNLS*/));
computeAllClasses();
checkCancel();
@@ -559,7 +560,7 @@ protected void computeAllPackages(IResourceDelta delta, IPackageFragmentRoot[] o
for (int i = 0; i < oldRoots.length; i++) {
rootResource = null;
try {
- rootResource = oldRoots[i].getUnderlyingResource();
+ oldRoots[i].getUnderlyingResource();
} catch (JavaModelException e) {
}
if (rootResource != null && rootResource.getFullPath().isPrefixOf(path)) {
@@ -581,8 +582,8 @@ protected void computeAllPackages(IResourceDelta delta, IPackageFragmentRoot[] o
for (int i = 0; i < children.length; ++i) {
String extension = children[i].getFullPath().getFileExtension();
if (extension == null
- || extension.equalsIgnoreCase("zip") //$NON-NLS-1$
- || extension.equalsIgnoreCase("jar")) { //$NON-NLS-1$
+ || extension.equalsIgnoreCase("zip"/*nonNLS*/)
+ || extension.equalsIgnoreCase("jar"/*nonNLS*/)) {
// TBD: Currently rely on empty extension indicating folder
computeAllPackages(children[i], oldRoots, newRoots);
}
@@ -627,7 +628,7 @@ protected void computeNamespaceChanges() {
// Process added packages
for (Enumeration addedPkgs = fAddedPackageHandles.elements(); addedPkgs.hasMoreElements();) {
IPackage pkg = (IPackage) addedPkgs.nextElement();
- fNotifier.subTask(Util.bind("build.analyzing", PackageImpl.readableName(pkg))); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzing"/*nonNLS*/, PackageImpl.readableName(pkg)));
// Mark all dependents of missing namespace as needing compile.
markDependentsAsNeedingCompile(pkg);
@@ -642,7 +643,7 @@ protected void computeNamespaceChanges() {
// Process removed packages
for (Enumeration removedPkgs = fRemovedPackageHandles.elements(); removedPkgs.hasMoreElements();) {
IPackage pkg = (IPackage) removedPkgs.nextElement();
- fNotifier.subTask(Util.bind("build.analyzing", PackageImpl.readableName(pkg))); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzing"/*nonNLS*/, PackageImpl.readableName(pkg)));
// Mark all dependents of namespace as needing compile.
markDependentsAsNeedingCompile(pkg);
@@ -657,7 +658,7 @@ protected void computeNamespaceChanges() {
// Process changed packages
for (Enumeration changedPkgs = fChangedPackageHandles.elements(); changedPkgs.hasMoreElements();) {
IPackage pkg = (IPackage) changedPkgs.nextElement();
- fNotifier.subTask(Util.bind("build.analyzing", PackageImpl.readableName(pkg))); //$NON-NLS-1$
+ fNotifier.subTask(Util.bind("build.analyzing"/*nonNLS*/, PackageImpl.readableName(pkg)));
computeNamespaceChanges(pkg);
fNotifier.updateProgressDelta(progressDelta);
fNotifier.checkCancel();
@@ -670,7 +671,7 @@ protected void computeNamespaceChanges(Hashtable oldTSEntries, String parentType
String typeName = type.getElementName();
if (parentTypeName != null) {
int len = parentTypeName.length() + typeName.length() + 1;
- typeName = new StringBuffer(len).append(parentTypeName).append("$").append(typeName).toString(); //$NON-NLS-1$
+ typeName = new StringBuffer(len).append(parentTypeName).append("$"/*nonNLS*/).append(typeName).toString();
}
/* Remove it so that only non-matching ones remain in the table. */
TypeStructureEntry tsEntry = (TypeStructureEntry) oldTSEntries.remove(typeName);
@@ -913,7 +914,7 @@ static void dump(IResourceDelta delta) {
StringBuffer sb = new StringBuffer();
IPath path = delta.getFullPath();
for (int i = path.segmentCount(); --i > 0;) {
- sb.append(" "); //$NON-NLS-1$
+ sb.append(" "/*nonNLS*/);
}
switch (delta.getKind()) {
case IResourceDelta.ADDED:
@@ -1047,7 +1048,7 @@ protected Dictionary getSourceChanges(IPackage pkgHandle) {
/* skip non-java resources */
String extension = path.getFileExtension();
- if (extension != null && (extension.equalsIgnoreCase("java") || extension.equalsIgnoreCase("class"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (extension != null && (extension.equalsIgnoreCase("java"/*nonNLS*/) || extension.equalsIgnoreCase("class"/*nonNLS*/))) {
set.put(path, path);
}
}
@@ -1071,7 +1072,7 @@ protected boolean hasPackageMapChanges() {
IResourceDelta changed = (IResourceDelta) e.nextElement();
String extension = changed.getFullPath().getFileExtension();
if (extension != null) {
- if (extension.equalsIgnoreCase("zip") || extension.equalsIgnoreCase("jar")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (extension.equalsIgnoreCase("zip"/*nonNLS*/) || extension.equalsIgnoreCase("jar"/*nonNLS*/)) {
return true;
}
}
@@ -1126,7 +1127,7 @@ protected boolean hasSourceEntryChanges(IPackage pkgHandle) {
/* skip java resources */
String extension = path.getFileExtension();
if (extension != null) {
- if ((extension.equalsIgnoreCase("java") || extension.equalsIgnoreCase("class"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if ((extension.equalsIgnoreCase("java"/*nonNLS*/) || extension.equalsIgnoreCase("class"/*nonNLS*/))) {
/* if there is an added or removed jcu or binary, the source entries have changed */
int status = fileDeltas[j].getKind();
if (status == IResourceDelta.ADDED || status == IResourceDelta.REMOVED) {
@@ -1422,7 +1423,7 @@ protected void sort(PackageElement[] compileArray) {
* @see IImageBuilder
*/
public String toString() {
- return "incremental image builder for:\n" + "\tnew state: " + getNewState() + "\n" + "\told state: " + getOldState(); //$NON-NLS-1$ //$NON-NLS-4$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "incremental image builder for:\n"/*nonNLS*/ + "\tnew state: "/*nonNLS*/ + getNewState() + "\n"/*nonNLS*/ + "\told state: "/*nonNLS*/ + getOldState();
}
/**
* If this type is a subtype is the originator of an abstract method
@@ -1633,7 +1634,7 @@ protected boolean tryZeroArgConstructorInSuperclass(PackageElement unit, Indictm
for (int i = 0; i < types.length; ++i) {
IType superclass = getBuilderType(types[i]).getSuperclass();
if (superclass != null) {
- String key = '<' + superclass.getDeclaredName() + ">/0"; //$NON-NLS-1$
+ String key = '<' + superclass.getDeclaredName() + ">/0"/*nonNLS*/;
if (indictments.tryMethodEvidence(key.toCharArray())) {
return true;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IndictmentSet.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IndictmentSet.java
index c37effa7b2..b9040e53ca 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IndictmentSet.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/IndictmentSet.java
@@ -56,7 +56,7 @@ public class IndictmentSet {
fMethodOwners = new Hashtable(11);
fMethodOwners.put(owner, owner);
fMethodOwnersArray = null;
- if (i.getName().startsWith("<")) { //$NON-NLS-1$
+ if (i.getName().startsWith("<"/*nonNLS*/)) {
fHasConstructorIndictments = true;
}
break;
@@ -71,7 +71,7 @@ public class IndictmentSet {
fAbstractMethodTable.put(i.getKey(), i);
break;
default:
- Assert.isTrue(false, "Internal Error - Unexpected kind of indictment"); //$NON-NLS-1$
+ Assert.isTrue(false, "Internal Error - Unexpected kind of indictment"/*nonNLS*/);
break;
}
}
@@ -161,13 +161,13 @@ public void convictAll() {
*/
public String toString() {
return
- "IndictmentSet(" //$NON-NLS-1$
- + "\n hierarchyChange: " + fHierarchyChange //$NON-NLS-1$
- + "\n types:\n" + fTypesTable //$NON-NLS-1$
- + "\n interfaces:\n" + fAbstractMethodTable //$NON-NLS-1$
- + "\n methods:\n" + fMethodsTable //$NON-NLS-1$
- + "\n fields:\n" + fFieldsTable //$NON-NLS-1$
- + "\n)"; //$NON-NLS-1$
+ "IndictmentSet("/*nonNLS*/
+ + "\n hierarchyChange: "/*nonNLS*/ + fHierarchyChange
+ + "\n types:\n"/*nonNLS*/ + fTypesTable
+ + "\n interfaces:\n"/*nonNLS*/ + fAbstractMethodTable
+ + "\n methods:\n"/*nonNLS*/ + fMethodsTable
+ + "\n fields:\n"/*nonNLS*/ + fFieldsTable
+ + "\n)"/*nonNLS*/;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JCUNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JCUNode.java
index 3438cb221a..192d62644e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JCUNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JCUNode.java
@@ -86,6 +86,6 @@ public class JCUNode extends AbstractNode {
* purposes only.
*/
public String toString() {
- return "JCUNode(" + fUnit.getFileName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "JCUNode("/*nonNLS*/ + fUnit.getFileName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaBuilder.java
index f18efd9ed9..43dd321781 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaBuilder.java
@@ -60,7 +60,7 @@ public JavaBuilder() {
if (e.getThrowable() instanceof CoreException) {
throw (CoreException) e.getThrowable();
} else {
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("build.builderName"), e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("build.builderName"/*nonNLS*/), e));
}
} catch (OperationCanceledException e) {
// Do nothing for now, and avoid propagating the exception.
@@ -74,7 +74,7 @@ public JavaBuilder() {
// forcing a full build next time.
setLastBuiltState(null);
}
- if (monitor != null) monitor.subTask(Util.bind("build.completed")); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(Util.bind("build.completed"/*nonNLS*/));
}
return getRequiredProjects(getLastBuiltState(monitor));
}
@@ -93,28 +93,28 @@ public JavaBuilder() {
Hashtable deltas = new Hashtable(11);
IProject project = getProject();
- if (monitor != null) monitor.subTask(Util.bind("build.readingDelta", project.getName())); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(Util.bind("build.readingDelta"/*nonNLS*/, project.getName()));
IResourceDelta delta = getDelta(project);
if (delta == null){
//System.out.println("Missing delta for: "+ project.getName());
- if (monitor != null) monitor.subTask(""); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(""/*nonNLS*/);
return null;
} else {
deltas.put(project, delta);
}
IProject[] prereqs = getRequiredProjects(oldState);
for (int i = 0; i < prereqs.length; ++i) {
- if (monitor != null) monitor.subTask(Util.bind("build.readingDelta", prereqs[i].getName())); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(Util.bind("build.readingDelta"/*nonNLS*/, prereqs[i].getName()));
delta = getDelta(prereqs[i]);
if (delta == null){
//System.out.println("Missing delta for: "+ prereqs[i].getName());
- if (monitor != null) monitor.subTask(""); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(""/*nonNLS*/);
return null;
} else {
deltas.put(prereqs[i], delta);
}
}
- if (monitor != null) monitor.subTask(""); //$NON-NLS-1$
+ if (monitor != null) monitor.subTask(""/*nonNLS*/);
return deltas;
}
/**
@@ -127,7 +127,7 @@ protected boolean classpathChanged(IState lastBuiltState) throws CoreException {
return !Util.equalArraysOrNull(oldRoots, newRoots);
} catch (JavaModelException e) {
throw new CoreException(
- new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("element.projectDoesNotExist", getProject().getFullPath().toString()), e)); //$NON-NLS-1$
+ new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("element.projectDoesNotExist"/*nonNLS*/, getProject().getFullPath().toString()), e));
}
}
/**
@@ -143,7 +143,7 @@ protected boolean classpathChanged(IState lastBuiltState) throws CoreException {
/* create and invoke the batch builder */
// Pass the compiler options, needed for 1FVXS80: ITPJCORE:ALL - .class files are missing their LocalVariableTable
- ConfigurableOption[] options = JavaModelManager.getOptions();
+ ConfigurableOption[] options = JavaModelManager.convertConfigurableOptions(JavaCore.getOptions());
setLastBuiltState(null); // free possible existing state
IImageBuilder builder = dc.createState(project, null, problemReporter, options);
setLastBuiltState(builder.getNewState());
@@ -237,8 +237,8 @@ protected boolean isEmpty(IResourceDelta change) {
int flags = change.getFlags();
boolean contentChanged = isChanged && (flags & IResourceDelta.CONTENT) != 0;
String extension = change.getFullPath().getFileExtension();
- boolean isJavaOrClassFile = extension != null && (extension.equalsIgnoreCase("java") || extension.equalsIgnoreCase("class")); //$NON-NLS-1$ //$NON-NLS-2$
- boolean isArchive = extension != null && (extension.equalsIgnoreCase("zip") || extension.equalsIgnoreCase("jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean isJavaOrClassFile = extension != null && (extension.equalsIgnoreCase("java"/*nonNLS*/) || extension.equalsIgnoreCase("class"/*nonNLS*/));
+ boolean isArchive = extension != null && (extension.equalsIgnoreCase("zip"/*nonNLS*/) || extension.equalsIgnoreCase("jar"/*nonNLS*/));
// care about added, removed and modified (content actually modified) .java and .class files
if (isJavaOrClassFile && (isAdded || isRemoved || contentChanged))
@@ -288,7 +288,7 @@ protected boolean outputLocationChanged(IState lastBuiltState) throws CoreExcept
IPath newOutputLocation = getJavaProject().getOutputLocation();
return !oldOutputLocation.equals(newOutputLocation);
} catch (JavaModelException e) {
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("element.projectDoesNotExist", getProject().getFullPath().toString()), e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, Util.bind("element.projectDoesNotExist"/*nonNLS*/, getProject().getFullPath().toString()), e));
}
}
protected void setLastBuiltState(IState state) {
@@ -300,9 +300,9 @@ protected void setLastBuiltState(IState state) {
public String toString() {
IState lastBuiltState = getLastBuiltState(null);
if (lastBuiltState == null) {
- return "JavaBuilder(no built state)"; //$NON-NLS-1$
+ return "JavaBuilder(no built state)"/*nonNLS*/;
} else {
- return "JavaBuilder(" + lastBuiltState + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "JavaBuilder("/*nonNLS*/ + lastBuiltState + ")"/*nonNLS*/;
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaDevelopmentContextImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaDevelopmentContextImpl.java
index 118f597b18..3b894eac78 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaDevelopmentContextImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/JavaDevelopmentContextImpl.java
@@ -18,10 +18,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.ConfigurableOption;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.core.Util;
-import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.builder.IBinaryBroker;
import org.eclipse.jdt.internal.core.builder.IBuildListener;
import org.eclipse.jdt.internal.core.builder.IBuildMonitor;
@@ -72,12 +70,12 @@ public class JavaDevelopmentContextImpl implements IDevelopmentContext {
/**
* The default package.
*/
- private final IPackage fDefaultPackage = fImage.getPackageHandle("java.lang", false); //$NON-NLS-1$
+ private final IPackage fDefaultPackage = fImage.getPackageHandle("java.lang"/*nonNLS*/, false);
/**
* The root class handle
*/
- private final IType fRootClass = fDefaultPackage.getClassHandle("Object"); //$NON-NLS-1$
+ private final IType fRootClass = fDefaultPackage.getClassHandle("Object"/*nonNLS*/);
/**
* Primitive types
@@ -197,7 +195,7 @@ protected Vector getBuildListeners() {
}
public IState getCurrentState() throws NotPresentException {
if (fCurrentState == null) {
- throw new NotPresentException("Internal Error - No current state"); //$NON-NLS-1$
+ throw new NotPresentException("Internal Error - No current state"/*nonNLS*/);
}
return fCurrentState;
}
@@ -205,7 +203,15 @@ public IState getCurrentState() throws NotPresentException {
* Reads the default compiler options.
*/
protected static ConfigurableOption[] getDefaultCompilerOptions() {
- return JavaModelManager.getOptions();
+ ConfigurableOption[] options = Compiler.getDefaultOptions(Locale.getDefault());
+
+ /**
+ * Ugly because this requires knowledge of the compiler's
+ * internal problem representation.
+ */
+ setCompilerOption(options, 11, 1);
+ setCompilerOption(options, 12, 1);
+ return options;
}
/**
* Returns the default package handle (java.lang).
@@ -297,7 +303,7 @@ protected IType[] parameterTypesFromSignature(final String signature) {
char c = localSig.charAt(position);
if (c == 'L' || c == 'Q') {
/* its a class type */
- int endIndex = localSig.indexOf(";") + 1; //$NON-NLS-1$
+ int endIndex = localSig.indexOf(";"/*nonNLS*/) + 1;
parmType = classTypeFromName(localSig.substring(position, endIndex));
localSig = localSig.substring(endIndex);
} else {
@@ -399,7 +405,17 @@ public void setBinaryBroker(IBinaryBroker broker) {
*/
public void setBuildProgressListener(IProgressListener listener) {
}
-
+/**
+ * Sets a compiler option. This seems awkward.
+ */
+protected static void setCompilerOption(ConfigurableOption[] options, int optionID, int valueIndex) {
+ for (int i = 0; i < options.length; i++) {
+ if (options[i].getID() == optionID) {
+ options[i].setValueIndex(valueIndex);
+ return;
+ }
+ }
+}
/**
* setCurrentState method comment.
*/
@@ -413,6 +429,6 @@ public void setCurrentState(IState state) {
fProgressMonitor = monitor;
}
public String toString() {
- return "a JavaDevelopmentContextImpl(" + fCurrentState + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "a JavaDevelopmentContextImpl("/*nonNLS*/ + fCurrentState + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MarkerProblemReporter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MarkerProblemReporter.java
index 11927c5611..b98c6abf38 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MarkerProblemReporter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MarkerProblemReporter.java
@@ -1,5 +1,5 @@
package org.eclipse.jdt.internal.core.builder.impl;
-
+
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
@@ -7,12 +7,12 @@ package org.eclipse.jdt.internal.core.builder.impl;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-
+
import org.eclipse.jdt.internal.core.builder.*;
import org.eclipse.jdt.core.*;
-
+
import java.util.*;
-
+
/**
* An <code>IProblemReporter</code> that reports problems using the <code>IMarker</code> API.
@@ -120,22 +120,21 @@ public boolean hasProblems(Object sourceID) {
protected void markerFromProblemDetail(IResource resource, IProblemDetail problem) throws CoreException {
IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- int start = problem.getStartPos();
+
+ marker.setAttribute(IMarker.MESSAGE, problem.getMessage());
+
int sev = problem.getSeverity();
- marker.setAttributes(
- new String[]{ IMarker.MESSAGE, IMarker.SEVERITY, "ID", IMarker.CHAR_START, IMarker.CHAR_END, IMarker.LINE_NUMBER}, //$NON-NLS-1$
- new Object[]{
- problem.getMessage(),
- new Integer((sev & IProblemDetail.S_ERROR) != 0 ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING),
- new Integer(problem.getID()),
- new Integer(start),
- new Integer(problem.getEndPos() + 1),
- new Integer(problem.getLineNumber())
- });
-
+ marker.setAttribute(IMarker.SEVERITY , ((sev & IProblemDetail.S_ERROR) != 0 ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING));
if ((sev & ProblemDetailImpl.S_SYNTAX_ERROR) != 0) {
- marker.setAttribute(IJavaModelMarker.FLAGS, ProblemDetailImpl.S_SYNTAX_ERROR == 0 ? null : new Integer(ProblemDetailImpl.S_SYNTAX_ERROR));
+ setFlags(marker, ProblemDetailImpl.S_SYNTAX_ERROR);
}
+ marker.setAttribute("ID"/*nonNLS*/, new Integer(problem.getID()));
+
+ int start = problem.getStartPos();
+ marker.setAttribute(IMarker.CHAR_START, new Integer(start));
+ marker.setAttribute(IMarker.CHAR_END, new Integer(problem.getEndPos() + 1));
+ marker.setAttribute(IMarker.LINE_NUMBER, new Integer(problem.getLineNumber()));
+
// compute a user-friendly location
IJavaElement element = JavaCore.create(resource);
if (element instanceof ICompilationUnit){ // try to find a finer grain element
@@ -155,7 +154,7 @@ protected void markerFromProblemDetail(IResource resource, IProblemDetail proble
public void putProblem(Object sourceID, IProblemDetail problem) {
/* Delegate first to the backing problem table. */
fProblemTable.putProblem(sourceID, problem);
-
+
/* Now update the markers. */
IResource resource = getResource(sourceID);
if (resource != null) {
@@ -212,7 +211,7 @@ public void removeNonSyntaxErrors(Object sourceID) {
public void removeProblems(Object sourceID) {
/* Delegate first to the backing problem table. */
fProblemTable.removeProblems(sourceID);
-
+
/* Now update the markers. */
IResource resource = getResource(sourceID);
if (resource != null) {
@@ -237,13 +236,21 @@ public void removeSyntaxErrors(Object sourceID) {
removeMarkers(sourceID, true);
}
/**
+ * Sets the extra flags for the given marker.
+ */
+protected void setFlags(IMarker marker, int flags) throws CoreException {
+ // Don't take space if no extra flags.
+ marker.setAttribute(IJavaModelMarker.FLAGS, flags == 0 ? null : new Integer(flags));
+}
+
+/**
* Creates a new MarkerProblemReporter that reports problems as markers
* against the given project.
*/
public MarkerProblemReporter(IProject project, IDevelopmentContext dc) {
initialize(project, dc);
}
-
+
/**
* @see org.eclipse.jdt.internal.core.builder.IProblemReporter
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodCollaboratorIndictment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodCollaboratorIndictment.java
index bb99d279e2..4d8740ed2e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodCollaboratorIndictment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodCollaboratorIndictment.java
@@ -57,7 +57,7 @@ protected MethodCollaboratorIndictment(IType owner, char[] name, int parmCount)
* only (NON-NLS).
*/
public String toString() {
- StringBuffer buf = new StringBuffer("MethodIndictment("); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("MethodIndictment("/*nonNLS*/);
buf.append(fName);
buf.append('/');
buf.append(fParmCount);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodImpl.java
index 7864051a0b..9f37f904a1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/MethodImpl.java
@@ -61,14 +61,14 @@ public class MethodImpl extends AbstractMemberHandle implements IMethod {
* unqualified source signature format.
*/
protected String getSourceParameters() {
- String sourceSig = "("; //$NON-NLS-1$
+ String sourceSig = "("/*nonNLS*/;
/* append parameter types to signature */
IType[] parms = getParameterTypes();
for (int i = 0; i < parms.length; i++) {
sourceSig += parms[i].getSimpleName().replace('L', 'Q');
}
- sourceSig += ")"; //$NON-NLS-1$
+ sourceSig += ")"/*nonNLS*/;
return sourceSig;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ModifiedBuilderType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ModifiedBuilderType.java
index 74aea1cb36..283589f160 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ModifiedBuilderType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ModifiedBuilderType.java
@@ -249,7 +249,7 @@ public void setNewTypeStructureEntry(TypeStructureEntry newEntry) {
* For debugging only
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ModifiedBuilderType("); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("ModifiedBuilderType("/*nonNLS*/);
return buf.append(fOldTSEntry.getType().getName()).append(')').toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NamespaceNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NamespaceNode.java
index 2c53ebf0c1..852058220b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NamespaceNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NamespaceNode.java
@@ -62,6 +62,6 @@ public class NamespaceNode extends AbstractNode {
* purposes only.
*/
public String toString() {
- return "NamespaceNode(" + fPackage.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "NamespaceNode("/*nonNLS*/ + fPackage.getName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NewBuilderType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NewBuilderType.java
index aff7c6241f..1b40365c57 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NewBuilderType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NewBuilderType.java
@@ -48,6 +48,6 @@ public void setNewTypeStructureEntry(TypeStructureEntry newEntry) {
* For debugging only
*/
public String toString() {
- return "NewBuilderType(" + fNewTSEntry.getType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "NewBuilderType("/*nonNLS*/ + fNewTSEntry.getType().getName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NonStateSpecificHandleImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NonStateSpecificHandleImpl.java
index 71dde7667d..2b5be96a65 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NonStateSpecificHandleImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/NonStateSpecificHandleImpl.java
@@ -9,7 +9,7 @@ import org.eclipse.jdt.internal.core.builder.*;
public abstract class NonStateSpecificHandleImpl implements IHandle {
public boolean equals(Object obj) {
- Assert.isTrue(false, "TBD"); //$NON-NLS-1$
+ Assert.isTrue(false, "TBD"/*nonNLS*/);
return false;
}
public IDevelopmentContext getDevelopmentContext() {
@@ -107,7 +107,7 @@ static IType[] nonStateSpecific(IType[] stateSpecific) {
return result;
}
public String toString() {
- Assert.isTrue(false, "TBD"); //$NON-NLS-1$
+ Assert.isTrue(false, "TBD"/*nonNLS*/);
return null;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OldBuilderType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OldBuilderType.java
index f65be18f2e..7d947d4935 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OldBuilderType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OldBuilderType.java
@@ -56,6 +56,6 @@ public void setNewTypeStructureEntry(TypeStructureEntry newEntry) {
* For debugging only
*/
public String toString() {
- return "OldBuilderType(" + fOldTSEntry.getType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "OldBuilderType("/*nonNLS*/ + fOldTSEntry.getType().getName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OrderedSet.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OrderedSet.java
index 5cbcc5fbce..a37998d4ef 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OrderedSet.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/OrderedSet.java
@@ -214,7 +214,7 @@ public String toString () {
for (int i=0; i<elementCount; i++) {
if (i != 0) buffer.append (',');
if (buffer.length() > 1000) {
- buffer.append("..."); //$NON-NLS-1$
+ buffer.append("..."/*nonNLS*/);
break;
}
buffer.append (orderedList[i]);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImpl.java
index 1a6c0c971c..99c8630ce8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImpl.java
@@ -19,7 +19,7 @@ public class PackageImpl extends NonStateSpecificHandleImpl implements IPackage
String fName;
boolean fIsUnnamed;
- public static final String DEFAULT_PACKAGE_PREFIX = "Default-"; //$NON-NLS-1$
+ public static final String DEFAULT_PACKAGE_PREFIX = "Default-"/*nonNLS*/;
/**
* Creates a new package
* @param name of package
@@ -203,9 +203,9 @@ public boolean isUnnamed() {
public static String readableName(IPackage pkg) {
String name = pkg.getName();
if (pkg.isUnnamed()) {
- return Util.bind("build.defaultPackageName", name.substring(DEFAULT_PACKAGE_PREFIX.length())); //$NON-NLS-1$
+ return Util.bind("build.defaultPackageName"/*nonNLS*/, name.substring(DEFAULT_PACKAGE_PREFIX.length()));
} else {
- return Util.bind("build.packageName", name); //$NON-NLS-1$
+ return Util.bind("build.packageName"/*nonNLS*/, name);
}
}
/**
@@ -213,9 +213,9 @@ public static String readableName(IPackage pkg) {
* only (NON-NLS).
*/
public String toString() {
- String result = "package "; //$NON-NLS-1$
+ String result = "package "/*nonNLS*/;
if (isUnnamed())
- result += "{unnamed, id=" + getName() + "}"; //$NON-NLS-2$ //$NON-NLS-1$
+ result += "{unnamed, id="/*nonNLS*/ + getName() + "}"/*nonNLS*/;
else
result += getName();
return result;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImplSWH.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImplSWH.java
index 4f34fc8b68..8bf3a153fa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImplSWH.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageImplSWH.java
@@ -146,7 +146,7 @@ public IPackage[] getReferencedPackages() throws NotPresentException {
public IPackage[] getReferencingPackages(IImageContext context)
throws NotPresentException {
if (!isPresent())
- throw new NotPresentException(Util.bind("element.notPresent")); //$NON-NLS-1$
+ throw new NotPresentException(Util.bind("element.notPresent"/*nonNLS*/));
IPackage[] pkgs = fState.getReferencingPackages(fHandle, context);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMap.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMap.java
index ed4d744c87..8f88cf2b6e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMap.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMap.java
@@ -112,15 +112,15 @@ public class PackageMap extends StateTables {
IPackage[] pkgs = getAllPackagesAsArray();
Arrays.sort(pkgs, StateImpl.getPackageComparator());
StringBuffer sb = new StringBuffer();
- sb.append(super.toString() + ":\n"); //$NON-NLS-1$
+ sb.append(super.toString() + ":\n"/*nonNLS*/);
for (int i = 0; i < pkgs.length; ++i) {
- sb.append(" " + pkgs[i].getName() + ": "); //$NON-NLS-2$ //$NON-NLS-1$
+ sb.append(" "/*nonNLS*/ + pkgs[i].getName() + ": "/*nonNLS*/);
IPath[] fragments = getFragments(pkgs[i]);
for (int j = 0; j < fragments.length; ++j) {
- if (j != 0) sb.append(", "); //$NON-NLS-1$
+ if (j != 0) sb.append(", "/*nonNLS*/);
sb.append(fragments[j]);
}
- sb.append("\n"); //$NON-NLS-1$
+ sb.append("\n"/*nonNLS*/);
}
return sb.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMapEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMapEntry.java
index 869afaa6df..6f80669b5e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMapEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PackageMapEntry.java
@@ -73,9 +73,9 @@ void addFragment(IPath fragment) {
* This method is for debugging purposes only.
*/
public String toString() {
- StringBuffer buf = new StringBuffer("PackageMapEntry("); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("PackageMapEntry("/*nonNLS*/);
buf.append(fPkg);
- buf.append(")"); //$NON-NLS-1$
+ buf.append(")"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PathMap.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PathMap.java
index 98908acfe6..4a85e78bc8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PathMap.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PathMap.java
@@ -61,10 +61,10 @@ boolean hasPath(IPath path) {
IPackage packageHandleFromPath(IPath path) {
IPackage[] pkgs = (IPackage[])fTable.get(path);
if (pkgs == null) {
- throw new Error(Util.bind("build.noPackagePath", path.toString())); //$NON-NLS-1$
+ throw new Error(Util.bind("build.noPackagePath"/*nonNLS*/, path.toString()));
}
if (pkgs.length != 1) {
- throw new Error(Util.bind("build.ambiguousPackage", path.toString())); //$NON-NLS-1$
+ throw new Error(Util.bind("build.ambiguousPackage"/*nonNLS*/, path.toString()));
}
return pkgs[0];
}
@@ -120,23 +120,23 @@ IPackage[] packageHandlesFromPath(IPath path) {
}
Collections.sort(list, StateImpl.getPathComparator());
StringBuffer sb = new StringBuffer();
- sb.append(super.toString() + ":\n"); //$NON-NLS-1$
+ sb.append(super.toString() + ":\n"/*nonNLS*/);
for (int i = 0; i < list.size(); ++i) {
IPath path = (IPath) list.get(i);
- sb.append(" " + path + ": "); //$NON-NLS-2$ //$NON-NLS-1$
+ sb.append(" "/*nonNLS*/ + path + ": "/*nonNLS*/);
IPackage[] pkgs = packageHandlesFromPath(path);
if (pkgs.length == 1) {
sb.append(pkgs[0].getName());
}
else {
Arrays.sort(pkgs, StateImpl.getPackageComparator());
- sb.append("(" + pkgs.length + " packages)"); //$NON-NLS-2$ //$NON-NLS-1$
+ sb.append("("/*nonNLS*/ + pkgs.length + " packages)"/*nonNLS*/);
for (int j = 0; j < pkgs.length; ++j) {
- sb.append("\n "); //$NON-NLS-1$
+ sb.append("\n "/*nonNLS*/);
sb.append(pkgs[j].getName());
}
}
- sb.append("\n"); //$NON-NLS-1$
+ sb.append("\n"/*nonNLS*/);
}
return sb.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PrimitiveTypeHandleImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PrimitiveTypeHandleImpl.java
index db45948865..ecf1893011 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PrimitiveTypeHandleImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/PrimitiveTypeHandleImpl.java
@@ -149,23 +149,23 @@ public String getName() {
public String getSimpleName() {
switch (fTypeCode) {
case TC_BOOLEAN :
- return "boolean"; //$NON-NLS-1$
+ return "boolean"/*nonNLS*/;
case TC_BYTE :
- return "byte"; //$NON-NLS-1$
+ return "byte"/*nonNLS*/;
case TC_CHAR :
- return "char"; //$NON-NLS-1$
+ return "char"/*nonNLS*/;
case TC_DOUBLE :
- return "double"; //$NON-NLS-1$
+ return "double"/*nonNLS*/;
case TC_FLOAT :
- return "float"; //$NON-NLS-1$
+ return "float"/*nonNLS*/;
case TC_INT :
- return "int"; //$NON-NLS-1$
+ return "int"/*nonNLS*/;
case TC_LONG :
- return "long"; //$NON-NLS-1$
+ return "long"/*nonNLS*/;
case TC_SHORT :
- return "short"; //$NON-NLS-1$
+ return "short"/*nonNLS*/;
case TC_VOID :
- return "void"; //$NON-NLS-1$
+ return "void"/*nonNLS*/;
default :
}
return null;
@@ -219,25 +219,25 @@ public boolean isPrimitive() {
protected static String typeSignature(int typeCode) {
switch (typeCode) {
case TC_VOID :
- return "V"; //$NON-NLS-1$
+ return "V"/*nonNLS*/;
case TC_BOOLEAN :
- return "Z"; //$NON-NLS-1$
+ return "Z"/*nonNLS*/;
case TC_BYTE :
- return "B"; //$NON-NLS-1$
+ return "B"/*nonNLS*/;
case TC_CHAR :
- return "C"; //$NON-NLS-1$
+ return "C"/*nonNLS*/;
case TC_SHORT :
- return "S"; //$NON-NLS-1$
+ return "S"/*nonNLS*/;
case TC_INT :
- return "I"; //$NON-NLS-1$
+ return "I"/*nonNLS*/;
case TC_LONG :
- return "J"; //$NON-NLS-1$
+ return "J"/*nonNLS*/;
case TC_FLOAT :
- return "F"; //$NON-NLS-1$
+ return "F"/*nonNLS*/;
case TC_DOUBLE :
- return "D"; //$NON-NLS-1$
+ return "D"/*nonNLS*/;
default :
- return "unknown"; //$NON-NLS-1$
+ return "unknown"/*nonNLS*/;
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemDetailImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemDetailImpl.java
index a0d71a0ee9..812c53225b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemDetailImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemDetailImpl.java
@@ -197,6 +197,6 @@ public void setSourceStart(int sourceStart) {
* purposes only. Non-NLS.
*/
public String toString() {
- return "ProblemDetail(" + getMessage() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "ProblemDetail("/*nonNLS*/ + getMessage() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemFactory.java
index 14672d113d..87c7237959 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemFactory.java
@@ -25,7 +25,7 @@ public class ProblemFactory implements IProblemFactory {
*/
private ProblemFactory(Locale locale) {
fLocale = locale;
- fCompilerResources = ResourceBundle.getBundle("org.eclipse.jdt.internal.compiler.problem.Messages", locale); //$NON-NLS-1$
+ fCompilerResources = ResourceBundle.getBundle("org.eclipse.jdt.internal.compiler.problem.Messages"/*nonNLS*/, locale);
initializeMessageTemplates();
}
/**
@@ -53,7 +53,7 @@ public String getLocalizedMessage(int id, String[] problemArguments) {
StringBuffer output = new StringBuffer(80);
String message = fMessageTemplates[ (id & ProblemIrritants.IgnoreCategoriesMask)];
if (message == null) {
- return "Unable to retrieve the error message for problem id: "+ id + ". Check compiler resources."; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Unable to retrieve the error message for problem id: "/*nonNLS*/+ id + ". Check compiler resources."/*nonNLS*/;
}
int length = message.length();
int start = -1, end = length;
@@ -66,7 +66,7 @@ public String getLocalizedMessage(int id, String[] problemArguments) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- return "Corrupted compiler resources for problem id: " + (id & ProblemIrritants.IgnoreCategoriesMask) + ". Check compiler resources."; //$NON-NLS-1$ //$NON-NLS-2$
+ return "Corrupted compiler resources for problem id: "/*nonNLS*/ + (id & ProblemIrritants.IgnoreCategoriesMask) + ". Check compiler resources."/*nonNLS*/;
}
} else {
output.append(message.substring(end, length));
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemTable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemTable.java
index 9d92795185..3b7e49c40b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemTable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProblemTable.java
@@ -170,12 +170,12 @@ public void removeSyntaxErrors(Object entry) {
* @return a string representation of the receiver
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ProblemTable(\n\t"); //$NON-NLS-1$
- buf.append("type problems: "); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("ProblemTable(\n\t"/*nonNLS*/);
+ buf.append("type problems: "/*nonNLS*/);
buf.append(fTable);
- buf.append("\n\timage problems: "); //$NON-NLS-1$
+ buf.append("\n\timage problems: "/*nonNLS*/);
buf.append(fImageProblems);
- buf.append(")"); //$NON-NLS-1$
+ buf.append(")"/*nonNLS*/);
return buf.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectBinaryOutput.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectBinaryOutput.java
index 6973b1669b..745d9c03e4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectBinaryOutput.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectBinaryOutput.java
@@ -103,7 +103,7 @@ private void deleteClassesInContainer(IContainer container) {
IResource resource = (IResource) members[i];
switch (resource.getType()) {
case IResource.FILE :
- if (resource.getName().toLowerCase().endsWith(".class")) { //$NON-NLS-1$
+ if (resource.getName().toLowerCase().endsWith(".class"/*nonNLS*/)) {
resource.delete(true, null);
}
break;
@@ -141,7 +141,8 @@ public byte[] getBinary(TypeStructureEntry tsEntry, IType type) {
} catch (IOException e) {
return new byte[0];
} catch (CoreException e) {
- return new byte[0]; }
+ return new byte[0];
+ }
}
/**
* Returns the container for a path.
@@ -175,7 +176,7 @@ IPath getOutputPath() {
* Returns the path in the output folder for the given type.
*/
private IPath getPathForBinary(IType type) {
- return getOutputPath().append(type.getName().replace('.', '/') + ".class"); //$NON-NLS-1$
+ return getOutputPath().append(type.getName().replace('.', '/') + ".class"/*nonNLS*/);
}
/**
* Returns the container at the given path, creating it and any parent folders if necessary.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectResourceCopier.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectResourceCopier.java
index 90194e8756..628a23699b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectResourceCopier.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ProjectResourceCopier.java
@@ -65,7 +65,7 @@ public void copyAllResourcesOnClasspath(){
if (this.outputLocation.equals(this.sourceFolders[i].getFullPath())) continue; // do nothing if output is same as source folder
if (!hasNotified){
hasNotified = true;
- if (notifier != null) notifier.subTask(Util.bind("build.copyingResources")); //$NON-NLS-1$
+ if (notifier != null) notifier.subTask(Util.bind("build.copyingResources"/*nonNLS*/));
}
this.sourceFolders[i].accept(this);
}
@@ -87,7 +87,7 @@ private boolean copyToOutput(IResource resource) {
switch (resource.getType()){
case IResource.FILE :
if (sourceFolderPath == null) return false; // resource is not inside the classpath
- if (!"java".equals(resource.getFileExtension())){ // ignore source files //$NON-NLS-1$
+ if (!"java"/*nonNLS*/.equals(resource.getFileExtension())){ // ignore source files
IFile currentFile = (IFile) resource;
IPath pathSuffix = resourcePath.removeFirstSegments(sourceFolderPath.segmentCount());
@@ -140,7 +140,7 @@ private boolean deleteResourceCopyFromOutput(IResource resource) {
switch (resource.getType()){
case IResource.FILE :
- if (!"java".equals(resource.getFileExtension())){ // ignore source files //$NON-NLS-1$
+ if (!"java"/*nonNLS*/.equals(resource.getFileExtension())){ // ignore source files
IFile currentFile = (IFile) resource;
pathSuffix = resourcePath.removeFirstSegments(sourceFolderPath.segmentCount());
@@ -195,7 +195,7 @@ private IPath getSourceFolderPath(IResource resource) {
if (this.outputLocation.equals(this.sourceFolders[i].getFullPath())) continue; // do nothing if output is same as source folder
if (!hasNotified){
hasNotified = true;
- if (notifier != null) notifier.subTask(Util.bind("build.updatingResources")); //$NON-NLS-1$
+ if (notifier != null) notifier.subTask(Util.bind("build.updatingResources"/*nonNLS*/));
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ReportCardImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ReportCardImpl.java
index 5590beff71..10bef72e28 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ReportCardImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ReportCardImpl.java
@@ -104,7 +104,7 @@ private void getProblemsForPath(IPath path, Vector vResults) {
if (path.isPrefixOf(sEntryPath)) {
String extension = sEntryPath.getFileExtension();
// test most frequent cases first
- if (extension != null && (extension.toLowerCase().equals("java") || extension.toLowerCase().equals("class"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (extension != null && (extension.toLowerCase().equals("java"/*nonNLS*/) || extension.toLowerCase().equals("class"/*nonNLS*/))) {
getProblemsForSourceEntry(sEntry, vResults);
} else {
if (fState.isZipElement(sEntryPath)) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceElementTable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceElementTable.java
index efd6f1ddfb..48067b1fe7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceElementTable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceElementTable.java
@@ -123,6 +123,6 @@ SourceEntry removeSourceEntry(IPackage pkg, String fileName) {
* @return a string representation of the receiver
*/
public String toString() {
- return "SourceElementTable(" + fPackageTable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "SourceElementTable("/*nonNLS*/ + fPackageTable + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceEntry.java
index a63718d9ba..d42409f719 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceEntry.java
@@ -94,7 +94,7 @@ public String getPathWithZipEntryName() {
return s.replace('/', File.separatorChar);
}
public String getZipEntryName() {
- return fZipEntryPath == null ? fZipEntryFileName : fZipEntryPath + "/" + fZipEntryFileName; //$NON-NLS-1$
+ return fZipEntryPath == null ? fZipEntryFileName : fZipEntryPath + "/"/*nonNLS*/ + fZipEntryFileName;
}
public int hashCode() {
int code = fPath.hashCode();
@@ -112,10 +112,10 @@ public String getPathWithZipEntryName() {
*/
public boolean isBinary() {
if (fZipEntryFileName != null) {
- return fZipEntryFileName.endsWith(".class"); //$NON-NLS-1$
+ return fZipEntryFileName.endsWith(".class"/*nonNLS*/);
}
String extension = fPath.getFileExtension();
- return extension != null && extension.equalsIgnoreCase("class"); //$NON-NLS-1$
+ return extension != null && extension.equalsIgnoreCase("class"/*nonNLS*/);
}
/**
* Returns true if the source entry comes from a compilation unit, otherwise
@@ -123,16 +123,16 @@ public String getPathWithZipEntryName() {
*/
public boolean isSource() {
if (fZipEntryFileName != null) {
- return fZipEntryFileName.endsWith(".java"); //$NON-NLS-1$
+ return fZipEntryFileName.endsWith(".java"/*nonNLS*/);
}
String extension = fPath.getFileExtension();
- return extension != null && extension.equalsIgnoreCase("java"); //$NON-NLS-1$
+ return extension != null && extension.equalsIgnoreCase("java"/*nonNLS*/);
}
/**
* Returns a String that represents the value of this object.
* @return a string representation of the receiver
*/
public String toString() {
- return fZipEntryFileName == null ? fPath.toString() : fPath.toString() + ", entry: " + this.getZipEntryName(); //$NON-NLS-1$
+ return fZipEntryFileName == null ? fPath.toString() : fPath.toString() + ", entry: "/*nonNLS*/ + this.getZipEntryName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceFragmentImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceFragmentImpl.java
index d1dc34f996..76a1bf438d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceFragmentImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/SourceFragmentImpl.java
@@ -62,7 +62,7 @@ public String getZipEntryName() {
*/
public String toString() {
return
- "SourceFragmentImpl(" + fPath //$NON-NLS-1$
- + (fZipEntryName == null ? "" : " : " + fZipEntryName) + ")"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ "SourceFragmentImpl("/*nonNLS*/ + fPath
+ + (fZipEntryName == null ? ""/*nonNLS*/ : " : "/*nonNLS*/ + fZipEntryName) + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateImpl.java
index b22c4dcabe..0dce2cd329 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateImpl.java
@@ -1,5 +1,5 @@
package org.eclipse.jdt.internal.core.builder.impl;
-
+
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
@@ -16,7 +16,7 @@ import java.util.Random;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -63,52 +63,52 @@ import org.eclipse.jdt.internal.core.builder.NotPresentException;
import org.eclipse.jdt.internal.core.builder.StateSpecificException;
import org.eclipse.jdt.internal.core.lookup.ReferenceInfo;
import org.eclipse.jdt.internal.core.util.LookupTable;
-
+
/**
* The concrete representation of a built state.
*
* @see IState
*/
public class StateImpl implements IState {
-
+
/**
* The development context corresponding to this state
*/
private JavaDevelopmentContextImpl fDevelopmentContext;
-
+
/**
* The build context. Only packages in the build context
* are actually built
*/
private IImageContext fBuildContext;
-
+
/**
* The project built by this state.
*/
private IProject fProject;
-
+
/**
* The name of the project built by this state.
*/
private String fProjectName;
-
+
/**
* The paths of the package fragment roots in the class path.
*/
private IPackageFragmentRoot[] fPackageFragmentRootsInClassPath;
-
+
/**
* The binary output.
*/
private BinaryOutput fBinaryOutput;
-
+
/**
* The package map. A hashtable of package handles to PackageMapEntry objects.
* The package map entries store the collection of package fragments that
* make up the given builder package.
*/
private PackageMap fPackageMap;
-
+
/**
* The path map. A table that maps from paths to package handles. This
* is essentially a reverse index of the package map. Note that this
@@ -116,58 +116,63 @@ public class StateImpl implements IState {
* not need to be serialized or incrementally updated.
*/
private PathMap fPathMap;
-
+
/**
* The source element table. This table holds a source fragment for
* all workspace elements.
*/
private SourceElementTable fSourceElementTable;
-
+
/**
* The principal structure table. A table of type handles to TypeStructureEntry objects.
* This is where build results are stored. This table only contains types that
* have been compiled.
*/
private Hashtable fPrincipalStructureTable;
-
+
/**
* Table of IPackage to TypeStructureEntry[] for all types in package (lazy).
*/
private Hashtable fPrincipalStructureByPackageTable;
-
+
/**
* The problem reporter. All problems for this state are stored in this problem
* reporter.
*/
private IProblemReporter fProblemReporter;
-
+
/**
* The graph of source element dependencies, used for
* incremental compilation
*/
private DependencyGraph fGraph= null;
-
+
/**
* The table of subtypes. Maps from IType to TypeStructureEntry[]. Absence in table implies no subtypes.
*/
private Hashtable fSubtypesTable;
private IImageContext fSubtypesTableImageContext;
-
+
/**
* The image corresponding to this state
*/
private IImage fImage;
-
+
+ /**
+ * The compiler options that were used to build this state.
+ */
+ private ConfigurableOption[] fCompilerOptions;
+
/**
* Unique state number
*/
private int fStateNumber;
-
+
/**
* Fingerprint bytes
*/
private byte[] fFingerprint;
-
+
/* primitive type handles */
final IType fVoidType;
final IType fIntType;
@@ -178,28 +183,28 @@ public class StateImpl implements IState {
final IType fLongType;
final IType fShortType;
final IType fBooleanType;
-
+
/**
* Counter for unique state numbers (not the fingerprint).
*/
private static int fgStateCounter= 0;
-
+
/**
* Namespace flag indicating CU has parse error.
* Must not conflict with modifiers or other flags in IConstants.
*/
private static final int F_HAS_PARSE_ERROR= 0x10000000;
-
+
/**
* Name for namespace node representing unknown dependencies.
*/
- private static final String UNKNOWN_DEPENDENCIES= "$UNKNOWN_DEPENDENCIES$"; //$NON-NLS-1$
-
+ private static final String UNKNOWN_DEPENDENCIES= "$UNKNOWN_DEPENDENCIES$"/*nonNLS*/;
+
/**
* Random number generator, used for generating fingerprints.
*/
private static final Random fgRandom= new Random();
-
+
/**
* State constructor comment. The build context, fingerprint, and internal tables
* are not instantiated and must be filled in before use.
@@ -226,7 +231,7 @@ public class StateImpl implements IState {
protected StateImpl(JavaDevelopmentContextImpl dc, IProject project, IImageContext buildContext) {
this(dc, project);
fBuildContext= buildContext;
-
+
/* state tables */
fPackageMap= new PackageMap();
fSourceElementTable= new SourceElementTable();
@@ -250,7 +255,7 @@ public class StateImpl implements IState {
*/
protected void buildInitialPackageMap() {
fPackageMap= new PackageMap();
-
+
/* do for each package fragment root in (classpath INTERSECT workspace) */
try {
IPackageFragmentRoot[] roots= getPackageFragmentRootsInClassPath();
@@ -274,7 +279,7 @@ public class StateImpl implements IState {
} catch (JavaModelException e) {
throw internalException(e);
}
-
+
/* build the reverse index -- the path map */
fPathMap= new PathMap(fPackageMap);
}
@@ -352,12 +357,12 @@ public class StateImpl implements IState {
IPackage[] oldPackages= oldContext.getPackages();
int pkgCount= oldPackages.length;
IPackage[] newPackages= new IPackage[pkgCount];
-
+
/* canonicalize packages through package map */
for (int i= 0; i < pkgCount; i++) {
newPackages[i]= canonicalize(oldPackages[i]);
}
-
+
return new ImageContextImpl(fDevelopmentContext, newPackages);
}
/**
@@ -401,7 +406,7 @@ public class StateImpl implements IState {
String fileName= new String(result.getFileName());
SourceEntry sEntry= SourceEntry.fromPathWithZipEntryName(fileName);
PackageElement resultUnit= packageElementFromSourceEntry(sEntry);
-
+
/**
* Make sure the CU exists. May be null if unit is unavailable
* (e.g. package is not included in package map due to class path omission).
@@ -410,7 +415,7 @@ public class StateImpl implements IState {
IPackage resultPkg= resultUnit.getPackage();
IProblem[] compilerProblems= result.getProblems();
Vector vProblems= new Vector(compilerProblems == null ? 0 : compilerProblems.length);
-
+
/* convert type names to type handles for the produced types */
ClassFile[] classFiles= result.getClassFiles();
Vector vTSEntries= new Vector(classFiles.length);
@@ -420,7 +425,7 @@ public class StateImpl implements IState {
String className= Util.toString(classFile.getCompoundName());
if (classFile == null) {
// Could not discover principal structure
- String msg= Util.bind("build.errorParsingBinary", className); //$NON-NLS-1$
+ String msg= Util.bind("build.errorParsingBinary"/*nonNLS*/, className);
ProblemDetailImpl problem= new ProblemDetailImpl(msg, sEntry);
vProblems.addElement(problem);
// skip it
@@ -439,7 +444,7 @@ public class StateImpl implements IState {
if (!typePkg.isUnnamed()) {
path= path.append(typePkg.getName().replace('.', IPath.SEPARATOR));
}
- String msg= Util.bind("build.packageMismatch", path.toString()); //$NON-NLS-1$
+ String msg= Util.bind("build.packageMismatch"/*nonNLS*/, path.toString());
ProblemDetailImpl problem= new ProblemDetailImpl(msg, 0, IProblemDetail.S_ERROR, sEntry, 0, 0, 1);
vProblems.addElement(problem);
// Only report the conflict once (there may be several types, but there's only one package declaration).
@@ -449,7 +454,7 @@ public class StateImpl implements IState {
continue;
}
TypeStructureEntry tsEntry= new TypeStructureEntry(sEntry, typeHandle);
-
+
/* squirrel the binary away */
byte[] binary= classFile.getBytes();
// as a side effect, the following sets the crc32 for the type structure entry
@@ -458,10 +463,10 @@ public class StateImpl implements IState {
}
TypeStructureEntry[] tsEntries= new TypeStructureEntry[vTSEntries.size()];
vTSEntries.copyInto(tsEntries);
-
+
/* convert dependencies */
Vector dependencies= resolveDependencies(resultUnit, result);
-
+
/* convert problems */
if (compilerProblems != null) {
for (int i= 0; i < compilerProblems.length; i++) {
@@ -488,6 +493,7 @@ public class StateImpl implements IState {
newState.fProblemReporter= this.fProblemReporter.copy();
newState.fGraph= this.fGraph.copy();
newState.fBuildContext= context;
+ newState.fCompilerOptions= this.fCompilerOptions;
return newState;
}
/**
@@ -515,7 +521,7 @@ public class StateImpl implements IState {
IType type= tsEntry.getType();
SourceEntry sEntry= tsEntry.getSourceEntry();
IBinaryType binaryType= null;
-
+
/* if its a class file, get descriptor from binary index */
if (sEntry.isBinary()) {
try {
@@ -538,7 +544,7 @@ public class StateImpl implements IState {
}
if (lazyBuildCU && binaryType == null) {
/* couldn't parse the class file */
- ProblemDetailImpl problem= new ProblemDetailImpl(Util.bind("build.errorParsingBinary", type.getName()), sEntry); //$NON-NLS-1$
+ ProblemDetailImpl problem= new ProblemDetailImpl(Util.bind("build.errorParsingBinary"/*nonNLS*/, type.getName()), sEntry);
fProblemReporter.putProblem(sEntry, problem);
}
return binaryType;
@@ -574,9 +580,9 @@ public class StateImpl implements IState {
if (!fPackageMap.containsPackage(pkg)) {
return null;
}
-
+
// TBD: Doesn't support lazy builds.
-
+
int max= 30;
TypeStructureEntry[] list= new TypeStructureEntry[max];
int count= 0;
@@ -605,12 +611,12 @@ public class StateImpl implements IState {
}
IType nssHandle= (IType) type.nonStateSpecific();
TypeStructureEntry tsEntry= buildTypeStructureEntry(nssHandle);
-
+
/* Attempt to retrieve binary from binary output */
byte[] binary= getBinaryOutput().getBinary(tsEntry, nssHandle);
if (binary != null)
return binary;
-
+
/*
* We have a built entry, but couldn't get the bytes from the binary output.
* Need to recompile.
@@ -618,7 +624,7 @@ public class StateImpl implements IState {
if (!lazyBuildCU) {
return null;
}
-
+
/* make sure the entry is a compilation unit */
PackageElement unit= packageElementFromSourceEntry(tsEntry.getSourceEntry());
new BatchImageBuilder(this).lazyBuild(unit);
@@ -648,11 +654,11 @@ public class StateImpl implements IState {
* is thrown.
*/
protected IBinaryType getBinaryType(TypeStructureEntry tsEntry) throws NotPresentException {
-
+
/* rebuild descriptor from indexes or binary */
IBinaryType binaryType= forceBinaryType(tsEntry, false); // Use false for 1FVQGL1: ITPJCORE:WINNT - SEVERE - Error saving java file
if (binaryType == null) {
- throw new NotPresentException(Util.bind("build.errorBuildingType", tsEntry.getSourceEntry().getFileName())); //$NON-NLS-1$
+ throw new NotPresentException(Util.bind("build.errorBuildingType"/*nonNLS*/, tsEntry.getSourceEntry().getFileName()));
}
return binaryType;
}
@@ -662,7 +668,7 @@ public class StateImpl implements IState {
* the binary is not available (doesn't invoke a lazy build)
*/
protected IBinaryType getBinaryTypeOrNull(TypeStructureEntry tsEntry) {
-
+
/* rebuild descriptor from binary */
return forceBinaryType(tsEntry, false);
}
@@ -717,12 +723,17 @@ public class StateImpl implements IState {
if (!fSourceElementTable.containsPackage(pkg)) {
getSourceEntries(pkg);
}
- SourceEntry entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"); //$NON-NLS-1$
+ SourceEntry entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"/*nonNLS*/);
if (entry == null)
return null;
return new PackageElement(pkg, entry);
}
-
+ /**
+ * Returns the compiler options used to build this state.
+ */
+ public ConfigurableOption[] getCompilerOptions() {
+ return fCompilerOptions;
+ }
/**
* Returns an enumeration of TypeStructureEntry objects for all top-level types
* in the given package. Returns null if the package does not exist.
@@ -803,7 +814,7 @@ public class StateImpl implements IState {
return fDevelopmentContext.getBinaryFromFileSystem(file);
} catch (IOException e) {
String message= e.getMessage();
- message= (message == null ? "." : " due to " + message + "."); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ message= (message == null ? "."/*nonNLS*/ : " due to "/*nonNLS*/ + message + "."/*nonNLS*/);
return new byte[0];
}
}
@@ -920,7 +931,7 @@ public class StateImpl implements IState {
}
}
if (frag == null) {
- throw internalException(Util.bind("build.missingFile", sEntry.toString())); //$NON-NLS-1$
+ throw internalException(Util.bind("build.missingFile"/*nonNLS*/, sEntry.toString()));
}
String fileName= sEntry.getPath().lastSegment();
if (sEntry.isSource()) {
@@ -1081,10 +1092,10 @@ static Comparator getPathComparator() {
* The resulting packages are in no particular order.
*/
protected IPackage[] getReferencedPackages(IPackage pkgHandle) {
-
+
/* set of referenced builder packages */
Hashtable pkgTable= getTableOfReferencedPackages(pkgHandle);
-
+
/* convert to array and return */
IPackage[] results= new IPackage[pkgTable.size()];
int i= 0;
@@ -1124,11 +1135,11 @@ static Comparator getPathComparator() {
* This is an extremely slow implementation (n^3?). Avoid using it if possible.
*/
protected IPackage[] getReferencingPackages(IPackage pkgHandle, IImageContext context) {
-
+
/* the results */
Vector vResults= new Vector();
IImage image= fDevelopmentContext.getImage();
-
+
/* do for each package in the image context */
IPackage[] pkgs= context.getPackages();
for (int i= 0; i < pkgs.length; i++) {
@@ -1208,9 +1219,9 @@ static Comparator getPathComparator() {
ICompilationUnit unit= units[i];
String fileName= unit.getElementName();
// get the corresponding .class file name
- String classFileName = ""; //$NON-NLS-1$
+ String classFileName = ""/*nonNLS*/;
if (Util.isJavaFileName(fileName)) { // paranoia check
- classFileName = fileName.substring(0, fileName.length()-5).concat(".class"); //$NON-NLS-1$
+ classFileName = fileName.substring(0, fileName.length()-5).concat(".class"/*nonNLS*/);
}
// see if a source entry exists for this file name
// or for the corresponding .class file
@@ -1234,7 +1245,7 @@ static Comparator getPathComparator() {
String fileName= classFile.getElementName();
// get the corresponding .java file name
// note: this handles nested types, but not secondary types (e.g. class B defined in A.java)
- String javaFileName = ""; //$NON-NLS-1$
+ String javaFileName = ""/*nonNLS*/;
if (Util.isClassFileName(fileName)) { // paranoia check
// strip off any nested types
javaFileName = fileName.substring(0, fileName.length()-6);
@@ -1242,7 +1253,7 @@ static Comparator getPathComparator() {
if (dol != -1) {
javaFileName = javaFileName.substring(0, dol);
}
- javaFileName = javaFileName.concat(".java"); //$NON-NLS-1$
+ javaFileName = javaFileName.concat(".java"/*nonNLS*/);
}
// see if a source entry exists for this file name
// or for the corresponding .java file
@@ -1281,15 +1292,15 @@ static Comparator getPathComparator() {
if (entries != null) {
return entries;
}
-
+
/* Need to build the table for the package */
-
+
/* go through package fragments and compute all source entries */
IPath[] frags= fPackageMap.getFragments(pkg);
if (frags == null) {
return null; // package not present
}
-
+
/* build a table of source entries, keyed by filename */
LookupTable entryTable= new LookupTable(20);
for (int i= 0; i < frags.length; i++) {
@@ -1304,7 +1315,7 @@ static Comparator getPathComparator() {
protected SourceEntry getSourceEntry(String qualifiedNameWithSuffix) {
int dot= qualifiedNameWithSuffix.lastIndexOf('.');
dot= qualifiedNameWithSuffix.lastIndexOf('.', dot - 1);
- String pkgName= (dot == -1 ? ".default" : qualifiedNameWithSuffix.substring(0, dot)); //$NON-NLS-1$
+ String pkgName= (dot == -1 ? ".default"/*nonNLS*/ : qualifiedNameWithSuffix.substring(0, dot));
String fileName= (dot == -1 ? qualifiedNameWithSuffix : qualifiedNameWithSuffix.substring(dot + 1));
IPackage pkg= fDevelopmentContext.getImage().getPackageHandle(pkgName, false);
getSourceEntries(pkg); // force
@@ -1333,16 +1344,16 @@ static Comparator getPathComparator() {
getSourceEntries(pkg);
}
String simpleName= type.getSimpleName();
- SourceEntry entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"); //$NON-NLS-1$
+ SourceEntry entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"/*nonNLS*/);
if (entry == null) {
- entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".class"); //$NON-NLS-1$
+ entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".class"/*nonNLS*/);
if (entry == null) {
int firstDollar= simpleName.indexOf('$');
if (firstDollar != -1) {
simpleName= simpleName.substring(0, firstDollar);
- entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"); //$NON-NLS-1$
+ entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".java"/*nonNLS*/);
if (entry == null) {
- entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".class"); //$NON-NLS-1$
+ entry= fSourceElementTable.getSourceEntry(pkg, simpleName + ".class"/*nonNLS*/);
}
}
}
@@ -1415,14 +1426,14 @@ static Comparator getPathComparator() {
protected Hashtable getTableOfReferencedPackages(IPackage pkgHandle) {
/* set of referenced builder packages */
Hashtable pkgTable= new Hashtable();
-
+
/* do for each type in this package */
TypeStructureEntry[] types= getAllTypesForPackage(pkgHandle);
if (types != null) {
for (int i= 0; i < types.length; i++) {
PackageElement element= packageElementFromSourceEntry(types[i].getSourceEntry());
IPackage[] deps= getInternalDependencyGraph().getNamespaceDependencies(element);
-
+
/* make sure namespaces are actually packages */
for (int j= 0; j < deps.length; j++) {
if (fPackageMap.getEntry(deps[j]) != null) {
@@ -1431,7 +1442,7 @@ static Comparator getPathComparator() {
}
}
}
-
+
/* remove this package */
pkgTable.remove(pkgHandle);
return pkgTable;
@@ -1441,7 +1452,7 @@ static Comparator getPathComparator() {
*/
protected TypeStructureEntry getTypeStructureEntry(String qualifiedNameWithoutSuffix) {
int dot= qualifiedNameWithoutSuffix.lastIndexOf('.');
- String pkgName= (dot == -1 ? ".default" : qualifiedNameWithoutSuffix.substring(0, dot)); //$NON-NLS-1$
+ String pkgName= (dot == -1 ? ".default"/*nonNLS*/ : qualifiedNameWithoutSuffix.substring(0, dot));
String typeName= (dot == -1 ? qualifiedNameWithoutSuffix : qualifiedNameWithoutSuffix.substring(dot + 1));
IPackage pkg= fDevelopmentContext.getImage().getPackageHandle(pkgName, false);
IType type= pkg.getClassHandle(typeName);
@@ -1458,16 +1469,16 @@ static Comparator getPathComparator() {
if (tsEntry != null) {
return tsEntry;
}
-
+
// TBD: Doesn't handle lazy builds.
-
+
/* get the source element */
IPackage pkg= handle.getPackage();
SourceEntry sEntry= getSourceEntry(handle);
if (sEntry == null) {
return null;
}
-
+
/* if its a class file, parse it */
if (sEntry.isBinary()) {
//byte[] bytes = getElementContentBytes(sEntry);
@@ -1482,13 +1493,13 @@ static Comparator getPathComparator() {
// Don't try again.
return null;
}
-
+
// make sure the entry is a compilation unit
PackageElement unit= packageElementFromSourceEntry(sEntry);
-
+
// compile it
new BatchImageBuilder(this).lazyBuild(unit);
-
+
// try to get the entry again; may still be null
tsEntry= (TypeStructureEntry) fPrincipalStructureTable.get(handle);
}
@@ -1521,7 +1532,7 @@ static Comparator getPathComparator() {
*/
protected static boolean isZipElement(IPath path) {
String extension= path.getFileExtension();
- return extension != null && (extension.equalsIgnoreCase("zip") || extension.equalsIgnoreCase("jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ return extension != null && (extension.equalsIgnoreCase("zip"/*nonNLS*/) || extension.equalsIgnoreCase("jar"/*nonNLS*/));
}
/**
* Given a project-relative path, returns an absolute path.
@@ -1556,7 +1567,7 @@ static Comparator getPathComparator() {
protected IPackage packageFromSourceEntry(SourceEntry entry) {
IPath path= entry.getPath();
IPackage pkgHandle;
-
+
/* if it's a zip file */
String zipEntryFileName = entry.fZipEntryFileName;
if (zipEntryFileName != null) {
@@ -1581,23 +1592,23 @@ static Comparator getPathComparator() {
*/
protected void putCompilationResult(ConvertedCompilationResult result) {
PackageElement unit= result.getPackageElement();
-
+
/* get source entry for result */
SourceEntry sEntry= getSourceEntry(unit);
-
+
/* record problems */
fProblemReporter.removeNonSyntaxErrors(sEntry);
IProblemDetail[] problems= result.getProblems();
for (int i= 0; i < problems.length; ++i) {
fProblemReporter.putProblem(sEntry, problems[i]);
}
-
+
/* This records the types actually contributed, */
/* to record in the dependency graph. */
TypeStructureEntry[] tsEntries= result.getTypes();
IType[] types= new IType[tsEntries.length];
int count= 0;
-
+
/* record type structure */
for (int i= 0; i < tsEntries.length; i++) {
TypeStructureEntry tsEntry= tsEntries[i];
@@ -1607,19 +1618,19 @@ static Comparator getPathComparator() {
if (tsExisting != null) {
if (!tsExisting.getSourceEntry().getFileName().equals(sEntry.getFileName())) {
// Same type provided by different files
- String msg= Util.bind("build.duplicateType", typeHandle.getName(), tsExisting.getSourceEntry().getFileName()); //$NON-NLS-1$
+ String msg= Util.bind("build.duplicateType"/*nonNLS*/, typeHandle.getName(), tsExisting.getSourceEntry().getFileName());
ProblemDetailImpl problem= new ProblemDetailImpl(msg, sEntry);
fProblemReporter.putProblem(sEntry, problem);
// skip it
continue;
}
}
-
+
// Finally, put it in table.
fPrincipalStructureTable.put(typeHandle, tsEntry);
types[count++]= typeHandle;
}
-
+
/* Update the dependency graph. */
if (count < types.length) {
System.arraycopy(types, 0, types= new IType[count], 0, count);
@@ -1712,7 +1723,7 @@ static Comparator getPathComparator() {
if (!vSourceDeps.contains(fDevelopmentContext.getDefaultPackage())) {
vSourceDeps.addElement(fDevelopmentContext.getDefaultPackage());
}
-
+
/* do for each file dependency */
if (fileDependencies != null) {
for (int i= 0; i < fileDependencies.length; i++) {
@@ -1745,6 +1756,13 @@ static Comparator getPathComparator() {
fBuildContext= context;
}
/**
+ * Sets the compiler options that were in effect when
+ * this state was built.
+ */
+ protected void setCompilerOptions(ConfigurableOption[] options) {
+ fCompilerOptions= options;
+ }
+ /**
* Sets the fingerprint for this state.
*/
protected void setFingerprint(byte[] fp) {
@@ -1798,7 +1816,7 @@ static Comparator getPathComparator() {
* Returns a string representation of the receiver.
*/
public String toString() {
- return "StateImpl(" + fStateNumber + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "StateImpl("/*nonNLS*/ + fStateNumber + ")"/*nonNLS*/;
}
/**
* Returns the type handle for the given type name,
@@ -1850,7 +1868,7 @@ static Comparator getPathComparator() {
++i;
c= sig.charAt(i);
}
-
+
/* if its a class */
IType elementType;
if (c == 'L') {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnap.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnap.java
index 01bf6366de..52fcb91c38 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnap.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnap.java
@@ -75,7 +75,7 @@ public StateImpl read(JavaDevelopmentContextImpl dc, IProject project, DataInput
int magic = in.readInt();
int version = in.readShort();
if (magic != MAGIC) { // magic = "STAT"e
- throw new IOException(Util.bind("build.wrongFileFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("build.wrongFileFormat"/*nonNLS*/));
}
/* dispatch to appropriate reader */
@@ -85,7 +85,7 @@ public StateImpl read(JavaDevelopmentContextImpl dc, IProject project, DataInput
case VERSION6:
return new StateSnapV6().read(dc, project, in);
default:
- throw new IOException(Util.bind("build.unhandledVersionFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("build.unhandledVersionFormat"/*nonNLS*/));
}
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapConstantPool.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapConstantPool.java
index 898311cce7..7584b6f8fb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapConstantPool.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapConstantPool.java
@@ -114,14 +114,14 @@ public void add(IHandle handle) {
// NOP
break;
default:
- Assert.isTrue(false, "Unknown kind of handle"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unknown kind of handle"/*nonNLS*/);
}
}
/**
* Add a SourceEntry to the pool.
*/
public void add(SourceEntry entry) {
- Assert.isNotNull(entry, "Null SourceEntry being added to StateSnapConstantPool"); //$NON-NLS-1$
+ Assert.isNotNull(entry, "Null SourceEntry being added to StateSnapConstantPool"/*nonNLS*/);
if (!fSet.includes(entry)) {
add(entry.getPath());
String zipEntryPath = entry.fZipEntryPath;
@@ -171,12 +171,12 @@ public IHandle getHandle(int index) throws IOException {
try {
IHandle result = (IHandle)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -192,12 +192,12 @@ public IPackage getPackage(int index) throws IOException {
try {
IPackage result = (IPackage)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -207,12 +207,12 @@ public IPath getPath(int index) throws IOException {
try {
IPath result = (IPath)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -222,12 +222,12 @@ public SourceEntry getSourceEntry(int index) throws IOException {
try {
SourceEntry result = (SourceEntry)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -237,12 +237,12 @@ public String getString(int index) throws IOException {
try {
String result = (String)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -263,7 +263,7 @@ public Object getStringOrNumber(int index) throws IOException {
return result;
}
else {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -273,12 +273,12 @@ public IType getType(int index) throws IOException {
try {
IType result = (IType)fSet.get(index);
if (result == null) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
return result;
}
catch (ClassCastException e) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
}
/**
@@ -306,10 +306,10 @@ public String histogram() {
++nN;
}
else {
- Assert.isTrue(false, "Unexpected pool item"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unexpected pool item"/*nonNLS*/);
}
}
- return "nStr=" + nStr + ", nID=" + nID + ", nSE=" + nSE + ", nH=" + nH + ",nN=" + nN; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ return "nStr="/*nonNLS*/ + nStr + ", nID="/*nonNLS*/ + nID + ", nSE="/*nonNLS*/ + nSE + ", nH="/*nonNLS*/ + nH + ",nN="/*nonNLS*/ + nN;
}
/**
@@ -323,7 +323,7 @@ public int index(Object obj) {
return fSet.index(obj);
}
catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Internal error in state serialization. Expected object missing from constant pool: " + obj); //$NON-NLS-1$
+ throw new IllegalArgumentException("Internal error in state serialization. Expected object missing from constant pool: "/*nonNLS*/ + obj);
}
}
/**
@@ -397,7 +397,7 @@ private void read(IDevelopmentContext dc, DataInputStream in, StateSnapV5 snap)
fSet.put(i, readNumber(in, tag));
break;
default:
- throw new IOException("Unexpected kind of pool item"); //$NON-NLS-1$
+ throw new IOException("Unexpected kind of pool item"/*nonNLS*/);
}
}
}
@@ -415,7 +415,7 @@ private IHandle readHandle(IDevelopmentContext dc, DataInputStream in, int tag)
case 5: {
// primitive type
// Should not occur since primitive types are well known and not written
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
case 6: {
// array type
@@ -433,7 +433,7 @@ private IHandle readHandle(IDevelopmentContext dc, DataInputStream in, int tag)
// method
IType declaringClass = getType(in.readInt());
if (declaringClass.isPrimitive() || declaringClass.isArray()) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
String name = getString(in.readInt());
int numParams = in.readByte() & 0xFF;
@@ -447,7 +447,7 @@ private IHandle readHandle(IDevelopmentContext dc, DataInputStream in, int tag)
// constructor
IType declaringClass = getType(in.readInt());
if (declaringClass.isPrimitive() || declaringClass.isArray()) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
int numParams = in.readByte() & 0xFF;
IType[] params = new IType[numParams];
@@ -460,7 +460,7 @@ private IHandle readHandle(IDevelopmentContext dc, DataInputStream in, int tag)
// field
IType declaringClass = getType(in.readInt());
if (declaringClass.isPrimitive() || declaringClass.isArray()) {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
String name = getString(in.readInt());
return declaringClass.getFieldHandle(name);
@@ -469,7 +469,7 @@ private IHandle readHandle(IDevelopmentContext dc, DataInputStream in, int tag)
// image
return dc.getImage();
default:
- throw new IOException("Unexpected kind of pool item"); //$NON-NLS-1$
+ throw new IOException("Unexpected kind of pool item"/*nonNLS*/);
}
}
/**
@@ -490,7 +490,7 @@ private Number readNumber(DataInputStream in, int tag) throws IOException {
// Double
return new Double(Double.longBitsToDouble(in.readLong()));
default:
- throw new IOException("Unexpected type of number"); //$NON-NLS-1$
+ throw new IOException("Unexpected type of number"/*nonNLS*/);
}
}
/**
@@ -539,7 +539,7 @@ public void write(DataOutputStream out) throws IOException {
writeNumber((Number)obj, out); // tags 12 through 15
}
else {
- Assert.isTrue(false, "Unexpected kind of pool item"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unexpected kind of pool item"/*nonNLS*/);
}
}
}
@@ -559,7 +559,7 @@ private void writeHandle(IHandle h, DataOutputStream out) throws IOException {
if (t.isPrimitive()) {
// tag=5
// Primitive types should not show up since they are well known and are not written.
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
else if (t.isArray()) {
ArrayTypeHandleImpl at = (ArrayTypeHandleImpl)t;
@@ -611,7 +611,7 @@ private void writeHandle(IHandle h, DataOutputStream out) throws IOException {
out.writeByte(11);
break;
default:
- Assert.isTrue(false, "Unknown kind of handle"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unknown kind of handle"/*nonNLS*/);
}
}
/**
@@ -635,7 +635,7 @@ private void writeNumber(Number num, DataOutputStream out) throws IOException {
out.writeLong(Double.doubleToLongBits(num.doubleValue()));
}
else {
- Assert.isTrue(false, "Unexpected type of number"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unexpected type of number"/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapV5.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapV5.java
index 75baf0db3f..e7f9d4f4fd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapV5.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/StateSnapV5.java
@@ -75,7 +75,7 @@ protected void addDependencyGraphToPool(StateImpl state, StateSnapConstantPool p
pool.add(((ZipNode)node).getZipFile());
break;
default:
- Assert.isTrue(false, "Unexpected kind of node"); //$NON-NLS-1$
+ Assert.isTrue(false, "Unexpected kind of node"/*nonNLS*/);
}
// Don't need to process node dependents here, since they're nodes as well
// and will have their info added to the pool above.
@@ -153,7 +153,7 @@ protected void addTypeStructureEntryToPool(TypeStructureEntry tsEntry, StateSnap
pool.add(tsEntry.getType());
}
protected void badFormat() throws IOException {
- throw new IOException("Error in format"); //$NON-NLS-1$
+ throw new IOException("Error in format"/*nonNLS*/);
}
/**
* Check that the next section has the given name.
@@ -202,7 +202,7 @@ public StateImpl read(JavaDevelopmentContextImpl dc, IProject project, DataInput
* Read the build context.
*/
protected IImageContext readBuildContext(IDevelopmentContext dc, StateSnapConstantPool pool, DataInputStream in) throws IOException {
- checkSection(in, "BuildContext"); //$NON-NLS-1$
+ checkSection(in, "BuildContext"/*nonNLS*/);
int numPkgs = in.readInt();
if (numPkgs == -1) {
return null;
@@ -218,7 +218,7 @@ protected IImageContext readBuildContext(IDevelopmentContext dc, StateSnapConsta
* The state is needed to create CompilationUnit objects from SourceEntry objects.
*/
protected DependencyGraph readDependencyGraph(StateSnapConstantPool pool, DataInputStream in, StateImpl state) throws IOException {
- checkSection(in, "DependencyGraph"); //$NON-NLS-1$
+ checkSection(in, "DependencyGraph"/*nonNLS*/);
DependencyGraph graph = new DependencyGraph();
// Avoid creating package elements for each node and dependency.
@@ -268,7 +268,7 @@ protected DependencyGraph readDependencyGraph(StateSnapConstantPool pool, DataIn
* Read the package map.
*/
protected PackageMap readPackageMap(StateSnapConstantPool pool, DataInputStream in) throws IOException {
- checkSection(in, "PackageMap"); //$NON-NLS-1$
+ checkSection(in, "PackageMap"/*nonNLS*/);
PackageMap map = new PackageMap();
int size = in.readInt();
for (int i = 0; i < size; ++i) {
@@ -286,7 +286,7 @@ protected PackageMap readPackageMap(StateSnapConstantPool pool, DataInputStream
* Read the principal structure table.
*/
protected Hashtable readPrincipalStructureTable(StateSnapConstantPool pool, DataInputStream in, StateImpl state) throws IOException {
- checkSection(in, "PrincipalStructureTable"); //$NON-NLS-1$
+ checkSection(in, "PrincipalStructureTable"/*nonNLS*/);
int numEntries = in.readInt();
Hashtable table = new Hashtable(numEntries * 2 + 1);
for (int i = 0; i < numEntries; ++i) {
@@ -314,7 +314,7 @@ protected ProblemDetailImpl readProblem(StateSnapConstantPool pool, DataInputStr
* Read the problem reporter.
*/
protected IProblemReporter readProblemReporter(IProject project, StateSnapConstantPool pool, DataInputStream in) throws IOException {
- checkSection(in, "Problems"); //$NON-NLS-1$
+ checkSection(in, "Problems"/*nonNLS*/);
IProblemReporter reporter = null;
boolean isProblemTable = in.readBoolean();
if (isProblemTable) {
@@ -330,14 +330,14 @@ protected IProblemReporter readProblemReporter(IProject project, StateSnapConsta
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
- throw new IOException("Class " + className + " was not found."); //$NON-NLS-2$ //$NON-NLS-1$
+ throw new IOException("Class "/*nonNLS*/ + className + " was not found."/*nonNLS*/);
}
try {
reporter = (IProblemReporter) clazz.newInstance();
} catch (InstantiationException e) {
- throw new IOException("Could not instanciate " + clazz.getName()); //$NON-NLS-1$
+ throw new IOException("Could not instanciate "/*nonNLS*/ + clazz.getName());
} catch (IllegalAccessException e) {
- throw new IOException("Could not instanciate " + clazz.getName()); //$NON-NLS-1$
+ throw new IOException("Could not instanciate "/*nonNLS*/ + clazz.getName());
}
reporter.initialize(project, JavaModelManager.getJavaModelManager().getDevelopmentContext(project));
}
@@ -347,7 +347,7 @@ protected IProblemReporter readProblemReporter(IProject project, StateSnapConsta
* Read the source element table.
*/
protected SourceElementTable readSourceElementTable(StateSnapConstantPool pool, DataInputStream in) throws IOException {
- checkSection(in, "SourceElementTable"); //$NON-NLS-1$
+ checkSection(in, "SourceElementTable"/*nonNLS*/);
SourceElementTable table = new SourceElementTable();
int numPackages = in.readInt();
for (int i = 0; i < numPackages; ++i) {
@@ -476,7 +476,7 @@ protected void skipAttributes(DataInputStream in) throws IOException {
* Write the build context.
*/
protected void writeBuildContext(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("BuildContext"); //$NON-NLS-1$
+ out.writeUTF("BuildContext"/*nonNLS*/);
IImageContext ctx = state.getBuildContext();
if (ctx == null) {
out.writeInt(-1);
@@ -493,7 +493,7 @@ protected void writeBuildContext(StateImpl state, StateSnapConstantPool pool, Da
* Write the dependency graph.
*/
protected void writeDependencyGraph(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("DependencyGraph"); //$NON-NLS-1$
+ out.writeUTF("DependencyGraph"/*nonNLS*/);
DependencyGraph graph = state.getInternalDependencyGraph();
graph.integrityCheck();
/**
@@ -508,7 +508,7 @@ protected void writeDependencyGraph(StateImpl state, StateSnapConstantPool pool,
out.writeBoolean(true);
SourceEntry sEntry = state.getSourceEntry(jcu.getPackageElement());
if (sEntry == null) {
- System.out.println("Warning: StatSnap: Attempt to serialize dependency graph node for missing JCU: " + jcu.getPackageElement() + ". Skipping..."); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Warning: StatSnap: Attempt to serialize dependency graph node for missing JCU: "/*nonNLS*/ + jcu.getPackageElement() + ". Skipping..."/*nonNLS*/);
} else {
Assert.isNotNull(sEntry);
out.writeInt(pool.index(sEntry));
@@ -572,7 +572,7 @@ protected void writeEmptyAttributes(DataOutputStream out) throws IOException {
* Write the package map.
*/
protected void writePackageMap(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("PackageMap"); //$NON-NLS-1$
+ out.writeUTF("PackageMap"/*nonNLS*/);
PackageMap map = state.getPackageMap();
out.writeInt(map.size());
int count = 0;
@@ -592,7 +592,7 @@ protected void writePackageMap(StateImpl state, StateSnapConstantPool pool, Data
* Write the principal structure table.
*/
protected void writePrincipalStructureTable(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("PrincipalStructureTable"); //$NON-NLS-1$
+ out.writeUTF("PrincipalStructureTable"/*nonNLS*/);
Hashtable table = state.getPrincipalStructureTable();
int num = table.size();
out.writeInt(num);
@@ -621,7 +621,7 @@ protected void writeProblem(ProblemDetailImpl pb, StateSnapConstantPool pool, Da
* Write the problem reporter.
*/
protected void writeProblemReporter(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("Problems"); //$NON-NLS-1$
+ out.writeUTF("Problems"/*nonNLS*/);
IProblemReporter reporter = state.getProblemReporter();
if (reporter instanceof ProblemTable) {
out.writeBoolean(true);
@@ -645,7 +645,7 @@ protected void writeProblemReporter(StateImpl state, StateSnapConstantPool pool,
* Write the source element table.
*/
protected void writeSourceElementTable(StateImpl state, StateSnapConstantPool pool, DataOutputStream out) throws IOException {
- out.writeUTF("SourceElementTable"); //$NON-NLS-1$
+ out.writeUTF("SourceElementTable"/*nonNLS*/);
SourceElementTable table = state.getSourceElementTable();
int num = table.numPackages();
out.writeInt(num);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeCollaboratorIndictment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeCollaboratorIndictment.java
index b799ee9ff5..622b1e5361 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeCollaboratorIndictment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeCollaboratorIndictment.java
@@ -28,6 +28,6 @@ protected TypeCollaboratorIndictment(char[] name) {
*/
public String toString() {
// don't use + with char[]
- return new StringBuffer("TypeIndictment(").append(fName).append(")").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ return new StringBuffer("TypeIndictment("/*nonNLS*/).append(fName).append(")"/*nonNLS*/).toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeHierarchyIndictment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeHierarchyIndictment.java
index 97d8a65c21..cf0bf75dfa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeHierarchyIndictment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeHierarchyIndictment.java
@@ -28,6 +28,6 @@ protected TypeHierarchyIndictment(char[] name) {
*/
public String toString() {
// don't use + with char[]
- return new StringBuffer("TypeHierarchyIndictment(").append(fName).append(")").toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ return new StringBuffer("TypeHierarchyIndictment("/*nonNLS*/).append(fName).append(")"/*nonNLS*/).toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImpl.java
index d398e6e1eb..a7b9c0dc34 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImpl.java
@@ -16,7 +16,7 @@ public abstract class TypeImpl extends NonStateSpecificHandleImpl implements ITy
typeA = (IType)a;
typeB = (IType)b;
} catch (ClassCastException e) {
- Assert.isTrue(false, "Should only be comparing ITypes"); //$NON-NLS-1$
+ Assert.isTrue(false, "Should only be comparing ITypes"/*nonNLS*/);
}
return typeA.getName().compareTo(typeB.getName());
}
@@ -149,7 +149,7 @@ public int getDeclaredModifiers() throws NotPresentException {
* a String of length 0.
*/
public String getDeclaredName() throws NotPresentException {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
/**
* If the class or interface represented by this Type object is
@@ -476,6 +476,6 @@ public boolean isTopLevel() throws org.eclipse.jdt.internal.core.builder.NotPres
* only (NON-NLS).
*/
public String toString() {
- return "type " + getName(); //$NON-NLS-1$
+ return "type "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImplSWH.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImplSWH.java
index 8f50227169..373d85435e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImplSWH.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeImplSWH.java
@@ -126,7 +126,7 @@ public int getDeclaredModifiers() throws NotPresentException {
* a String of length 0.
*/
public String getDeclaredName() throws NotPresentException {
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
}
/**
* If the class or interface represented by this Type object is
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeNode.java
index e99317d460..bd9a84b627 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeNode.java
@@ -63,6 +63,6 @@ public IType[] getTypes() {
* purposes only.
*/
public String toString() {
- return "TypeNode(" + fType.getFileName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "TypeNode("/*nonNLS*/ + fType.getFileName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeStructureEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeStructureEntry.java
index bdb9564bf8..3e11a4f827 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeStructureEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/TypeStructureEntry.java
@@ -92,11 +92,11 @@ int getCRC32() {
* @return a string representation of the receiver
*/
public String toString() {
- StringBuffer buf = new StringBuffer("TypeStructureEntry("); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("TypeStructureEntry("/*nonNLS*/);
if (fType != null) {
buf.append(fType.getName());
}
- buf.append(")"); //$NON-NLS-1$
+ buf.append(")"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/UnmodifiedBuilderType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/UnmodifiedBuilderType.java
index 83dd0eff3a..21812de253 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/UnmodifiedBuilderType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/UnmodifiedBuilderType.java
@@ -52,6 +52,6 @@ public boolean isAffected() {
* For debugging only
*/
public String toString() {
- return "UnmodifiedBuilderType(" + fNewTSEntry.getType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "UnmodifiedBuilderType("/*nonNLS*/ + fNewTSEntry.getType().getName() + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/WorkQueue.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/WorkQueue.java
index 7186c891c8..8f263a08a0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/WorkQueue.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/WorkQueue.java
@@ -61,7 +61,7 @@ public void add(PackageElement element) {
} else {
if (entry.status != NEEDS_COMPILE) {
if (entry.status == COMPILED) {
- System.out.println("Warning: image builder wants to recompile already compiled element: " + element); //$NON-NLS-1$
+ System.out.println("Warning: image builder wants to recompile already compiled element: "/*nonNLS*/ + element);
}
entry.status = NEEDS_COMPILE;
needsCompileList.addElement(element);
@@ -79,7 +79,7 @@ public void compiled(PackageElement element) {
entries.put(element, entry);
} else {
if (entry.status != NEEDS_COMPILE) {
- System.out.println("Warning: Java builder compiled the same element twice: " + element); //$NON-NLS-1$
+ System.out.println("Warning: Java builder compiled the same element twice: "/*nonNLS*/ + element);
}
needsCompileList.removeElement(element);
}
@@ -117,6 +117,6 @@ public boolean needsCompile(PackageElement element) {
return entry != null && entry.status == NEEDS_COMPILE;
}
public String toString() {
- return "WorkQueue: " + needsCompileList; //$NON-NLS-1$
+ return "WorkQueue: "/*nonNLS*/ + needsCompileList;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ZipNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ZipNode.java
index 635086d5bc..2f51cb3f79 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ZipNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/ZipNode.java
@@ -57,6 +57,6 @@ public IPath getZipFile() {
* purposes only.
*/
public String toString() {
- return "ZipNode(" + fZipFile + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "ZipNode("/*nonNLS*/ + fZipFile + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
index e3cc003fdb..2e7995f41a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
@@ -7,17 +7,16 @@ package org.eclipse.jdt.internal.core.eval;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.eval.*;
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
import org.eclipse.jdt.internal.codeassist.ICompletionRequestor;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.eval.*;
import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.builder.impl.JavaBuilder;
import org.eclipse.jdt.internal.core.builder.impl.ProblemFactory;
-import org.eclipse.jdt.internal.core.ClassFile;
import org.eclipse.jdt.internal.eval.*;
import java.util.Locale;
@@ -53,7 +52,7 @@ public IGlobalVariable[] allVariables() {
*/
protected void checkBuilderState() throws JavaModelException {
if (!getProject().hasBuildState()) {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.EVALUATION_ERROR, Util.bind("eval.needBuiltState"))); //$NON-NLS-1$
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.EVALUATION_ERROR, Util.bind("eval.needBuiltState"/*nonNLS*/)));
}
}
/**
@@ -65,7 +64,7 @@ public void codeComplete(String codeSnippet, int position, ICodeCompletionReques
position,
this.project.getSearchableNameEnvironment(),
new CompletionRequestorWrapper(requestor),
- JavaModelManager.getOptions()
+ JavaModelManager.convertConfigurableOptions(JavaCore.getOptions())
);
}
/**
@@ -79,7 +78,7 @@ public IJavaElement[] codeSelect(String codeSnippet, int offset, int length) thr
offset + length - 1,
this.project.getSearchableNameEnvironment(),
requestor,
- JavaModelManager.getOptions()
+ JavaModelManager.convertConfigurableOptions(JavaCore.getOptions())
);
return requestor.getElements();
}
@@ -91,7 +90,7 @@ public void deleteVariable(IGlobalVariable variable) {
GlobalVariableWrapper wrapper = (GlobalVariableWrapper)variable;
this.context.deleteVariable(wrapper.variable);
} else {
- throw new Error("Unknown implementation of IGlobalVariable"); //$NON-NLS-1$
+ throw new Error("Unknown implementation of IGlobalVariable"/*nonNLS*/);
}
}
/**
@@ -138,15 +137,6 @@ public void evaluateCodeSnippet(
}
this.context.setImports(importsNames);
}
- } else {
- // try to retrieve imports from the source
- SourceMapper sourceMapper = ((ClassFile) declaringType.getClassFile()).getSourceMapper();
- if (sourceMapper != null) {
- char[][] imports = sourceMapper.getImports((BinaryType) declaringType);
- if (imports != null) {
- this.context.setImports(imports);
- }
- }
}
}
try {
@@ -203,7 +193,7 @@ protected INameEnvironment getBuildNameEnvironment() throws JavaModelException {
* Returns the compiler's configurable options.
*/
protected ConfigurableOption[] getCompilerOptions() throws JavaModelException {
- return JavaModelManager.getOptions();
+ return JavaModelManager.convertConfigurableOptions(JavaCore.getOptions());
}
/**
* @see org.eclipse.jdt.core.eval.IEvaluationContext#getImports
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
index c8a6c6265b..41e2274f3f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
@@ -162,37 +162,30 @@ public void recordSuperType(char[] superTypeName, char[] superQualification, cha
public String toString() {
StringBuffer buffer = new StringBuffer();
if (this.modifiers == IConstants.AccPublic) {
- buffer.append("public "); //$NON-NLS-1$
+ buffer.append("public "/*nonNLS*/);
}
if (this.isClass()) {
- buffer.append("class "); //$NON-NLS-1$
+ buffer.append("class "/*nonNLS*/);
} else {
- buffer.append("interface "); //$NON-NLS-1$
+ buffer.append("interface "/*nonNLS*/);
}
if (this.name != null) {
buffer.append(this.name);
}
if (this.superclass != null) {
- buffer.append("\n extends "); //$NON-NLS-1$
+ buffer.append("\n extends "/*nonNLS*/);
buffer.append(this.superclass);
}
int length;
if (this.superInterfaces != null && (length = this.superInterfaces.length) != 0) {
- buffer.append("\n implements "); //$NON-NLS-1$
+ buffer.append("\n implements "/*nonNLS*/);
for (int i = 0; i < length; i++) {
buffer.append(this.superInterfaces[i]);
if (i != length - 1) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
}
}
return buffer.toString();
}
-
-/**
- * @see org.eclipse.jdt.internal.compiler.env.IBinaryType.
- */
-public char[] sourceFileName() {
- return null;
-}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
index b611d2fe5c..1b204e594d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
@@ -75,7 +75,7 @@ public class IndexBasedHierarchyBuilder extends HierarchyBuilder {
return name;
}
public String toString(){
- StringBuffer buffer = new StringBuffer("Queue:\n"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("Queue:\n"/*nonNLS*/);
for (int i = this.start; i <= this.end; i++){
buffer.append(names[i]).append('\n');
}
@@ -319,7 +319,7 @@ private void createInfoFromClassFile(Openable handle, String osPath, Vector info
*/
private void createInfoFromClassFileInJar(Openable classFile, Vector infos) throws JavaModelException {
IJavaElement pkg = classFile.getParent();
- String classFilePath = pkg.getElementName().replace('.', '/') + "/" + classFile.getElementName(); //$NON-NLS-1$
+ String classFilePath = pkg.getElementName().replace('.', '/') + "/"/*nonNLS*/ + classFile.getElementName();
IGenericType info = null;
java.util.zip.ZipFile zipFile = null;
try {
@@ -443,7 +443,7 @@ public static void searchAllPossibleSubTypes(
IIndexSearchRequestor searchRequestor = new IndexSearchAdapter(){
public void acceptSuperTypeReference(String resourcePath, char[] qualification, char[] typeName, char[] enclosingTypeName, char classOrInterface, char[] superQualification, char[] superTypeName, char superClassOrInterface, int modifiers) {
pathRequestor.acceptPath(resourcePath);
- if (resourcePath.endsWith("class")){ //$NON-NLS-1$
+ if (resourcePath.endsWith("class"/*nonNLS*/)){
HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(resourcePath);
if (binaryType == null){
binaryType = new HierarchyBinaryType(modifiers, qualification, typeName, enclosingTypeName, classOrInterface);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
index afb64f0fd0..de684ca051 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
@@ -1022,7 +1022,7 @@ public void refresh(IProgressMonitor monitor) throws JavaModelException {
}
fProgressMonitor = monitor;
if (monitor != null) {
- monitor.beginTask(Util.bind("hierarchy.creating"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ monitor.beginTask(Util.bind("hierarchy.creating"/*nonNLS*/), IProgressMonitor.UNKNOWN);
}
compute();
if (fType != null) {
@@ -1097,7 +1097,7 @@ private boolean subtypesIncludeSupertypeOf(IType type) {
return false;
}
if (superclassName == null) {
- superclassName = "Object"; //$NON-NLS-1$
+ superclassName = "Object"/*nonNLS*/;
}
int dot = -1;
String simpleSuper = (dot = superclassName.lastIndexOf('.')) > -1 ?
@@ -1133,24 +1133,24 @@ private boolean subtypesIncludeSupertypeOf(IType type) {
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("Focus: "); //$NON-NLS-1$
- buffer.append(fType == null ? "<NONE>" : fType.getFullyQualifiedName()); //$NON-NLS-1$
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("Focus: "/*nonNLS*/);
+ buffer.append(fType == null ? "<NONE>"/*nonNLS*/ : fType.getFullyQualifiedName());
+ buffer.append("\n"/*nonNLS*/);
if (exists()) {
if (fType != null) {
- buffer.append("Super types:\n"); //$NON-NLS-1$
+ buffer.append("Super types:\n"/*nonNLS*/);
toString(buffer, fType, 1, true);
- buffer.append("Sub types:\n"); //$NON-NLS-1$
+ buffer.append("Sub types:\n"/*nonNLS*/);
toString(buffer, fType, 1, false);
} else {
- buffer.append("Sub types of root classes:\n"); //$NON-NLS-1$
+ buffer.append("Sub types of root classes:\n"/*nonNLS*/);
IType[] roots= getRootClasses();
for (int i= 0; i < roots.length; i++) {
toString(buffer, roots[i], 1, false);
}
}
} else {
- buffer.append("(Hierarchy became stale)"); //$NON-NLS-1$
+ buffer.append("(Hierarchy became stale)"/*nonNLS*/);
}
return buffer.toString();
}
@@ -1161,7 +1161,7 @@ public String toString() {
*/
private void toString(StringBuffer buffer, IType type, int indent, boolean ascendant) {
for (int i= 0; i < indent; i++) {
- buffer.append(" "); //$NON-NLS-1$
+ buffer.append(" "/*nonNLS*/);
}
buffer.append(type.getFullyQualifiedName());
buffer.append('\n');
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
index 4b6b41e6bd..b7454d9e55 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
@@ -22,11 +22,11 @@ public CompilationUnit(char[] contents, char[] filename) {
fFileName = filename;
String file = new String(filename);
- int start = file.lastIndexOf("/") + 1; //$NON-NLS-1$
- if (start == 0 || start < file.lastIndexOf("\\")) //$NON-NLS-1$
- start = file.lastIndexOf("\\") + 1; //$NON-NLS-1$
+ int start = file.lastIndexOf("/"/*nonNLS*/) + 1;
+ if (start == 0 || start < file.lastIndexOf("\\"/*nonNLS*/))
+ start = file.lastIndexOf("\\"/*nonNLS*/) + 1;
- int end = file.lastIndexOf("."); //$NON-NLS-1$
+ int end = file.lastIndexOf("."/*nonNLS*/);
if (end == -1)
end = file.length();
@@ -42,6 +42,6 @@ public char[] getMainTypeName() {
return fMainTypeName;
}
public String toString() {
- return "CompilationUnit[" + new String(fFileName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
+ return "CompilationUnit["/*nonNLS*/ + new String(fFileName) + "]"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
index e7da005cdf..421510efea 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
@@ -33,7 +33,7 @@ class DOMCompilationUnit extends DOMNode implements IDOMCompilationUnit {
* Creates a new empty COMPILATION_UNIT document fragment.
*/
DOMCompilationUnit() {
- fHeader=""; //$NON-NLS-1$
+ fHeader=""/*nonNLS*/;
}
/**
* Creates a new COMPILATION_UNIT on the given range of the document.
@@ -47,7 +47,7 @@ DOMCompilationUnit() {
*/
DOMCompilationUnit(char[] document, int[] sourceRange) {
super(document, sourceRange, null, new int[]{-1, -1});
- fHeader = ""; //$NON-NLS-1$
+ fHeader = ""/*nonNLS*/;
}
/**
* @see DOMNode#appendContents(CharArrayBuffer)
@@ -75,7 +75,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
if (parent.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
return ((IPackageFragment)parent).getCompilationUnit(getName());
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -102,7 +102,7 @@ public String getName() {
topLevelType= firstType;
}
if (topLevelType != null) {
- return topLevelType.getName() + ".java"; //$NON-NLS-1$
+ return topLevelType.getName() + ".java"/*nonNLS*/;
} else {
return null;
}
@@ -174,6 +174,6 @@ protected void shareContents(DOMNode node) {
* @see IDOMNode#toString()
*/
public String toString() {
- return "COMPILATION_UNIT: " + getName(); //$NON-NLS-1$
+ return "COMPILATION_UNIT: "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
index d6e1b1a010..e9d22f5c3a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
@@ -229,7 +229,7 @@ protected void becomeDetailed() throws DOMException {
DOMBuilder builder = new DOMBuilder();
IDOMField[] details= builder.createFields(source.toCharArray());
if (details.length == 0) {
- throw new DOMException(Util.bind("dom.cannotDetail")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.cannotDetail"/*nonNLS*/));
} else {
node= this;
for (int i= 0; i < details.length; i++) {
@@ -316,7 +316,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
if (parent.getElementType() == IJavaElement.TYPE) {
return ((IType)parent).getField(getName());
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -561,7 +561,7 @@ protected void setIsVariableDeclarator(boolean isVariableDeclarator) {
*/
public void setName(String name) throws IllegalArgumentException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
} else {
super.setName(name);
setTypeAltered(true);
@@ -572,7 +572,7 @@ public void setName(String name) throws IllegalArgumentException {
*/
public void setType(String typeName) throws IllegalArgumentException {
if (typeName == null) {
- throw new IllegalArgumentException(Util.bind("element.nullType")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullType"/*nonNLS*/));
}
becomeDetailed();
expand();
@@ -603,6 +603,6 @@ protected void shareContents(DOMNode node) {
* @see IDOMNode#toString()
*/
public String toString() {
- return "FIELD: " + getName(); //$NON-NLS-1$
+ return "FIELD: "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
index a966e74095..5a9baf69fb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
@@ -27,7 +27,7 @@ class DOMImport extends DOMNode implements IDOMImport {
* Creates a new empty IMPORT node.
*/
DOMImport() {
- fName = "java.lang.*"; //$NON-NLS-1$
+ fName = "java.lang.*"/*nonNLS*/;
setMask(MASK_DETAILED_SOURCE_INDEXES, true);
}
/**
@@ -78,7 +78,7 @@ DOMImport(char[] document, int[] sourceRange, String name, boolean onDemand) {
protected void appendFragmentedContents(CharArrayBuffer buffer) {
if (fNameRange[0] < 0) {
buffer
- .append("import ") //$NON-NLS-1$
+ .append("import "/*nonNLS*/)
.append(fName)
.append(';')
.append(JavaModelManager.LINE_SEPARATOR);
@@ -112,7 +112,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
if (parent.getElementType() == IJavaElement.COMPILATION_UNIT) {
return ((ICompilationUnit)parent).getImport(getName());
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -138,16 +138,16 @@ protected DOMNode newDOMNode() {
*/
public void setName(String name) {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
}
becomeDetailed();
super.setName(name);
- fOnDemand = name.endsWith(".*"); //$NON-NLS-1$
+ fOnDemand = name.endsWith(".*"/*nonNLS*/);
}
/**
* @see IDOMNode#toString()
*/
public String toString() {
- return "IMPORT: " + getName(); //$NON-NLS-1$
+ return "IMPORT: "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
index 86a735a075..0a1e6a2a44 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
@@ -102,7 +102,7 @@ protected void appendMemberBodyContents(CharArrayBuffer buffer) {
.append(getBody())
.append(fDocument, fBodyRange[1] + 1, fSourceRange[1] - fBodyRange[1]);
} else {
- buffer.append("{}").append(JavaModelManager.LINE_SEPARATOR); //$NON-NLS-1$
+ buffer.append("{}"/*nonNLS*/).append(JavaModelManager.LINE_SEPARATOR);
}
}
/**
@@ -156,7 +156,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
}
return ((IType) parent).getInitializer(count);
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -219,6 +219,6 @@ protected void shareContents(DOMNode node) {
* @see IDOMNode#toString()
*/
public String toString() {
- return "INITIALIZER"; //$NON-NLS-1$
+ return "INITIALIZER"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
index 09596aecc7..76e25ee0b8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
@@ -281,7 +281,7 @@ public void setComment(String comment) {
/* see 1FVIJAH */
if (comment != null) {
String commentString = new String(comment);
- if (commentString.indexOf("@deprecated") >= 0) { //$NON-NLS-1$
+ if (commentString.indexOf("@deprecated"/*nonNLS*/) >= 0) {
fFlags= fFlags | IConstants.AccDeprecated;
return;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
index 59c20e4f61..921ef4cf5a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
@@ -226,7 +226,7 @@ DOMMethod(char[] document, int[] sourceRange, String name, int[] nameRange, int
*/
public void addException(String name) throws IllegalArgumentException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("dom.nullExceptionType")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.nullExceptionType"/*nonNLS*/));
}
if (fExceptions == null) {
fExceptions= new String[1];
@@ -241,10 +241,10 @@ public void addException(String name) throws IllegalArgumentException {
*/
public void addParameter(String type, String name) throws IllegalArgumentException {
if (type == null) {
- throw new IllegalArgumentException(Util.bind("dom.nullTypeParameter")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.nullTypeParameter"/*nonNLS*/));
}
if (name == null) {
- throw new IllegalArgumentException(Util.bind("dom.nullNameParameter")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.nullNameParameter"/*nonNLS*/));
}
if (fParameterNames == null) {
fParameterNames= new String[1];
@@ -306,7 +306,7 @@ protected void appendMemberDeclarationContents(CharArrayBuffer buffer) {
if (fExceptionRange[0] >= 0) {
buffer.append(fDocument, start, fExceptionRange[0] - start);
} else {
- buffer.append(" throws "); //$NON-NLS-1$
+ buffer.append(" throws "/*nonNLS*/);
}
// add exception list
if (fExceptionList != null) {
@@ -414,7 +414,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
}
return ((IType)parent).getMethod(name, sigs);
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -573,7 +573,7 @@ public void setBody(String body) {
fBody= body;
setHasBody(body != null);
if (!hasBody()) {
- fBody= ";"+JavaModelManager.LINE_SEPARATOR; //$NON-NLS-1$
+ fBody= ";"/*nonNLS*/+JavaModelManager.LINE_SEPARATOR;
}
}
/**
@@ -615,7 +615,7 @@ public void setExceptions(String[] names) {
*/
public void setName(String name) {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
} else {
super.setName(name);
}
@@ -631,17 +631,17 @@ public void setParameters(String[] types, String[] names) throws IllegalArgument
fParameterNames= null;
fParameterList= new char[] {'(',')'};
} else {
- throw new IllegalArgumentException(Util.bind("dom.mismatchArgNamesAndTypes")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.mismatchArgNamesAndTypes"/*nonNLS*/));
}
} else if (names.length != types.length) {
- throw new IllegalArgumentException(Util.bind("dom.mismatchArgNamesAndTypes")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.mismatchArgNamesAndTypes"/*nonNLS*/));
} else if (names.length == 0) {
setParameters(null, null);
} else {
fParameterNames= names;
fParameterTypes= types;
CharArrayBuffer parametersBuffer = new CharArrayBuffer();
- parametersBuffer.append("("); //$NON-NLS-1$
+ parametersBuffer.append("("/*nonNLS*/);
char[] comma = new char[] {',', ' '};
for (int i = 0; i < names.length; i++) {
if (i > 0) {
@@ -662,7 +662,7 @@ public void setParameters(String[] types, String[] names) throws IllegalArgument
*/
public void setReturnType(String name) throws IllegalArgumentException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("dom.nullReturnType")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.nullReturnType"/*nonNLS*/));
}
becomeDetailed();
fragment();
@@ -705,9 +705,9 @@ protected void shareContents(DOMNode node) {
*/
public String toString() {
if (isConstructor()) {
- return "CONSTRUCTOR"; //$NON-NLS-1$
+ return "CONSTRUCTOR"/*nonNLS*/;
} else {
- return "METHOD: " + getName(); //$NON-NLS-1$
+ return "METHOD: "/*nonNLS*/ + getName();
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
index aa6ca79618..660f13c795 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
@@ -331,23 +331,23 @@ protected abstract void appendFragmentedContents(CharArrayBuffer buffer);
void basicAddChild(IDOMNode child) throws IllegalArgumentException, DOMException {
// verify child may be added
if (!canHaveChildren()) {
- throw new DOMException(Util.bind("dom.unableAddChild")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.unableAddChild"/*nonNLS*/));
}
if (child == null) {
- throw new IllegalArgumentException(Util.bind("dom.addNullChild")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.addNullChild"/*nonNLS*/));
}
if (!isAllowableChild(child)) {
- throw new DOMException(Util.bind("dom.addIncompatibleChild")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addIncompatibleChild"/*nonNLS*/));
}
if (child.getParent() != null) {
- throw new DOMException(Util.bind("dom.addChildWithParent")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addChildWithParent"/*nonNLS*/));
}
/* NOTE: To test if the child is an ancestor of this node, we
* need only test if the root of this node is the child (the child
* is already a root since we have just guarenteed it has no parent).
*/
if (child == getRoot()) {
- throw new DOMException(Util.bind("dom.addAncestorAsChild")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addAncestorAsChild"/*nonNLS*/));
}
DOMNode node= (DOMNode)child;
@@ -379,7 +379,7 @@ protected void becomeDetailed() throws DOMException {
if (!isDetailed()) {
DOMNode detailed= getDetailedNode();
if (detailed == null) {
- throw new DOMException(Util.bind("dom.cannotDetail")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.cannotDetail"/*nonNLS*/));
}
if (detailed != this) {
shareContents(detailed);
@@ -652,23 +652,23 @@ public int getStartPosition() {
public void insertSibling(IDOMNode sibling) throws IllegalArgumentException, DOMException {
// verify sibling may be added
if (sibling == null) {
- throw new IllegalArgumentException(Util.bind("dom.addNullSibling")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.addNullSibling"/*nonNLS*/));
}
if (fParent == null) {
- throw new DOMException(Util.bind("dom.addSiblingBeforeRoot")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addSiblingBeforeRoot"/*nonNLS*/));
}
if (!fParent.isAllowableChild(sibling)) {
- throw new DOMException(Util.bind("dom.addIncompatibleSibling")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addIncompatibleSibling"/*nonNLS*/));
}
if (sibling.getParent() != null) {
- throw new DOMException(Util.bind("dom.addSiblingWithParent")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addSiblingWithParent"/*nonNLS*/));
}
/* NOTE: To test if the sibling is an ancestor of this node, we
* need only test if the root of this node is the child (the sibling
* is already a root since we have just guaranteed it has no parent).
*/
if (sibling == getRoot()) {
- throw new DOMException(Util.bind("dom.addAncestorAsSibling")); //$NON-NLS-1$
+ throw new DOMException(Util.bind("dom.addAncestorAsSibling"/*nonNLS*/));
}
DOMNode node= (DOMNode)sibling;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
index 87c7be8865..dec2d57e07 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
@@ -70,7 +70,7 @@ DOMPackage(char[] document, int[] sourceRange, String name, int[] nameRange) {
protected void appendFragmentedContents(CharArrayBuffer buffer) {
if (fNameRange[0] < 0) {
buffer
- .append("package ") //$NON-NLS-1$
+ .append("package "/*nonNLS*/)
.append(fName)
.append(';')
.append(JavaModelManager.LINE_SEPARATOR);
@@ -104,7 +104,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
if (parent.getElementType() == IJavaElement.COMPILATION_UNIT) {
return ((ICompilationUnit)parent).getPackageDeclaration(getName());
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -130,6 +130,6 @@ public void setName(String name) {
* @see IDOMNode#toString()
*/
public String toString() {
- return "PACKAGE: " + getName(); //$NON-NLS-1$
+ return "PACKAGE: "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
index 320560e948..f1132242f7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
@@ -226,7 +226,7 @@ DOMType(char[] document, int[] sourceRange, String name, int[] nameRange, int fl
*/
public void addSuperInterface(String name) throws IllegalArgumentException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("dom.addNullInterface")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.addNullInterface"/*nonNLS*/));
}
if (fSuperInterfaces == null) {
fSuperInterfaces= new String[1];
@@ -264,7 +264,7 @@ protected void appendMemberDeclarationContents(CharArrayBuffer buffer) {
if (getMask(MASK_TYPE_HAS_SUPERCLASS)) {
hasSuperclass = true;
if (fExtendsRange[0] < 0) {
- buffer.append(" extends "); //$NON-NLS-1$
+ buffer.append(" extends "/*nonNLS*/);
} else {
buffer.append(fDocument, fExtendsRange[0], fExtendsRange[1] + 1 - fExtendsRange[0]);
}
@@ -277,7 +277,7 @@ protected void appendMemberDeclarationContents(CharArrayBuffer buffer) {
if (getMask(MASK_TYPE_HAS_INTERFACES)) {
hasInterfaces = true;
if (fImplementsRange[0] < 0) {
- buffer.append(" implements "); //$NON-NLS-1$
+ buffer.append(" implements "/*nonNLS*/);
} else {
buffer.append(fDocument, fImplementsRange[0], fImplementsRange[1] + 1 - fImplementsRange[0]);
}
@@ -307,7 +307,7 @@ protected void appendMemberDeclarationContents(CharArrayBuffer buffer) {
} else {
if (getMask(MASK_TYPE_HAS_INTERFACES)) {
if (fExtendsRange[0] < 0) {
- buffer.append(" extends "); //$NON-NLS-1$
+ buffer.append(" extends "/*nonNLS*/);
} else {
buffer.append(fDocument, fExtendsRange[0], fExtendsRange[1] + 1 - fExtendsRange[0]);
}
@@ -377,7 +377,7 @@ public IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentEx
} else if (parent.getElementType() == IJavaElement.COMPILATION_UNIT) {
return ((ICompilationUnit)parent).getType(getName());
} else {
- throw new IllegalArgumentException(Util.bind("element.illegalParent")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.illegalParent"/*nonNLS*/));
}
}
/**
@@ -527,9 +527,9 @@ public void setClass(boolean b) {
fragment();
setMask(MASK_TYPE_IS_CLASS, b);
if (b) {
- fTypeKeyword= "class"; //$NON-NLS-1$
+ fTypeKeyword= "class"/*nonNLS*/;
} else {
- fTypeKeyword= "interface"; //$NON-NLS-1$
+ fTypeKeyword= "interface"/*nonNLS*/;
setSuperclass(null);
}
}
@@ -556,7 +556,7 @@ void setCloseBodyRangeStart(int start) {
*/
public void setName(String name) throws IllegalArgumentException {
if (name == null) {
- throw new IllegalArgumentException(Util.bind("element.nullName")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("element.nullName"/*nonNLS*/));
}
super.setName(name);
Enumeration children= getChildren();
@@ -588,7 +588,7 @@ public void setSuperclass(String superclassName) {
public void setSuperInterfaces(String[] names) {
becomeDetailed();
if (names == null) {
- throw new IllegalArgumentException(Util.bind("dom.nullInterfaces")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Util.bind("dom.nullInterfaces"/*nonNLS*/));
}
fragment();
fSuperInterfaces= names;
@@ -601,7 +601,7 @@ public void setSuperInterfaces(String[] names) {
CharArrayBuffer buffer = new CharArrayBuffer();
for (int i = 0; i < names.length; i++) {
if (i > 0) {
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
}
buffer.append(names[i]);
}
@@ -636,6 +636,6 @@ protected void shareContents(DOMNode node) {
* @see IDOMNode#toString()
*/
public String toString() {
- return "TYPE: " + getName(); //$NON-NLS-1$
+ return "TYPE: "/*nonNLS*/ + getName();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
index 214c053afe..49830eb364 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
@@ -27,7 +27,7 @@ public void acceptImport(int declarationStart, int declarationEnd, char[] name,
String importName = new String(name);
/** name is set to contain the '*' */
if (onDemand) {
- importName+=".*"; //$NON-NLS-1$
+ importName+=".*"/*nonNLS*/;
}
fNode= new DOMImport(fDocument, sourceRange, importName, onDemand);
addChild(fNode);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/lookup/ReferenceInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/lookup/ReferenceInfo.java
index 8e5fd4b26f..6a73282029 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/lookup/ReferenceInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/lookup/ReferenceInfo.java
@@ -53,12 +53,12 @@ public char[][] getNames() {
* For debugging only
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ReferenceInfo("); //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer("ReferenceInfo("/*nonNLS*/);
for (int i = 0; i < fNames.length; i++) {
buf.append(fNames[i]);
- buf.append(" "); //$NON-NLS-1$
+ buf.append(" "/*nonNLS*/);
}
- buf.append(")"); //$NON-NLS-1$
+ buf.append(")"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Messages.properties b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties
index a3c90e4f40..a49d4524f5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Messages.properties
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties
@@ -75,7 +75,7 @@ build.analyzingSources = Analyzing sources
build.analyzing = Analyzing {0}
build.preparingBuild = Preparing for build
build.compiling = Compiling {0}
-build.readingDelta = Reading resource change information for: {0}
+build.readingDelta = Reading resource change information for : {0}
build.completed = Java build completed
build.builderName = Java Builder
build.compilingContent = Compiling content of {0}
@@ -149,7 +149,6 @@ classpath.needAbsolutePath = Path for IClasspathEntry must be absolute.
file.notFound = File not found.
file.badFormat = Bad format.
variable.badFormat = Bad format for variables.
-option.badFormat = Bad format for options.
path.nullPath = Path cannot be null.
path.mustBeAbsolute = Path must be absolute.
cache.invalidLoadFactor = Incorrect load factor
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
index eaf8532740..e846e1ac14 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
@@ -19,7 +19,7 @@ public AnonymousFileSource(File directory) {
if (!directory.exists()) {
directory.mkdirs();
} else if (!directory.isDirectory()) {
- throw new IllegalArgumentException("Directory arguments should be a directory."); //$NON-NLS-1$
+ throw new IllegalArgumentException("Directory arguments should be a directory."/*nonNLS*/);
}
fDirectory = directory;
}
@@ -30,7 +30,7 @@ public AnonymousFileSource(File directory) {
synchronized public RandomAccessFile allocateAnonymousFile() throws IOException {
File file = getAnonymousFile();
- return new RandomAccessFile(file, "rw"); //$NON-NLS-1$
+ return new RandomAccessFile(file, "rw"/*nonNLS*/);
}
/**
* Returns a URL on a newly allocated file with the given initial content.
@@ -38,17 +38,17 @@ synchronized public RandomAccessFile allocateAnonymousFile() throws IOException
*/
synchronized public URL allocateAnonymousURL(byte[] bytes) throws IOException {
try {
- byte hasharray[] = java.security.MessageDigest.getInstance("SHA").digest(bytes); //$NON-NLS-1$
+ byte hasharray[] = java.security.MessageDigest.getInstance("SHA"/*nonNLS*/).digest(bytes);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < hasharray.length; i++) {
sb.append(Character.forDigit((int)((hasharray[i] >> 4) & 0x0F), 16));
sb.append(Character.forDigit((int)(hasharray[i] & 0x0F), 16));
}
- sb.append(".jnk"); //$NON-NLS-1$
+ sb.append(".jnk"/*nonNLS*/);
String fileName = sb.toString();
File file = fileForName(fileName);
if (!file.exists()) {
- RandomAccessFile raf = new RandomAccessFile(file, "rw"); //$NON-NLS-1$
+ RandomAccessFile raf = new RandomAccessFile(file, "rw"/*nonNLS*/);
raf.write(bytes);
raf.close();
}
@@ -64,7 +64,7 @@ synchronized public URL allocateAnonymousURL(byte[] bytes) throws IOException {
static public URL convertFileToURL(File file) {
try {
String path = file.getCanonicalPath().replace(java.io.File.separatorChar, '/');
- return new URL("file", "", "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new URL("file"/*nonNLS*/, ""/*nonNLS*/, "/"/*nonNLS*/ + path);
}
catch (IOException ioe) {
throw new Error();
@@ -121,7 +121,7 @@ synchronized public String getAnonymousFileName(long l) {
sb.append(Character.forDigit((int)(l % 36), 36));
l /= 36;
}
- sb.append(".jnk"); //$NON-NLS-1$
+ sb.append(".jnk"/*nonNLS*/);
return sb.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DiskCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DiskCache.java
index ad02b6f058..7213985e80 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DiskCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DiskCache.java
@@ -171,9 +171,9 @@ public class DiskCache {
EntryCache fEntryCache;
- static final String CONTENTS_FILE_NAME = "contents"; //$NON-NLS-1$
- static final String TEMP_CONTENTS_FILE_NAME = "tempcont"; //$NON-NLS-1$
- static final String CONTENTS_VERSION = "DiskCache.V1.0"; //$NON-NLS-1$
+ static final String CONTENTS_FILE_NAME = "contents"/*nonNLS*/;
+ static final String TEMP_CONTENTS_FILE_NAME = "tempcont"/*nonNLS*/;
+ static final String CONTENTS_VERSION = "DiskCache.V1.0"/*nonNLS*/;
/**
* Set to true when cache is modified, cleared when saved.
@@ -217,7 +217,7 @@ public DiskCache(File directory, int spaceLimit) {
*/
public OutputStream add(final String key, int size, byte[] extraInfo) throws IOException {
if (size > fSpaceLimit*1024) {
- throw new IOException("Entry size greater than cache size"); //$NON-NLS-1$
+ throw new IOException("Entry size greater than cache size"/*nonNLS*/);
}
final File file;
OutputStream output;
@@ -518,7 +518,7 @@ public int getNumberOfFilesToBeDeleted() {
int spaceUsed = in.readInt(); /* Ignored -- updated as entries are read */
int numEntries = in.readInt();
if (!sig.equals(CONTENTS_VERSION)) {
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("file.badFormat"/*nonNLS*/));
}
/* Read to a temp. array of entries. The entries are in most- to
@@ -736,7 +736,7 @@ public synchronized void removeAll(Vector keys) {
}
}
};
- fPeriodicSaveThread.setName("DiskCache periodic save"); //$NON-NLS-1$
+ fPeriodicSaveThread.setName("DiskCache periodic save"/*nonNLS*/);
fPeriodicSaveThread.start();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
index bc32cd26f9..2f61613f59 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
@@ -62,30 +62,30 @@ public void dump(int[] val, int maxPerLine) {
if (!oneLine) {
++fTabLevel;
}
- fWriter.print("["); //$NON-NLS-1$
+ fWriter.print("["/*nonNLS*/);
for (int i = 0; i < len; ++i) {
if (!oneLine) {
if ((i % maxPerLine) == 0) {
fWriter.println();
tabIfNeeded();
fWriter.print(i);
- fWriter.print(": "); //$NON-NLS-1$
+ fWriter.print(": "/*nonNLS*/);
}
}
fWriter.print(val[i]);
if (i + 1 < len) {
- fWriter.print(", "); //$NON-NLS-1$
+ fWriter.print(", "/*nonNLS*/);
}
}
if (oneLine) {
- fWriter.print("]"); //$NON-NLS-1$
+ fWriter.print("]"/*nonNLS*/);
fWriter.println();
}
else {
fWriter.println();
--fTabLevel;
tabIfNeeded();
- fWriter.print("]"); //$NON-NLS-1$
+ fWriter.print("]"/*nonNLS*/);
fWriter.println();
}
}
@@ -94,7 +94,7 @@ public void dump(int[] val, int maxPerLine) {
*/
public void dump(Object[] val) {
int len = val.length;
- fWriter.print("["); //$NON-NLS-1$
+ fWriter.print("["/*nonNLS*/);
if (len > 0) {
fWriter.println();
++fTabLevel;
@@ -104,7 +104,7 @@ public void dump(Object[] val) {
--fTabLevel;
tabIfNeeded();
}
- fWriter.println("]"); //$NON-NLS-1$
+ fWriter.println("]"/*nonNLS*/);
}
/**
* Dumps the given array.
@@ -116,20 +116,20 @@ public void dump(String[] val, int maxPerLine) {
if (!oneLine) {
++fTabLevel;
}
- fWriter.print("["); //$NON-NLS-1$
+ fWriter.print("["/*nonNLS*/);
boolean newLine = !oneLine;
for (int i = 0; i < len; ++i) {
if (newLine) {
fWriter.println();
tabIfNeeded();
}
- fWriter.print("\"" + val[i] + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ fWriter.print("\""/*nonNLS*/ + val[i] + "\""/*nonNLS*/);
if (i + 1 < len) {
- fWriter.print(", "); //$NON-NLS-1$
+ fWriter.print(", "/*nonNLS*/);
}
newLine = (i != 0 && (i % maxPerLine) == 0);
}
- fWriter.print("]"); //$NON-NLS-1$
+ fWriter.print("]"/*nonNLS*/);
if (oneLine || newLine) {
fWriter.println();
}
@@ -144,18 +144,18 @@ public void dump(Object val) {
tabIfNeeded();
if (val instanceof IDumpable) {
IDumpable dumpable = (IDumpable) val;
- fWriter.println(classNameFor(val) + " {"); //$NON-NLS-1$
+ fWriter.println(classNameFor(val) + " {"/*nonNLS*/);
int originalLevel = fTabLevel;
++fTabLevel;
try {
dumpable.dump(this);
}
catch (Throwable t) {
- fWriter.println("*ERR*"); //$NON-NLS-1$
+ fWriter.println("*ERR*"/*nonNLS*/);
}
fTabLevel = originalLevel;
tabIfNeeded();
- fWriter.println("}"); //$NON-NLS-1$
+ fWriter.println("}"/*nonNLS*/);
}
else {
fWriter.println(val);
@@ -211,7 +211,7 @@ public void dump(String name, Object val) {
*/
public void dump(String name, String val) {
prefix(name);
- fWriter.println(val == null ? "null" : "\"" + val + "\""); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
+ fWriter.println(val == null ? "null"/*nonNLS*/ : "\""/*nonNLS*/ + val + "\""/*nonNLS*/);
}
/**
* Dumps the given value, with the given name as a prefix.
@@ -264,7 +264,7 @@ public void outdent() {
void prefix(String name) {
tabIfNeeded();
fWriter.print(name);
- fWriter.print(": "); //$NON-NLS-1$
+ fWriter.print(": "/*nonNLS*/);
}
/**
* Print an object directly, without a newline.
@@ -289,7 +289,7 @@ public void println(Object obj) {
*/
void tabIfNeeded() {
for (int i = 0; i < fTabLevel; ++i) {
- fWriter.print(" "); //$NON-NLS-1$
+ fWriter.print(" "/*nonNLS*/);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
index b6b72e4419..fbac18a93b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
@@ -80,7 +80,7 @@ public class LRUCache implements Cloneable {
*/
public String toString() {
- return "LRUCacheEntry [" + _fKey + "-->" + _fValue + "]"; //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-2$
+ return "LRUCacheEntry ["/*nonNLS*/ + _fKey + "-->"/*nonNLS*/ + _fValue + "]"/*nonNLS*/;
}
}
@@ -444,7 +444,7 @@ public class LRUCache implements Cloneable {
*/
public String toString() {
return
- "LRUCache " + (fCurrentSpace * 100.0 / fSpaceLimit) + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "LRUCache "/*nonNLS*/ + (fCurrentSpace * 100.0 / fSpaceLimit) + "% full\n"/*nonNLS*/ +
this.toStringContents();
}
/**
@@ -471,9 +471,9 @@ protected String toStringContents() {
String toString = sorter.sortedStrings[i];
Object value = this.get(sorter.sortedObjects[i]);
result.append(toString);
- result.append(" -> "); //$NON-NLS-1$
+ result.append(" -> "/*nonNLS*/);
result.append(value);
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
}
return result.toString();
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LookupTable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LookupTable.java
index 777bc912f7..74888e9e6b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LookupTable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LookupTable.java
@@ -62,7 +62,7 @@ public class LookupTable extends Dictionary implements Cloneable {
entry = null;
return next;
}
- throw new NoSuchElementException("LookupTable Enumerator"); //$NON-NLS-1$
+ throw new NoSuchElementException("LookupTable Enumerator"/*nonNLS*/);
}
}
/**
@@ -94,10 +94,10 @@ public class LookupTable extends Dictionary implements Cloneable {
*/
public LookupTable(int initialCapacity, float loadFactor) {
if (initialCapacity < 0)
- throw new IllegalArgumentException("Illegal Capacity: "+ //$NON-NLS-1$
+ throw new IllegalArgumentException("Illegal Capacity: "/*nonNLS*/+
initialCapacity);
if (loadFactor <= 0)
- throw new IllegalArgumentException("Illegal Load: "+loadFactor); //$NON-NLS-1$
+ throw new IllegalArgumentException("Illegal Load: "/*nonNLS*/+loadFactor);
if (initialCapacity==0)
initialCapacity = 1;
@@ -428,27 +428,27 @@ public class LookupTable extends Dictionary implements Cloneable {
for (int i = 0; i < keys.length; ++i) {
if (keys[i] == null) {
if (values[i] != null) {
- System.err.println("LookupTable sanity check in " + where + ": key is null, but value isn't at index " + i); //$NON-NLS-2$ //$NON-NLS-1$
+ System.err.println("LookupTable sanity check in "/*nonNLS*/ + where + ": key is null, but value isn't at index "/*nonNLS*/ + i);
throw new Error();
}
}
else {
if (values[i] == null) {
- System.err.println("LookupTable sanity check in " + where + ": value is null, but key isn't at index " + i); //$NON-NLS-2$ //$NON-NLS-1$
+ System.err.println("LookupTable sanity check in "/*nonNLS*/ + where + ": value is null, but key isn't at index "/*nonNLS*/ + i);
throw new Error();
}
else {
++n;
Object value = get(keys[i]);
if (value == null || value != values[i]) {
- System.err.println("LookupTable sanity check in " + where + ": key doesn't hash to proper value: " + keys[i]); //$NON-NLS-2$ //$NON-NLS-1$
+ System.err.println("LookupTable sanity check in "/*nonNLS*/ + where + ": key doesn't hash to proper value: "/*nonNLS*/ + keys[i]);
throw new Error();
}
}
}
}
if (n != count) {
- System.err.println("LookupTable sanity check in " + where + ": count is " + count + " but there are " + n + " entries"); //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ System.err.println("LookupTable sanity check in "/*nonNLS*/ + where + ": count is "/*nonNLS*/ + count + " but there are "/*nonNLS*/ + n + " entries"/*nonNLS*/);
throw new Error();
}
}
@@ -473,7 +473,7 @@ public class LookupTable extends Dictionary implements Cloneable {
*/
public synchronized String toString() {
StringBuffer buf = new StringBuffer();
- buf.append("{"); //$NON-NLS-1$
+ buf.append("{"/*nonNLS*/);
boolean first = true;
for (int i = 0, max = keys.length; i < max; i++) {
if (keys[i] != null) {
@@ -481,18 +481,18 @@ public class LookupTable extends Dictionary implements Cloneable {
first = false;
}
else {
- buf.append(", "); //$NON-NLS-1$
+ buf.append(", "/*nonNLS*/);
}
if (buf.length() > 1000) {
- buf.append("..."); //$NON-NLS-1$
+ buf.append("..."/*nonNLS*/);
break;
}
else {
- buf.append(keys[i]).append("=").append(values[i]); //$NON-NLS-1$
+ buf.append(keys[i]).append("="/*nonNLS*/).append(values[i]);
}
}
}
- buf.append("}"); //$NON-NLS-1$
+ buf.append("}"/*nonNLS*/);
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java
index 356e552868..6846b44865 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java
@@ -117,9 +117,9 @@ public String toString() {
String key = this.keyTable[i];
if (key != null) {
buffer.append(key);
- buffer.append(" -> "); //$NON-NLS-1$
+ buffer.append(" -> "/*nonNLS*/);
buffer.append(this.valueTable[i]);
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append("\n"/*nonNLS*/);
}
}
return buffer.toString();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringMatcher.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringMatcher.java
index 33492d8b22..3d161d9018 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringMatcher.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringMatcher.java
@@ -229,9 +229,9 @@ public class StringMatcher {
* @param p, a String object that is a simple regular expression with ‘*’ and/or ‘?’
*/
private void parseWildCards() {
- if(fPattern.startsWith("*")) //$NON-NLS-1$
+ if(fPattern.startsWith("*"/*nonNLS*/))
fHasLeadingStar = true;
- if(fPattern.endsWith("*")) { //$NON-NLS-1$
+ if(fPattern.endsWith("*"/*nonNLS*/)) {
/* make sure it's not an escaped wildcard */
if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
fHasTrailingStar = true;
diff --git a/org.eclipse.jdt.core/plugin.jars b/org.eclipse.jdt.core/plugin.jars
index 95b28d5d40..c6ba09bf88 100644
--- a/org.eclipse.jdt.core/plugin.jars
+++ b/org.eclipse.jdt.core/plugin.jars
@@ -1,5 +1,4 @@
jdtcore.jar=\
- Eclipse Java Ant Compiler,\
Eclipse Java Batch Compiler,\
Eclipse Java Code Assist,\
Eclipse Java Formatter,\
diff --git a/org.eclipse.jdt.core/scripts/pluginUpdate.xml b/org.eclipse.jdt.core/scripts/pluginUpdate.xml
index 2f2dd9e90a..10a526cdae 100644
--- a/org.eclipse.jdt.core/scripts/pluginUpdate.xml
+++ b/org.eclipse.jdt.core/scripts/pluginUpdate.xml
@@ -30,7 +30,6 @@
<echo message="UPDATE jdtcoresrc.zip" />
<zip zipfile="${dest}/jdtcoresrc.zip">
- <zipfileset dir="Eclipse Java Ant Compiler" />
<zipfileset dir="Eclipse Java Batch Compiler" />
<zipfileset dir="Eclipse Java Code Assist" />
<zipfileset dir="Eclipse Java Compiler" />
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
index b3d61db06c..ef7e7589a8 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
@@ -246,7 +246,7 @@ public void search(IWorkspace workspace, ISearchPattern searchPattern, IJavaSear
/* initialize progress monitor */
IProgressMonitor progressMonitor = resultCollector.getProgressMonitor();
if (progressMonitor != null) {
- progressMonitor.beginTask(Util.bind("engine.searching"), 105); // 5 for getting paths, 100 for locating matches //$NON-NLS-1$
+ progressMonitor.beginTask(Util.bind("engine.searching"/*nonNLS*/), 105); // 5 for getting paths, 100 for locating matches
}
/* index search */
@@ -417,7 +417,7 @@ public void searchAllTypeNames(
*/
public void searchDeclarationsOfAccessedFields(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
MatchLocator locator = new MatchLocator(
- (SearchPattern)createSearchPattern("*", IJavaSearchConstants.FIELD, IJavaSearchConstants.REFERENCES, true), //$NON-NLS-1$
+ (SearchPattern)createSearchPattern("*"/*nonNLS*/, IJavaSearchConstants.FIELD, IJavaSearchConstants.REFERENCES, true),
IInfoConstants.DeclarationInfo,
resultCollector,
new JavaWorkspaceScope());
@@ -464,7 +464,7 @@ public void searchDeclarationsOfAccessedFields(IWorkspace workspace, IJavaElemen
*/
public void searchDeclarationsOfReferencedTypes(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
MatchLocator locator = new MatchLocator(
- (SearchPattern)createSearchPattern("*", IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, true), //$NON-NLS-1$
+ (SearchPattern)createSearchPattern("*"/*nonNLS*/, IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, true),
IInfoConstants.DeclarationInfo,
resultCollector,
new JavaWorkspaceScope());
@@ -514,7 +514,7 @@ public void searchDeclarationsOfReferencedTypes(IWorkspace workspace, IJavaEleme
*/
public void searchDeclarationsOfSentMessages(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
MatchLocator locator = new MatchLocator(
- (SearchPattern)createSearchPattern("*", IJavaSearchConstants.METHOD, IJavaSearchConstants.REFERENCES, true), //$NON-NLS-1$
+ (SearchPattern)createSearchPattern("*"/*nonNLS*/, IJavaSearchConstants.METHOD, IJavaSearchConstants.REFERENCES, true),
IInfoConstants.DeclarationInfo,
resultCollector,
new JavaWorkspaceScope());
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
index ce9988288d..67bf68deeb 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
@@ -190,10 +190,10 @@ public class BlocksIndexInput extends IndexInput {
public void open() throws IOException {
if (!opened) {
- raf= new SafeRandomAccessFile(indexFile, "r"); //$NON-NLS-1$
+ raf= new SafeRandomAccessFile(indexFile, "r"/*nonNLS*/);
String sig= raf.readUTF();
if (!sig.equals(IIndexConstants.SIGNATURE))
- throw new IOException(Util.bind("exception.wrongFormat")); //$NON-NLS-1$
+ throw new IOException(Util.bind("exception.wrongFormat"/*nonNLS*/));
int summaryBlockNum= raf.readInt();
raf.seek(summaryBlockNum * (long) IIndexConstants.BLOCK_SIZE);
summary= new IndexSummary();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
index 8ac2060b40..a48657d6a8 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
@@ -152,7 +152,7 @@ public class BlocksIndexOutput extends IndexOutput {
firstInBlock= true;
firstIndexBlock= true;
firstFileListBlock= true;
- indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$
+ indexOut= new SafeRandomAccessFile(this.indexFile, "rw"/*nonNLS*/);
opened= true;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
index dc898376c0..8ede6b7ef8 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
@@ -46,15 +46,15 @@ public int hashCode(){
}
public String toString(){
StringBuffer buffer = new StringBuffer(word.length * 2);
- buffer.append("EntryResult: word="); //$NON-NLS-1$
+ buffer.append("EntryResult: word="/*nonNLS*/);
buffer.append(word);
- buffer.append(", refs={"); //$NON-NLS-1$
+ buffer.append(", refs={"/*nonNLS*/);
for (int i = 0; i < fileRefs.length; i++){
if (i > 0) buffer.append(',');
buffer.append(' ');
buffer.append(fileRefs[i]);
}
- buffer.append(" }"); //$NON-NLS-1$
+ buffer.append(" }"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
index b6d03a05f1..701ec7815f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
@@ -48,7 +48,7 @@ public class FileDocument extends PropertyDocument {
public String getType() {
int lastDot= file.getPath().lastIndexOf('.');
if (lastDot == -1)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
return file.getPath().substring(lastDot + 1);
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/HashtableOfObject.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/HashtableOfObject.java
index 1a63d4791c..d1e22b009e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/HashtableOfObject.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/HashtableOfObject.java
@@ -79,11 +79,11 @@ public final class HashtableOfObject {
return elementSize;
}
public String toString() {
- String s= ""; //$NON-NLS-1$
+ String s= ""/*nonNLS*/;
Object object;
for (int i= 0, length= valueTable.length; i < length; i++)
if ((object= valueTable[i]) != null)
- s += new String(keyTable[i]) + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ s += new String(keyTable[i]) + " -> "/*nonNLS*/ + object.toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
index c6fb8149ae..33b33d4081 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
@@ -75,7 +75,7 @@ public class IFileDocument extends PropertyDocument {
public String getType() {
String extension= file.getFileExtension();
if (extension == null)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
return extension;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
index fdd136de7a..a1a1ce0e53 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
@@ -12,7 +12,7 @@ public interface IIndexConstants {
/**
* The signature of the index file.
*/
- public static final String SIGNATURE= "INDEX FILE 0.001"; //$NON-NLS-1$
+ public static final String SIGNATURE= "INDEX FILE 0.001"/*nonNLS*/;
/**
* The signature of the index file.
*/
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
index 324ad5bd14..f989c1f96a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
@@ -53,7 +53,7 @@ public class Index implements IIndex {
*/
private String toString;
public Index(File indexDirectory) throws IOException {
- this(indexDirectory,".index"); //$NON-NLS-1$
+ this(indexDirectory,".index"/*nonNLS*/);
}
public Index(File indexDirectory, String indexName) throws IOException {
super();
@@ -215,7 +215,7 @@ public class Index implements IIndex {
//System.out.println("merge");
//initialisation of tempIndex
- File tempFile= new File(indexFile.getAbsolutePath() + "TempVA"); //$NON-NLS-1$
+ File tempFile= new File(indexFile.getAbsolutePath() + "TempVA"/*nonNLS*/);
boolean exists= indexFile.exists();
IndexInput mainIndexInput= new BlocksIndexInput(indexFile);
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
index d515907237..b5cf187257 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
@@ -45,7 +45,7 @@ public class IndexSummary {
char[] word;
int blockNum;
public String toString(){
- return "FirstWordInBlock: " + new String(word) + ", blockNum: " + blockNum; //$NON-NLS-1$ //$NON-NLS-2$
+ return "FirstWordInBlock: "/*nonNLS*/ + new String(word) + ", blockNum: "/*nonNLS*/ + blockNum;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
index 5eb12708d2..d115c7d659 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
@@ -20,10 +20,10 @@ import org.eclipse.jdt.internal.core.index.*;
public class IndexedFile implements IQueryResult {
protected String path;
protected int fileNumber;
- protected static final String INFO_BEGIN= "("; //$NON-NLS-1$
- protected static final String INFO_END= ")"; //$NON-NLS-1$
- protected static final String INFO_SEPARATOR= ","; //$NON-NLS-1$
- protected static final String INFO_VALUE_SEPARATOR= ":"; //$NON-NLS-1$
+ protected static final String INFO_BEGIN= "("/*nonNLS*/;
+ protected static final String INFO_END= ")"/*nonNLS*/;
+ protected static final String INFO_SEPARATOR= ","/*nonNLS*/;
+ protected static final String INFO_VALUE_SEPARATOR= ":"/*nonNLS*/;
protected static final int MAX_PROPERTIES_SIZE= 2 * 1024;
protected Hashtable properties;
protected int propertiesSize= 2 * (INFO_BEGIN.length() + INFO_END.length());
@@ -131,7 +131,7 @@ public class IndexedFile implements IQueryResult {
}
public String propertiesToString() {
if (properties.isEmpty())
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
StringBuffer prop= new StringBuffer(INFO_BEGIN);
for (Enumeration e= getPropertyNames(); e.hasMoreElements();) {
String property= (String) e.nextElement();
@@ -160,6 +160,6 @@ public class IndexedFile implements IQueryResult {
properties.put(propertyName, value);
}
public String toString() {
- return "IndexedFile(" + fileNumber + ": " + path + ")"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
+ return "IndexedFile("/*nonNLS*/ + fileNumber + ": "/*nonNLS*/ + path + ")"/*nonNLS*/;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
index 37b8e1c57e..bae4d88d5d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
@@ -56,7 +56,7 @@ public String getStringContent() throws java.io.IOException {
public String getType() {
String extension= file.getFileExtension();
if (extension == null)
- return ""; //$NON-NLS-1$
+ return ""/*nonNLS*/;
return extension;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
index 1c277dea2d..db9f920441 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
@@ -19,7 +19,7 @@ public class JarFileEntryDocument extends PropertyDocument {
protected ZipEntry zipEntry;
protected byte[] byteContents;
protected Path zipFilePath;
- public static final String JAR_FILE_ENTRY_SEPARATOR = "|"; //$NON-NLS-1$
+ public static final String JAR_FILE_ENTRY_SEPARATOR = "|"/*nonNLS*/;
/**
* JarFileEntryDocument constructor comment.
*/
@@ -59,7 +59,7 @@ public String getStringContent() throws java.io.IOException {
* @see IDocument#getType
*/
public String getType() {
- return "class"; //$NON-NLS-1$
+ return "class"/*nonNLS*/;
}
public void setBytes(byte[] byteContents) {
this.byteContents = byteContents;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
index 8a6272abd2..7ca6386ab0 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
@@ -86,7 +86,7 @@ public class LRUCache implements Cloneable {
*/
public String toString() {
- return "LRUCacheEntry [" + _fKey + "-->" + _fValue + "]"; //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-2$
+ return "LRUCacheEntry ["/*nonNLS*/ + _fKey + "-->"/*nonNLS*/ + _fValue + "]"/*nonNLS*/;
}
}
@@ -451,7 +451,7 @@ public class LRUCache implements Cloneable {
*/
public String toString() {
- return "LRUCache " + (getCurrentSpace() * 100.0 / getSpaceLimit()) + "% full"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "LRUCache "/*nonNLS*/ + (getCurrentSpace() * 100.0 / getSpaceLimit()) + "% full"/*nonNLS*/;
}
/**
* Updates the timestamp for the given entry, ensuring that the queue is
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ObjectVector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ObjectVector.java
index f385a5b2b8..a65cd3b6bd 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ObjectVector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ObjectVector.java
@@ -61,9 +61,9 @@ public final class ObjectVector {
size= 0;
}
public String toString() {
- String s= ""; //$NON-NLS-1$
+ String s= ""/*nonNLS*/;
for (int i= 0; i < size; i++)
- s += elements[i].toString() + "\n"; //$NON-NLS-1$
+ s += elements[i].toString() + "\n"/*nonNLS*/;
return s;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
index af6828cd7e..6e468c8852 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
@@ -67,7 +67,7 @@ private void buildResourceVector() throws JavaModelException {
zipFileName +
JAR_FILE_ENTRY_SEPARATOR +
type.getFullyQualifiedName().replace('.', '/') +
- ".class"; //$NON-NLS-1$
+ ".class"/*nonNLS*/;
this.resourcePaths.put(resourcePath, resourcePath);
paths.put(jar.getPath(), type);
} else {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
index d2fba1320b..5d3a2a46be 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
@@ -74,7 +74,7 @@ public boolean execute() {
isComplete &= search(searchIndexes[i]);
}
if (JobManager.VERBOSE){
- System.out.println("-> execution time: " + executionTime + " ms. for : "+this); //$NON-NLS-2$ //$NON-NLS-1$
+ System.out.println("-> execution time: "/*nonNLS*/ + executionTime + " ms. for : "/*nonNLS*/+this);
}
return isComplete;
}
@@ -96,7 +96,7 @@ public boolean search(IIndex index) {
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE) System.out.println("-> merging index : "+index.getIndexFile()); //$NON-NLS-1$
+ if (IndexManager.VERBOSE) System.out.println("-> merging index : "/*nonNLS*/+index.getIndexFile());
index.save();
} catch(IOException e){
return FAILED;
@@ -116,6 +116,6 @@ public boolean search(IIndex index) {
}
}
public String toString(){
- return "searching " + pattern.toString(); //$NON-NLS-1$
+ return "searching "/*nonNLS*/ + pattern.toString();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
index 6894d48197..a24d5c697e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
@@ -56,7 +56,7 @@ public boolean search(IIndex index) {
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE) System.out.println("-> merging index : "+index.getIndexFile()); //$NON-NLS-1$
+ if (IndexManager.VERBOSE) System.out.println("-> merging index : "/*nonNLS*/+index.getIndexFile());
index.save();
} catch(IOException e){
return FAILED;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
index 86ae5dbec7..b0f6cb0e20 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
@@ -10,7 +10,7 @@ import java.util.ResourceBundle;
public class Util {
/* Bundle containing messages */
protected static ResourceBundle bundle;
- private final static String bundleName = "org.eclipse.jdt.internal.core.search.Messages"; //$NON-NLS-1$
+ private final static String bundleName = "org.eclipse.jdt.internal.core.search.Messages"/*nonNLS*/;
static {
relocalize();
}
@@ -34,14 +34,14 @@ public static String bind(String id, String binding) {
*/
public static String bind(String id, String[] bindings) {
if (id == null)
- return "No message available"; //$NON-NLS-1$
+ return "No message available"/*nonNLS*/;
String message = null;
try {
message = bundle.getString(id);
} catch (MissingResourceException e) {
// If we got an exception looking for the message, fail gracefully by just returning
// the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
+ return "Missing message: "/*nonNLS*/ + id + " in: "/*nonNLS*/ + bundleName;
}
if (bindings == null)
return message;
@@ -60,7 +60,7 @@ public static String bind(String id, String[] bindings) {
} catch (NumberFormatException nfe) {
output.append(message.substring(end + 1, start + 1));
} catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
+ output.append("{missing "/*nonNLS*/ + Integer.toString(index) + "}"/*nonNLS*/);
}
} else {
output.append(message.substring(end, length));
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
index ee59e69d72..3f6d3ed475 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
@@ -68,6 +68,6 @@ public void initializeContents() {
}
}
public String toString(){
- return "indexing " + resource.getName(); //$NON-NLS-1$
+ return "indexing "/*nonNLS*/ + resource.getName();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
index 9b3968e1be..5b1bd84a7b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
@@ -69,6 +69,6 @@ public void initializeContents() {
}
}
public String toString(){
- return "indexing " + resource.getName(); //$NON-NLS-1$
+ return "indexing "/*nonNLS*/ + resource.getName();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
index 009feebee0..bc57a19ed6 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
@@ -73,11 +73,11 @@ public boolean execute() {
}
if (JobManager.VERBOSE)
- System.out.println("INDEX : " + zip.getName()); //$NON-NLS-1$
+ System.out.println("INDEX : "/*nonNLS*/ + zip.getName());
long initialTime = System.currentTimeMillis();
final Hashtable indexedFileNames = new Hashtable(100);
- IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$
+ IQueryResult[] results = index.queryInDocumentNames(""/*nonNLS*/); // all file names
int resultLength = results == null ? 0 : results.length;
if (resultLength != 0) {
/* check integrity of the existing index file
@@ -135,11 +135,11 @@ public boolean execute() {
}
if (JobManager.VERBOSE)
System.out.println(
- "INDEX : " //$NON-NLS-1$
+ "INDEX : "/*nonNLS*/
+ zip.getName()
- + " COMPLETE in " //$NON-NLS-1$
+ + " COMPLETE in "/*nonNLS*/
+ (System.currentTimeMillis() - initialTime)
- + " ms"); //$NON-NLS-1$
+ + " ms"/*nonNLS*/);
} finally {
if (zip != null)
zip.close();
@@ -160,12 +160,12 @@ public String toString() {
if (resource != null) {
IPath location = resource.getLocation();
if (location == null){
- toString = "indexing "; //$NON-NLS-1$
+ toString = "indexing "/*nonNLS*/;
} else {
- toString = "indexing " + location.toFile().toString(); //$NON-NLS-1$
+ toString = "indexing "/*nonNLS*/ + location.toFile().toString();
}
} else {
- toString = "indexing " + this.path.toFile().toString(); //$NON-NLS-1$
+ toString = "indexing "/*nonNLS*/ + this.path.toFile().toString();
}
}
return toString;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
index 6f52cfd4f0..e9756c4f2e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
@@ -13,16 +13,16 @@ import java.util.*;
import java.util.zip.*;
public class BinaryIndexer extends AbstractIndexer {
- public static final String[] FILE_TYPES= new String[] {"class"}; //$NON-NLS-1$
- private static final char[] BYTE = "byte".toCharArray(); //$NON-NLS-1$
- private static final char[] CHAR = "char".toCharArray(); //$NON-NLS-1$
- private static final char[] DOUBLE = "double".toCharArray(); //$NON-NLS-1$
- private static final char[] FLOAT = "float".toCharArray(); //$NON-NLS-1$
- private static final char[] INT = "int".toCharArray(); //$NON-NLS-1$
- private static final char[] LONG = "long".toCharArray(); //$NON-NLS-1$
- private static final char[] SHORT = "short".toCharArray(); //$NON-NLS-1$
- private static final char[] BOOLEAN = "boolean".toCharArray(); //$NON-NLS-1$
- private static final char[] VOID = "void".toCharArray(); //$NON-NLS-1$
+ public static final String[] FILE_TYPES= new String[] {"class"/*nonNLS*/};
+ private static final char[] BYTE = "byte"/*nonNLS*/.toCharArray();
+ private static final char[] CHAR = "char"/*nonNLS*/.toCharArray();
+ private static final char[] DOUBLE = "double"/*nonNLS*/.toCharArray();
+ private static final char[] FLOAT = "float"/*nonNLS*/.toCharArray();
+ private static final char[] INT = "int"/*nonNLS*/.toCharArray();
+ private static final char[] LONG = "long"/*nonNLS*/.toCharArray();
+ private static final char[] SHORT = "short"/*nonNLS*/.toCharArray();
+ private static final char[] BOOLEAN = "boolean"/*nonNLS*/.toCharArray();
+ private static final char[] VOID = "void"/*nonNLS*/.toCharArray();
private boolean needReferences;
@@ -359,8 +359,8 @@ private final char[] extractClassName(int[] constantPoolOffsets, ClassFileReader
return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}
private final char[] extractName(int[] constantPoolOffsets, ClassFileReader reader, int index) {
- int nameAndTypeIndex = reader.u2At(constantPoolOffsets[index] + 3);
- int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[nameAndTypeIndex] + 1)];
+ int constantPoolIndex = reader.u2At(constantPoolOffsets[index] + 3);
+ int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 1)];
return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}
/**
@@ -442,14 +442,14 @@ private void indexClassFile(byte[] contents, char[] documentName) throws IOExcep
char[][] superinterfaces = replace('/', '.', reader.getInterfaceNames());
if (DEBUG) {
if (packageName != null) {
- System.out.println("package name = " + new String(packageName)); //$NON-NLS-1$
+ System.out.println("package name = "/*nonNLS*/ + new String(packageName));
}
if (name != null) {
- System.out.println("class name = " + new String(name)); //$NON-NLS-1$
+ System.out.println("class name = "/*nonNLS*/ + new String(name));
}
if (superinterfaces != null) {
for (int i = 0, max = superinterfaces.length; i < max; i++) {
- System.out.println("superinterfaces[" + i + "]= " + new String(superinterfaces[i])); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("superinterfaces["/*nonNLS*/ + i + "]= "/*nonNLS*/ + new String(superinterfaces[i]));
}
}
}
@@ -460,7 +460,7 @@ private void indexClassFile(byte[] contents, char[] documentName) throws IOExcep
char[] superclass = replace('/', '.', reader.getSuperclassName());
if (DEBUG) {
if (superclass != null) {
- System.out.println("superclass name = " + new String(superclass)); //$NON-NLS-1$
+ System.out.println("superclass name = "/*nonNLS*/ + new String(superclass));
}
}
addClassDeclaration(reader.getModifiers(), packageName, name, enclosingTypeNames, superclass, superinterfaces);
@@ -477,19 +477,19 @@ private void indexClassFile(byte[] contents, char[] documentName) throws IOExcep
char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
if (DEBUG) {
if (method.getSelector() != null) {
- System.out.println("method selector = " + new String(method.getSelector())); //$NON-NLS-1$
+ System.out.println("method selector = "/*nonNLS*/ + new String(method.getSelector()));
}
if (parameterTypes != null) {
for (int j = 0, max2 = parameterTypes.length; j < max2; j++) {
- System.out.println("parameterTypes[" + j + "]= " + new String(parameterTypes[j])); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("parameterTypes["/*nonNLS*/ + j + "]= "/*nonNLS*/ + new String(parameterTypes[j]));
}
}
if (returnType != null) {
- System.out.println("return type = " + new String(returnType)); //$NON-NLS-1$
+ System.out.println("return type = "/*nonNLS*/ + new String(returnType));
}
if (exceptionTypes != null) {
for (int j = 0, max2 = exceptionTypes.length; j < max2; j++) {
- System.out.println("exceptionTypes[" + j + "]= " + new String(exceptionTypes[j])); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("exceptionTypes["/*nonNLS*/ + j + "]= "/*nonNLS*/ + new String(exceptionTypes[j]));
}
}
}
@@ -510,10 +510,10 @@ private void indexClassFile(byte[] contents, char[] documentName) throws IOExcep
char[] fieldType = decodeFieldType(replace('/', '.', field.getTypeName()));
if (DEBUG) {
if (fieldName != null) {
- System.out.println("field name = " + new String(fieldName)); //$NON-NLS-1$
+ System.out.println("field name = "/*nonNLS*/ + new String(fieldName));
}
if (fieldType != null) {
- System.out.println("field type = " + new String(fieldType)); //$NON-NLS-1$
+ System.out.println("field type = "/*nonNLS*/ + new String(fieldType));
}
}
addFieldDeclaration(fieldType, fieldName);
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
index b15a260b44..e74bdad95a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
@@ -9,20 +9,20 @@ import org.eclipse.jdt.internal.core.search.processing.*;
public interface IIndexConstants extends IJobConstants {
/* index encoding */
- char[] REF= "ref/".toCharArray(); //$NON-NLS-1$
- char[] FIELD_REF= "fieldRef/".toCharArray(); //$NON-NLS-1$
- char[] METHOD_REF= "methodRef/".toCharArray(); //$NON-NLS-1$
- char[] CONSTRUCTOR_REF= "constructorRef/".toCharArray(); //$NON-NLS-1$
- char[] TYPE_REF= "typeRef/".toCharArray(); //$NON-NLS-1$
- char[] SUPER_REF = "superRef/".toCharArray(); //$NON-NLS-1$
- char[] TYPE_DECL = "typeDecl/".toCharArray(); //$NON-NLS-1$
+ char[] REF= "ref/"/*nonNLS*/.toCharArray();
+ char[] FIELD_REF= "fieldRef/"/*nonNLS*/.toCharArray();
+ char[] METHOD_REF= "methodRef/"/*nonNLS*/.toCharArray();
+ char[] CONSTRUCTOR_REF= "constructorRef/"/*nonNLS*/.toCharArray();
+ char[] TYPE_REF= "typeRef/"/*nonNLS*/.toCharArray();
+ char[] SUPER_REF = "superRef/"/*nonNLS*/.toCharArray();
+ char[] TYPE_DECL = "typeDecl/"/*nonNLS*/.toCharArray();
int TYPE_DECL_LENGTH = 9;
- char[] CLASS_DECL= "typeDecl/C/".toCharArray(); //$NON-NLS-1$
- char[] INTERFACE_DECL= "typeDecl/I/".toCharArray(); //$NON-NLS-1$
- char[] METHOD_DECL= "methodDecl/".toCharArray(); //$NON-NLS-1$
- char[] CONSTRUCTOR_DECL= "constructorDecl/".toCharArray(); //$NON-NLS-1$
- char[] FIELD_DECL= "fieldDecl/".toCharArray(); //$NON-NLS-1$
- char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
+ char[] CLASS_DECL= "typeDecl/C/"/*nonNLS*/.toCharArray();
+ char[] INTERFACE_DECL= "typeDecl/I/"/*nonNLS*/.toCharArray();
+ char[] METHOD_DECL= "methodDecl/"/*nonNLS*/.toCharArray();
+ char[] CONSTRUCTOR_DECL= "constructorDecl/"/*nonNLS*/.toCharArray();
+ char[] FIELD_DECL= "fieldDecl/"/*nonNLS*/.toCharArray();
+ char[] OBJECT = "Object"/*nonNLS*/.toCharArray();
char[][] COUNTS=
new char[][] { new char[] {'0'}, new char[] {'1'}, new char[] {'2'}, new char[] {'3'}, new char[] {'4'}, new char[] {'5'}, new char[] {'6'}, new char[] {'7'}, new char[] {'8'}, new char[] {'9'}
};
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
index cb18b03330..b51827be20 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
@@ -45,7 +45,7 @@ public boolean execute(){
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE) System.out.println("-> merging index : "+index.getIndexFile()); //$NON-NLS-1$
+ if (IndexManager.VERBOSE) System.out.println("-> merging index : "/*nonNLS*/+index.getIndexFile());
index.save();
} catch(IOException e){
return FAILED;
@@ -54,12 +54,12 @@ public boolean execute(){
monitor.enterRead(); // reacquire read permission
}
}
- final String OK = "OK"; //$NON-NLS-1$
- final String DELETED = "DELETED"; //$NON-NLS-1$
+ final String OK = "OK"/*nonNLS*/;
+ final String DELETED = "DELETED"/*nonNLS*/;
final long indexLastModified = index.getIndexFile().lastModified();
final Hashtable indexedFileNames = new Hashtable(100);
- IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$
+ IQueryResult[] results = index.queryInDocumentNames(""/*nonNLS*/); // all file names
for (int i = 0, max = results == null ? 0 : results.length; i < max; i++){
String fileName = results[i].getPath();
indexedFileNames.put(fileName, DELETED);
@@ -68,7 +68,7 @@ public boolean execute(){
public boolean visit(IResource resource) {
if (resource.getType() == IResource.FILE) {
String extension = resource.getFileExtension();
- if ((extension != null) && extension.equalsIgnoreCase("java")) { //$NON-NLS-1$
+ if ((extension != null) && extension.equalsIgnoreCase("java"/*nonNLS*/)) {
IPath path = resource.getLocation();
if (path != null){
File resourceFile = path.toFile();
@@ -108,6 +108,6 @@ public boolean execute(){
return COMPLETE;
}
public String toString(){
- return "indexing project " + project.getName(); //$NON-NLS-1$
+ return "indexing project "/*nonNLS*/ + project.getName();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
index 6c95ded28c..c56c43195a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
@@ -57,13 +57,13 @@ public void activateProcessing() {
public void add(IFile resource){
if (JavaCore.getPlugin() == null || this.workspace == null) return;
String extension = resource.getFileExtension();
- if ("java".equals(extension)){ //$NON-NLS-1$
+ if ("java"/*nonNLS*/.equals(extension)){
AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, this);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
job.initializeContents();
}
request(job);
- } else if ("class".equals(extension)){ //$NON-NLS-1$
+ } else if ("class"/*nonNLS*/.equals(extension)){
AddClassFileToIndex job = new AddClassFileToIndex(resource, this);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
job.initializeContents();
@@ -77,7 +77,7 @@ public void add(IFile resource){
*/
public void checkIndexConsistency() {
- if (VERBOSE) System.out.println("STARTING - ensuring consistency"); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("STARTING - ensuring consistency"/*nonNLS*/);
boolean wasEnabled = isEnabled();
try {
@@ -94,15 +94,15 @@ public void checkIndexConsistency() {
}
} finally {
if (wasEnabled) enable();
- if (VERBOSE) System.out.println("DONE - ensuring consistency"); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("DONE - ensuring consistency"/*nonNLS*/);
}
}
private String computeIndexName(String pathString) {
byte[] pathBytes = pathString.getBytes();
checksumCalculator.reset();
checksumCalculator.update(pathBytes);
- String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
- if (VERBOSE) System.out.println(" index name: " + pathString + " <----> " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
+ String fileName = Long.toString(checksumCalculator.getValue()) + ".index"/*nonNLS*/;
+ if (VERBOSE) System.out.println(" index name: "/*nonNLS*/ + pathString + " <----> "/*nonNLS*/ + fileName);
IPath indexPath = getJavaPluginWorkingLocation();
String indexDirectory = indexPath.toOSString();
if (indexDirectory.endsWith(File.separator)) {
@@ -183,7 +183,7 @@ public synchronized IIndex getIndex(IPath path, boolean mustCreate) {
if (index == null) {
// New index: add same index for given path and canonical path
String indexPath = computeIndexName(canonicalPath.toOSString());
- index = IndexFactory.newIndex(indexPath, "Index for " + canonicalPath.toOSString()); //$NON-NLS-1$
+ index = IndexFactory.newIndex(indexPath, "Index for "/*nonNLS*/ + canonicalPath.toOSString());
indexes.put(canonicalPath, index);
indexes.put(path, index);
monitors.put(index, new ReadWriteMonitor());
@@ -257,7 +257,7 @@ protected void notifyIdle(long idlingTime){
* Name of the background process
*/
public String processName(){
- return Util.bind("process.name", IndexManager.class.getName()); //$NON-NLS-1$
+ return Util.bind("process.name"/*nonNLS*/, IndexManager.class.getName());
}
/**
* Recreates the index for a given path, keeping the same read-write monitor.
@@ -273,7 +273,7 @@ public synchronized IIndex recreateIndex(IPath path) {
// Add same index for given path and canonical path
String indexPath = computeIndexName(canonicalPath.toOSString());
ReadWriteMonitor monitor = (ReadWriteMonitor)monitors.remove(index);
- index = IndexFactory.newIndex(indexPath, "Index for " + canonicalPath.toOSString()); //$NON-NLS-1$
+ index = IndexFactory.newIndex(indexPath, "Index for "/*nonNLS*/ + canonicalPath.toOSString());
index.empty();
indexes.put(canonicalPath, index);
indexes.put(path, index);
@@ -318,7 +318,7 @@ public void saveIndexes(){
if (monitor == null) continue; // index got deleted since acquired
try {
monitor.enterWrite();
- if (IndexManager.VERBOSE) System.out.println("-> merging index : "+index.getIndexFile()); //$NON-NLS-1$
+ if (IndexManager.VERBOSE) System.out.println("-> merging index : "/*nonNLS*/+index.getIndexFile());
index.save();
} finally {
monitor.exitWrite();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
index 032b16524d..a03484a96b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
@@ -48,6 +48,6 @@ public boolean execute(){
return COMPLETE;
}
public String toString(){
- return "removing from index " + resourceName; //$NON-NLS-1$
+ return "removing from index "/*nonNLS*/ + resourceName;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
index f2b3553f49..62853a978e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
@@ -31,7 +31,7 @@ import java.util.*;
*/
public class SourceIndexer extends AbstractIndexer {
- public static final String[] FILE_TYPES= new String[] {"java"}; //$NON-NLS-1$
+ public static final String[] FILE_TYPES= new String[] {"java"/*nonNLS*/};
protected DefaultProblemFactory problemFactory= new DefaultProblemFactory(Locale.getDefault());
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
index fc0b28a397..f00abd2826 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
@@ -60,6 +60,85 @@ public char[] indexEntryPrefix() {
isCaseSensitive);
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof ConstructorDeclaration)) return false;
+
+ ConstructorDeclaration constructor = (ConstructorDeclaration)node;
+
+ // constructor name is stored in selector field
+ if (this.declaringSimpleName != null
+ && !this.matchesName(this.declaringSimpleName, constructor.selector))
+ return false;
+
+ // declaring type
+ MethodBinding binding = constructor.binding;
+ if (resolve && binding != null) {
+ ReferenceBinding declaringBinding = binding.declaringClass;
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringBinding))
+ return false;
+ }
+
+ // argument types
+ int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
+ if (argumentCount > -1) {
+ int parameterCount = constructor.arguments == null ? 0 : constructor.arguments.length;
+ if (parameterCount != argumentCount)
+ return false;
+
+ if (resolve && binding != null) {
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, binding.parameters[i]))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof MethodBinding)) return false;
+
+ MethodBinding method = (MethodBinding)binding;
+
+ // must be a constructor
+ if (!method.isConstructor()) return false;
+
+ // declaring type
+ ReferenceBinding declaringType = method.declaringClass;
+ if (declaringType != null) {
+ if (!method.isStatic() && !method.isPrivate()) {
+ if (!this.matchesAsSubtype(declaringType, this.declaringSimpleName, this.declaringQualification))
+ return false;
+ } else {
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringType))
+ return false;
+ }
+ }
+
+ // parameter types
+ int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
+ if (parameterCount > -1) {
+ int argumentCount = method.parameters == null ? 0 : method.parameters.length;
+ if (parameterCount != argumentCount)
+ return false;
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, method.parameters[i]))
+ return false;
+ }
+ }
+
+ return true;
+}
+/**
* @see SearchPattern#matchesBinary(Object, Object)
*/
public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
@@ -130,116 +209,39 @@ protected boolean matchIndexEntry() {
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("ConstructorDeclarationPattern: "); //$NON-NLS-1$
+ buffer.append("ConstructorDeclarationPattern: "/*nonNLS*/);
if (declaringQualification != null) buffer.append(declaringQualification).append('.');
if (declaringSimpleName != null)
buffer.append(declaringSimpleName);
- else if (declaringQualification != null) buffer.append("*"); //$NON-NLS-1$
+ else if (declaringQualification != null) buffer.append("*"/*nonNLS*/);
buffer.append('(');
if (parameterSimpleNames == null) {
- buffer.append("..."); //$NON-NLS-1$
+ buffer.append("..."/*nonNLS*/);
} else {
for (int i = 0, max = parameterSimpleNames.length; i < max; i++){
- if (i > 0) buffer.append(", "); //$NON-NLS-1$
+ if (i > 0) buffer.append(", "/*nonNLS*/);
if (parameterQualifications[i] != null) buffer.append(parameterQualifications[i]).append('.');
if (parameterSimpleNames[i] == null) buffer.append('*'); else buffer.append(parameterSimpleNames[i]);
}
}
buffer.append(')');
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof ConstructorDeclaration)) return IMPOSSIBLE_MATCH;
-
- ConstructorDeclaration constructor = (ConstructorDeclaration)node;
-
- if (resolve) {
- return this.matchLevel(constructor.binding);
- } else {
- // constructor name is stored in selector field
- if (this.declaringSimpleName != null
- && !this.matchesName(this.declaringSimpleName, constructor.selector))
- return IMPOSSIBLE_MATCH;
-
- // parameter types
- int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (parameterCount > -1) {
- int argumentCount = constructor.arguments == null ? 0 : constructor.arguments.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
- }
-
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof MethodBinding)) return IMPOSSIBLE_MATCH;
- int level;
-
- MethodBinding constructor = (MethodBinding)binding;
-
- // must be a constructor
- if (!constructor.isConstructor()) return IMPOSSIBLE_MATCH;
-
- // declaring type
- ReferenceBinding declaringType = constructor.declaringClass;
- if (!constructor.isStatic() && !constructor.isPrivate()) {
- level = this.matchLevelAsSubtype(declaringType, this.declaringSimpleName, this.declaringQualification);
- } else {
- level = this.matchLevelForType(this.declaringSimpleName, this.declaringQualification, declaringType);
- }
- if (level == IMPOSSIBLE_MATCH) {
- return IMPOSSIBLE_MATCH;
- }
-
- // parameter types
- int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (parameterCount > -1) {
- int argumentCount = constructor.parameters == null ? 0 : constructor.parameters.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
- for (int i = 0; i < parameterCount; i++) {
- char[] qualification = this.parameterQualifications[i];
- char[] type = this.parameterSimpleNames[i];
- int newLevel = this.matchLevelForType(type, qualification, constructor.parameters[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
- }
- }
-
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
index adc2999cd4..ec874230d8 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
@@ -58,6 +58,90 @@ public char[] indexEntryPrefix() {
isCaseSensitive);
}
/**
+ * Returns whether this constructor pattern matches the given allocation expression.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(AllocationExpression allocation, boolean resolve) {
+
+ // constructor name is simple type name
+ char[][] typeName = allocation.type.getTypeName();
+ if (this.declaringSimpleName != null
+ && !this.matchesName(this.declaringSimpleName, typeName[typeName.length-1]))
+ return false;
+
+ // declaring type
+ MethodBinding binding = allocation.binding;
+ if (resolve && binding != null) {
+ ReferenceBinding declaringBinding = binding.declaringClass;
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringBinding))
+ return false;
+ }
+
+ // argument types
+ int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
+ if (argumentCount > -1) {
+ int parameterCount = allocation.arguments == null ? 0 : allocation.arguments.length;
+ if (parameterCount != argumentCount)
+ return false;
+
+ if (resolve && binding != null) {
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, binding.parameters[i]))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (node instanceof AllocationExpression) {
+ return this.matches((AllocationExpression)node, resolve);
+ } else if (node instanceof ExplicitConstructorCall) {
+ return this.matches((ExplicitConstructorCall)node, resolve);
+ }
+ return false;
+}
+/**
+ * Returns whether this constructor pattern matches the given explicit constructor call.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(ExplicitConstructorCall call, boolean resolve) {
+ // TBD: constructor name is super simple type name
+
+ // declaring type
+ MethodBinding binding = call.binding;
+ if (resolve && binding != null) {
+ ReferenceBinding declaringBinding = binding.declaringClass;
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringBinding))
+ return false;
+ }
+
+ // argument types
+ int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
+ if (argumentCount > -1) {
+ int parameterCount = call.arguments == null ? 0 : call.arguments.length;
+ if (parameterCount != argumentCount)
+ return false;
+
+ if (resolve && binding != null) {
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, binding.parameters[i]))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -89,141 +173,38 @@ protected boolean matchIndexEntry() {
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("ConstructorReferencePattern: "); //$NON-NLS-1$
+ buffer.append("ConstructorReferencePattern: "/*nonNLS*/);
if (declaringQualification != null) buffer.append(declaringQualification).append('.');
if (declaringSimpleName != null)
buffer.append(declaringSimpleName);
- else if (declaringQualification != null) buffer.append("*"); //$NON-NLS-1$
+ else if (declaringQualification != null) buffer.append("*"/*nonNLS*/);
buffer.append('(');
if (parameterSimpleNames == null) {
- buffer.append("..."); //$NON-NLS-1$
+ buffer.append("..."/*nonNLS*/);
} else {
for (int i = 0, max = parameterSimpleNames.length; i < max; i++){
- if (i > 0) buffer.append(", "); //$NON-NLS-1$
+ if (i > 0) buffer.append(", "/*nonNLS*/);
if (parameterQualifications[i] != null) buffer.append(parameterQualifications[i]).append('.');
if (parameterSimpleNames[i] == null) buffer.append('*'); else buffer.append(parameterSimpleNames[i]);
}
}
buffer.append(')');
- buffer.append(", "); //$NON-NLS-1$
+ buffer.append(", "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * Returns whether this constructor pattern matches the given allocation expression.
- * Look at resolved information only if specified.
- */
-private int matchLevel(AllocationExpression allocation, boolean resolve) {
-
- // constructor name is simple type name
- char[][] typeName = allocation.type.getTypeName();
- if (this.declaringSimpleName != null
- && !this.matchesName(this.declaringSimpleName, typeName[typeName.length-1]))
- return IMPOSSIBLE_MATCH;
-
- if (resolve) {
- return this.matchLevel(allocation.binding);
- } else {
- // argument types
- int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (argumentCount > -1) {
- int parameterCount = allocation.arguments == null ? 0 : allocation.arguments.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
- }
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (node instanceof AllocationExpression) {
- return this.matchLevel((AllocationExpression)node, resolve);
- } else if (node instanceof ExplicitConstructorCall) {
- return this.matchLevel((ExplicitConstructorCall)node, resolve);
- }
- return IMPOSSIBLE_MATCH;
-}
-
-/**
- * Returns whether this constructor pattern matches the given explicit constructor call.
- * Look at resolved information only if specified.
- */
-private int matchLevel(ExplicitConstructorCall call, boolean resolve) {
- // TBD: constructor name is super simple type name
-
- if (resolve) {
- return this.matchLevel(call.binding);
- } else {
- // argument types
- int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (argumentCount > -1) {
- int parameterCount = call.arguments == null ? 0 : call.arguments.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
- }
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding binding).
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof MethodBinding)) return IMPOSSIBLE_MATCH;
- int level;
-
- // declaring type
- MethodBinding method = (MethodBinding)binding;
- ReferenceBinding declaringBinding = method.declaringClass;
- level = this.matchLevelForType(this.declaringSimpleName, this.declaringQualification, declaringBinding);
- if (level == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH;
-
- // argument types
- int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (argumentCount > -1) {
- if (method.parameters == null) {
- level = INACCURATE_MATCH;
- } else {
- int parameterCount = method.parameters.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
-
- for (int i = 0; i < parameterCount; i++) {
- char[] qualification = this.parameterQualifications[i];
- char[] type = this.parameterSimpleNames[i];
- int newLevel = this.matchLevelForType(type, qualification, method.parameters[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
- }
- }
- }
-
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
index e16148ec26..4100d26244 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
@@ -85,6 +85,71 @@ protected int matchContainer() {
return CLASS;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof FieldDeclaration)) return false;
+
+ FieldDeclaration field = (FieldDeclaration)node;
+ if (!field.isField()) return false; // ignore field initializers
+
+ // field name
+ if (!this.matchesName(this.name, field.name))
+ return false;
+
+ // declaring type
+ FieldBinding binding = field.binding;
+ if (resolve && binding != null) {
+ ReferenceBinding declaringBinding = binding.declaringClass;
+ if (declaringBinding != null && !this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringBinding))
+ return false;
+ }
+
+ // field type
+ if (this.typeQualification == null) {
+ TypeReference fieldType = field.type;
+ char[][] fieldTypeName = fieldType.getTypeName();
+ char[] sourceName = this.toArrayName(
+ fieldTypeName[fieldTypeName.length-1],
+ fieldType.dimensions());
+ if (!this.matchesName(this.typeSimpleName, sourceName))
+ return false;
+ } else {
+ if (resolve
+ && binding != null
+ && !this.matchesType(this.typeSimpleName, this.typeQualification, binding.type))
+ return false;
+ }
+ return true;
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof FieldBinding)) return false;
+
+ FieldBinding field = (FieldBinding)binding;
+
+ // field name
+ if (!this.matchesName(this.name, field.readableName()))
+ return false;
+
+ // declaring type
+ ReferenceBinding declaringBinding = field.declaringClass;
+ if (declaringBinding != null
+ && !this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringBinding)) {
+
+ return false;
+ }
+
+ // field type
+ if(!this.matchesType(this.typeSimpleName, this.typeQualification, field.type)) {
+ return false;
+ }
+
+ return true;
+}
+/**
* @see SearchPattern#matchesBinary(Object, Object)
*/
public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
@@ -157,106 +222,38 @@ private boolean needsResolve() {
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("FieldDeclarationPattern: "); //$NON-NLS-1$
+ buffer.append("FieldDeclarationPattern: "/*nonNLS*/);
if (declaringQualification != null) buffer.append(declaringQualification).append('.');
if (declaringSimpleName != null)
buffer.append(declaringSimpleName).append('.');
- else if (declaringQualification != null) buffer.append("*."); //$NON-NLS-1$
+ else if (declaringQualification != null) buffer.append("*."/*nonNLS*/);
if (name == null) {
- buffer.append("*"); //$NON-NLS-1$
+ buffer.append("*"/*nonNLS*/);
} else {
buffer.append(name);
}
if (typeQualification != null)
- buffer.append(" --> ").append(typeQualification).append('.'); //$NON-NLS-1$
- else if (typeSimpleName != null) buffer.append(" --> "); //$NON-NLS-1$
+ buffer.append(" --> "/*nonNLS*/).append(typeQualification).append('.');
+ else if (typeSimpleName != null) buffer.append(" --> "/*nonNLS*/);
if (typeSimpleName != null)
buffer.append(typeSimpleName);
- else if (typeQualification != null) buffer.append("*"); //$NON-NLS-1$
- buffer.append(", "); //$NON-NLS-1$
+ else if (typeQualification != null) buffer.append("*"/*nonNLS*/);
+ buffer.append(", "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof FieldDeclaration)) return IMPOSSIBLE_MATCH;
-
- FieldDeclaration field = (FieldDeclaration)node;
-
- if (resolve) {
- return this.matchLevel(field.binding);
- } else {
- if (!field.isField()) return IMPOSSIBLE_MATCH; // ignore field initializers
-
- // field name
- if (!this.matchesName(this.name, field.name))
- return IMPOSSIBLE_MATCH;
-
- // field type
- TypeReference fieldType = field.type;
- char[][] fieldTypeName = fieldType.getTypeName();
- char[] sourceName = this.toArrayName(
- fieldTypeName[fieldTypeName.length-1],
- fieldType.dimensions());
- if (!this.matchesName(this.typeSimpleName, sourceName))
- return IMPOSSIBLE_MATCH;
-
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof FieldBinding)) return IMPOSSIBLE_MATCH;
- int level;
-
- FieldBinding field = (FieldBinding)binding;
-
- // field name
- if (!this.matchesName(this.name, field.readableName()))
- return IMPOSSIBLE_MATCH;
-
- // declaring type
- ReferenceBinding declaringBinding = field.declaringClass;
- if (declaringBinding == null ) {
- return INACCURATE_MATCH;
- } else {
- level = this.matchLevelForType(this.declaringSimpleName, this.declaringQualification, declaringBinding);
- if (level == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH;
- }
-
- // field type
- int newLevel = this.matchLevelForType(this.typeSimpleName, this.typeQualification, field.type);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
-
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
index 4995bd0d94..28b132bf51 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
@@ -112,6 +112,92 @@ protected int matchContainer() {
return METHOD | FIELD;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (node instanceof FieldReference) {
+ return this.matches((FieldReference)node, resolve);
+ } else if (node instanceof NameReference) {
+ return this.matches((NameReference)node, resolve);
+ }
+ return false;
+}
+/**
+ * Returns whether this field reference pattern matches the given field reference.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(FieldReference fieldRef, boolean resolve) {
+ // field name
+ if (!this.matchesName(this.name, fieldRef.token))
+ return false;
+
+ if (resolve) {
+ // receiver type and field type
+ FieldBinding binding = fieldRef.binding;
+ if (binding != null && !this.matches(fieldRef.receiverType, fieldRef.isSuperAccess(), binding))
+ return false;
+ }
+
+ return true;
+}
+/**
+ * Returns whether this field reference pattern matches the given name reference.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(NameReference nameRef, boolean resolve) {
+ // field name
+ boolean nameMatch = true;
+ if (this.name != null) {
+ if (nameRef instanceof SingleNameReference) {
+ nameMatch = matchesName(this.name, ((SingleNameReference)nameRef).token);
+ } else { // QualifiedNameReference
+ nameMatch = false;
+ QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
+ char[][] tokens = qNameRef.tokens;
+ for (int i = qNameRef.indexOfFirstFieldBinding-1, max = tokens.length; i < max && !nameMatch; i++){
+ if (i >= 0) nameMatch = matchesName(this.name, tokens[i]);
+ }
+ }
+ }
+ if (!nameMatch) return false;
+
+ if (resolve){
+ Binding binding = nameRef.binding;
+ if (binding != null){
+ if (nameRef instanceof SingleNameReference){
+ if (binding instanceof FieldBinding){
+ if (!this.matches(nameRef.receiverType, false, (FieldBinding) binding)){
+ return false;
+ }
+ } else {
+ return false; // must be a field binding
+ }
+ } else { // QualifiedNameReference
+ QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
+ TypeBinding receiverType = qNameRef.receiverType;
+ FieldBinding fieldBinding = null;
+ if (!(binding instanceof FieldBinding
+ && matchesName(this.name, (fieldBinding = (FieldBinding)binding).name)
+ && matches(receiverType, false, fieldBinding))){
+ if (binding instanceof VariableBinding){
+ receiverType = ((VariableBinding) binding).type;
+ }
+ boolean otherMatch = false;
+ int otherMax = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
+ for (int i = 0; i < otherMax && !otherMatch; i++){
+ FieldBinding otherBinding = qNameRef.otherBindings[i];
+ if (otherBinding == null) break;
+ otherMatch = matchesName(this.name, otherBinding.name) && matches(receiverType, false, otherBinding);
+ receiverType = otherBinding.type;
+ }
+ if (!otherMatch) return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -138,6 +224,25 @@ protected boolean matchIndexEntry() {
return true;
}
/**
+ * Finds out whether the given ast node matches this search pattern.
+ * Returns IMPOSSIBLE_MATCH if it doesn't.
+ * Returns TRUSTED_MATCH if it matches exactly this search pattern (ie.
+ * it doesn't need to be resolved or it has already been resolved.)
+ * Returns POSSIBLE_MATCH if it potentially matches
+ * this search pattern and it needs to be resolved to get more information.
+ */
+public int matchLevel(AstNode node) {
+ if (this.matches(node, false)) {
+ if (this.needsResolve
+ || node instanceof NameReference) { // ensure it is a field
+ return POSSIBLE_MATCH;
+ } else {
+ return TRUSTED_MATCH;
+ }
+ }
+ return IMPOSSIBLE_MATCH;
+}
+/**
* @see SearchPattern#matchReportReference
*/
protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
@@ -167,38 +272,38 @@ protected void resetQuery() {
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("FieldReferencePattern: "); //$NON-NLS-1$
+ buffer.append("FieldReferencePattern: "/*nonNLS*/);
if (declaringQualification != null) buffer.append(declaringQualification).append('.');
if (declaringSimpleName != null)
buffer.append(declaringSimpleName).append('.');
- else if (declaringQualification != null) buffer.append("*."); //$NON-NLS-1$
+ else if (declaringQualification != null) buffer.append("*."/*nonNLS*/);
if (name != null) {
buffer.append(name);
} else {
- buffer.append("*"); //$NON-NLS-1$
+ buffer.append("*"/*nonNLS*/);
}
if (typeQualification != null)
- buffer.append(" --> ").append(typeQualification).append('.'); //$NON-NLS-1$
- else if (typeSimpleName != null) buffer.append(" --> "); //$NON-NLS-1$
+ buffer.append(" --> "/*nonNLS*/).append(typeQualification).append('.');
+ else if (typeSimpleName != null) buffer.append(" --> "/*nonNLS*/);
if (typeSimpleName != null)
buffer.append(typeSimpleName);
- else if (typeQualification != null) buffer.append("*"); //$NON-NLS-1$
- buffer.append(", "); //$NON-NLS-1$
+ else if (typeQualification != null) buffer.append("*"/*nonNLS*/);
+ buffer.append(", "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
@@ -208,130 +313,24 @@ public boolean initializeFromLookupEnvironment(LookupEnvironment env) {
}
/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (node instanceof FieldReference) {
- return this.matchLevel((FieldReference)node, resolve);
- } else if (node instanceof NameReference) {
- return this.matchLevel((NameReference)node, resolve);
- }
- return IMPOSSIBLE_MATCH;
-}
-
-/**
- * Returns whether this field reference pattern matches the given field reference.
- * Look at resolved information only if specified.
- */
-private int matchLevel(FieldReference fieldRef, boolean resolve) {
- // field name
- if (!this.matchesName(this.name, fieldRef.token))
- return IMPOSSIBLE_MATCH;
-
- if (resolve) {
- // receiver type and field type
- return this.matchLevel(fieldRef.receiverType, fieldRef.isSuperAccess(), fieldRef.binding);
- } else {
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * Returns whether this field reference pattern matches the given name reference.
- * Look at resolved information only if specified.
- */
-private int matchLevel(NameReference nameRef, boolean resolve) {
- // field name
- boolean nameMatch = true;
- if (this.name != null) {
- if (nameRef instanceof SingleNameReference) {
- nameMatch = this.matchesName(this.name, ((SingleNameReference)nameRef).token);
- } else { // QualifiedNameReference
- nameMatch = false;
- QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
- char[][] tokens = qNameRef.tokens;
- for (int i = qNameRef.indexOfFirstFieldBinding-1, max = tokens.length; i < max && !nameMatch; i++){
- if (i >= 0) nameMatch = this.matchesName(this.name, tokens[i]);
- }
- }
- }
- if (!nameMatch) return IMPOSSIBLE_MATCH;
-
- if (resolve) {
- Binding binding = nameRef.binding;
- if (binding == null) {
- return INACCURATE_MATCH;
- } else {
- if (nameRef instanceof SingleNameReference){
- if (binding instanceof FieldBinding){
- return this.matchLevel(nameRef.receiverType, false, (FieldBinding) binding);
- } else {
- return IMPOSSIBLE_MATCH; // must be a field binding
- }
- } else { // QualifiedNameReference
- QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
- TypeBinding receiverType = qNameRef.receiverType;
- FieldBinding fieldBinding = null;
- if (binding instanceof FieldBinding && this.matchesName(this.name, (fieldBinding = (FieldBinding)binding).name)) {
- return this.matchLevel(receiverType, false, fieldBinding);
- } else {
- if (binding instanceof VariableBinding){
- receiverType = ((VariableBinding) binding).type;
- }
- int otherLevel = IMPOSSIBLE_MATCH;
- int otherMax = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
- for (int i = 0; i < otherMax && (otherLevel == IMPOSSIBLE_MATCH); i++){
- FieldBinding otherBinding = qNameRef.otherBindings[i];
- if (this.matchesName(this.name, otherBinding.name)) {
- otherLevel = this.matchLevel(receiverType, false, otherBinding);
- }
- receiverType = otherBinding.type;
- }
- return otherLevel;
- }
- }
- }
- } else {
- return POSSIBLE_MATCH;
- }
-}
-
-/**
* Returns whether this field reference pattern matches the given field binding and receiver type.
*/
-private int matchLevel(TypeBinding receiverType, boolean isSuperAccess, FieldBinding binding) {
- if (receiverType == null || binding == null) return INACCURATE_MATCH;
- int level;
-
+private boolean matches(TypeBinding receiverType, boolean isSuperAccess, FieldBinding binding) {
// receiver type
ReferenceBinding receiverBinding =
isSuperAccess || binding.isStatic() ?
binding.declaringClass :
(ReferenceBinding)receiverType;
- if (receiverBinding == null) {
- return INACCURATE_MATCH;
- } else {
- level = this.matchLevelAsSubtype(receiverBinding, this.declaringSimpleName, this.declaringQualification);
- if (level == IMPOSSIBLE_MATCH) {
- level = this.matchLevelForType(this.allSuperDeclaringTypeNames, receiverBinding);
- if (level == IMPOSSIBLE_MATCH) {
- return IMPOSSIBLE_MATCH;
- }
- }
+ if (receiverBinding != null
+ && !this.matchesAsSubtype(receiverBinding, this.declaringSimpleName, this.declaringQualification)
+ && !this.matchesType(this.allSuperDeclaringTypeNames, receiverBinding)) {
+ return false;
}
// field type
- int newLevel = this.matchLevelForType(this.typeSimpleName, this.typeQualification, binding.type);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
+ if (!this.matchesType(this.typeSimpleName, this.typeQualification, binding.type))
+ return false;
- return level;
+ return true;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index 33270d590c..892bcace58 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -41,7 +41,6 @@ import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
/**
* Locate matches in compilation units.
@@ -52,709 +51,727 @@ public class MatchLocator implements ITypeRequestor {
public IJavaSearchResultCollector collector;
public IJavaSearchScope scope;
- public MatchLocatorParser parser;
- public LookupEnvironment lookupEnvironment;
- public HashtableOfObject parsedUnits;
- private PotentialMatch[] potentialMatches;
- private int potentialMatchesIndex;
- private int potentialMatchesLength;
-
- public MatchLocator(
- SearchPattern pattern,
- int detailLevel,
- IJavaSearchResultCollector collector,
- IJavaSearchScope scope) {
-
- this.pattern = pattern;
- this.detailLevel = detailLevel;
- this.collector = collector;
- this.scope = scope;
- }
-
- /**
- * Add an additional binary type
- */
- public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
- this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
- }
-
- /**
- * Add an additional compilation unit.
- */
- public void accept(ICompilationUnit sourceUnit) {
- CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
- CompilationUnitDeclaration parsedUnit =
- this.parser.dietParse(sourceUnit, result);
+ private MatchLocatorParser parser;
+ private LookupEnvironment lookupEnvironment;
+ private IResource currentResource;
+ private Openable currentOpenable;
+public MatchLocator(
+ SearchPattern pattern,
+ int detailLevel,
+ IJavaSearchResultCollector collector,
+ IJavaSearchScope scope) {
+
+ this.pattern = pattern;
+ this.detailLevel = detailLevel;
+ this.collector = collector;
+ this.scope = scope;
+}
+/**
+ * Add an additional binary type
+ */
+public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
+ this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
+}
+/**
+ * Add an additional compilation unit.
+ */
+public void accept(ICompilationUnit sourceUnit) {
+ CompilationResult result = new CompilationResult(sourceUnit, 1, 1);
+ CompilationUnitDeclaration parsedUnit = this.parser.dietParse(sourceUnit, result);
- this.lookupEnvironment.buildTypeBindings(parsedUnit);
- this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
+ this.lookupEnvironment.buildTypeBindings(parsedUnit);
+ this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
+}
+/**
+ * Add an additional source type
+ */
+public void accept(ISourceType sourceType, PackageBinding packageBinding) {
+ while (sourceType.getEnclosingType() != null) sourceType = sourceType.getEnclosingType();
+ CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1); // need to hold onto this
+ CompilationUnitDeclaration unit =
+ SourceTypeConverter.buildCompilationUnit(sourceType, true, true, lookupEnvironment.problemReporter, result);
+
+ if (unit != null) {
+ this.lookupEnvironment.buildTypeBindings(unit);
+ this.lookupEnvironment.completeTypeBindings(unit, true);
}
-
- /**
- * Add an additional source type
- */
- public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
- ISourceType sourceType = sourceTypes[0];
- while (sourceType.getEnclosingType() != null)
- sourceType = sourceType.getEnclosingType();
- CompilationUnitDeclaration unit;
- if (sourceType instanceof SourceTypeElementInfo) {
- // get source
- SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
- IType type = elementInfo.getHandle();
- try {
- final IFile file = (IFile) type.getUnderlyingResource();
- final char[] source = PotentialMatch.getContents(file);
-
- // get main type name
- final String fileName = file.getFullPath().lastSegment();
- final char[] mainTypeName =
- fileName.substring(0, fileName.length() - 5).toCharArray();
-
- // source unit
- ICompilationUnit sourceUnit = new ICompilationUnit() {
- public char[] getContents() {
- return source;
- }
- public char[] getFileName() {
- return fileName.toCharArray();
- }
- public char[] getMainTypeName() {
- return mainTypeName;
- }
- };
-
- // diet parse
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0);
- unit = this.parser.dietParse(sourceUnit, compilationResult);
- } catch (JavaModelException e) {
- unit = null;
+}
+/**
+ * Creates an IField from the given field declaration and simple type names.
+ */
+private IField createFieldHandle(FieldDeclaration field, char[][] definingTypeNames) {
+ IType type = this.createTypeHandle(definingTypeNames);
+ return type.getField(new String(field.name));
+}
+/**
+ * Creates an IImportDeclaration from the given import statement
+ */
+private IImportDeclaration createImportHandle(ImportReference importRef) {
+ char[] importName = CharOperation.concatWith(importRef.getImportName(), '.');
+ if (importRef.onDemand) {
+ importName = CharOperation.concat(importName, ".*"/*nonNLS*/.toCharArray());
+ }
+ return ((CompilationUnit)this.currentOpenable).getImport(
+ new String(importName));
+}
+/**
+ * Creates an IInitializer from the given field declaration and simple type names.
+ */
+private IInitializer createInitializerHandle(TypeDeclaration typeDecl, FieldDeclaration initializer, char[][] definingTypeNames) {
+ IType type = this.createTypeHandle(definingTypeNames);
+
+ // find occurence count of the given initializer in its type declaration
+ int occurrenceCount = 0;
+ FieldDeclaration[] fields = typeDecl.fields;
+ for (int i = 0, length = fields.length; i < length; i++) {
+ FieldDeclaration field = fields[i];
+ if (!field.isField()) {
+ occurrenceCount++;
+ if (field.equals(initializer)) {
+ break;
}
- } else {
- CompilationResult result =
- new CompilationResult(sourceType.getFileName(), 0, 0);
- unit =
- SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
- lookupEnvironment.problemReporter,
- result);
}
-
- if (unit != null) {
- this.lookupEnvironment.buildTypeBindings(unit);
- this.lookupEnvironment.completeTypeBindings(unit, true);
- this.parsedUnits.put(sourceType.getQualifiedName(), unit);
+ }
+
+ return type.getInitializer(occurrenceCount);
+}
+/**
+ * Creates an IMethod from the given method declaration and simple type names.
+ */
+private IMethod createMethodHandle(AbstractMethodDeclaration method, char[][] definingTypeNames) {
+ IType type = this.createTypeHandle(definingTypeNames);
+ Argument[] arguments = method.arguments;
+ int length = arguments == null ? 0 : arguments.length;
+ String[] parameterTypeSignatures = new String[length];
+ for (int i = 0; i < length; i++) {
+ TypeReference parameterType = arguments[i].type;
+ char[] typeName = CharOperation.concatWith(parameterType.getTypeName(), '.');
+ for (int j = 0; j < parameterType.dimensions(); j++) {
+ typeName = CharOperation.concat(typeName, "[]"/*nonNLS*/.toCharArray());
}
+ parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
}
-
- /**
- * Creates an IField from the given field declaration and simple type names.
- */
- private IField createFieldHandle(
- FieldDeclaration field,
- char[][] definingTypeNames) {
- IType type = this.createTypeHandle(definingTypeNames);
- return type.getField(new String(field.name));
+ return type.getMethod(
+ new String(method.selector),
+ parameterTypeSignatures);
+}
+/**
+ * Creates an IType from the given simple type names.
+ */
+private IType createTypeHandle(char[][] simpleTypeNames) {
+ // creates compilation unit
+ CompilationUnit unit = (CompilationUnit) this.currentOpenable;
+
+ // create type
+ int length = simpleTypeNames.length;
+ IType type = unit.getType(new String(simpleTypeNames[0]));
+ for (int i = 1; i < length; i++) {
+ type = type.getType(new String(simpleTypeNames[i]));
}
-
- /**
- * Creates an IImportDeclaration from the given import statement
- */
- private IImportDeclaration createImportHandle(ImportReference importRef) {
- char[] importName = CharOperation.concatWith(importRef.getImportName(), '.');
- if (importRef.onDemand) {
- importName = CharOperation.concat(importName, ".*" .toCharArray()); //$NON-NLS-1$
+ return type;
+}
+private char[] getContents(IFile file) {
+ BufferedInputStream input = null;
+ try {
+ input = new BufferedInputStream(file.getContents(true));
+ StringBuffer buffer= new StringBuffer();
+ int nextChar = input.read();
+ while (nextChar != -1) {
+ buffer.append( (char)nextChar );
+ nextChar = input.read();
}
- return ((CompilationUnit) this.getCurrentOpenable()).getImport(
- new String(importName));
- }
-
- /**
- * Creates an IInitializer from the given field declaration and simple type names.
- */
- private IInitializer createInitializerHandle(
- TypeDeclaration typeDecl,
- FieldDeclaration initializer,
- char[][] definingTypeNames) {
- IType type = this.createTypeHandle(definingTypeNames);
-
- // find occurence count of the given initializer in its type declaration
- int occurrenceCount = 0;
- FieldDeclaration[] fields = typeDecl.fields;
- for (int i = 0, length = fields.length; i < length; i++) {
- FieldDeclaration field = fields[i];
- if (!field.isField()) {
- occurrenceCount++;
- if (field.equals(initializer)) {
- break;
- }
+ int length = buffer.length();
+ char[] result = new char[length];
+ buffer.getChars(0, length, result, 0);
+ return result;
+ } catch (IOException e) {
+ return null;
+ } catch (CoreException e) {
+ return null;
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ // nothing can be done if the file cannot be closed
}
}
-
- return type.getInitializer(occurrenceCount);
}
+}
+protected IResource getCurrentResource() {
+ return this.currentResource;
+}
+protected Scanner getScanner() {
+ return this.parser == null ? null : this.parser.scanner;
+}
+/**
+ * Locate the matches in the given files and report them using the search requestor.
+ */
+public void locateMatches(String[] filePaths, IWorkspace workspace) throws JavaModelException {
+ Util.sort(filePaths); // sort by projects
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ HandleFactory factory = new HandleFactory(workspace.getRoot(), manager);
+ JavaProject previousJavaProject = null;
+ int length = filePaths.length;
+ double increment = 100.0 / length;
+ double totalWork = 0;
+ int lastProgress = 0;
+ boolean couldInitializePattern = false;
+ for (int i = 0; i < length; i++) {
+ IProgressMonitor monitor = this.collector.getProgressMonitor();
+ if (monitor != null && monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ String pathString = filePaths[i];
+ this.currentOpenable = factory.createOpenable(pathString);
+ if (this.currentOpenable == null) continue; // match is outside classpath
- /**
- * Creates an IMethod from the given method declaration and simple type names.
- */
- private IMethod createMethodHandle(
- AbstractMethodDeclaration method,
- char[][] definingTypeNames) {
- IType type = this.createTypeHandle(definingTypeNames);
- Argument[] arguments = method.arguments;
- int length = arguments == null ? 0 : arguments.length;
- String[] parameterTypeSignatures = new String[length];
- for (int i = 0; i < length; i++) {
- TypeReference parameterType = arguments[i].type;
- char[] typeName = CharOperation.concatWith(parameterType.getTypeName(), '.');
- for (int j = 0; j < parameterType.dimensions(); j++) {
- typeName = CharOperation.concat(typeName, "[]" .toCharArray()); //$NON-NLS-1$
+ // create new parser and lookup environment if this is a new project
+ try {
+ JavaProject javaProject = (JavaProject)this.currentOpenable.getJavaProject();
+ this.currentResource = this.currentOpenable.getUnderlyingResource();
+ if (this.currentResource == null) { // case of a file in an external jar
+ this.currentResource = javaProject.getProject();
+ }
+ if (!javaProject.equals(previousJavaProject)) {
+ // create parser for this project
+ couldInitializePattern = this.createParser(javaProject);
+ previousJavaProject = javaProject;
}
- parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
+ if (!couldInitializePattern) continue; // the pattern could not be initialized: the match cannot be in this project
+ } catch (JavaModelException e) {
+ // file doesn't exist -> skip it
+ continue;
}
- return type.getMethod(new String(method.selector), parameterTypeSignatures);
- }
- /**
- * Creates an IType from the given simple type names.
- */
- private IType createTypeHandle(char[][] simpleTypeNames) {
- // creates compilation unit
- CompilationUnit unit = (CompilationUnit) this.getCurrentOpenable();
-
- // create type
- int length = simpleTypeNames.length;
- IType type = unit.getType(new String(simpleTypeNames[0]));
- for (int i = 1; i < length; i++) {
- type = type.getType(new String(simpleTypeNames[i]));
+ // locate matches in current file and report them
+ try {
+ if (this.currentOpenable instanceof CompilationUnit) {
+ this.locateMatchesInCompilationUnit();
+ } else if (this.currentOpenable instanceof org.eclipse.jdt.internal.core.ClassFile) {
+ this.locateMatchesInClassFile();
+ }
+ } catch (AbortCompilation e) {
+ // problem with class path: it could not find base classes
+ throw new JavaModelException(e, IJavaModelStatusConstants.BUILDER_INITIALIZATION_ERROR);
+ } catch (CoreException e) {
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException)e;
+ } else {
+ throw new JavaModelException(e);
+ }
+ }
+ if (monitor != null) {
+ totalWork = totalWork + increment;
+ int worked = (int)totalWork - lastProgress;
+ monitor.worked(worked);
+ lastProgress = (int)totalWork;
}
- return type;
}
- protected IResource getCurrentResource() {
- return this.potentialMatches[this.potentialMatchesIndex].resource;
+}
+/**
+ * Locate declaration in the current class file. This class file is always in a jar.
+ */
+private void locateMatchesInClassFile() throws CoreException, JavaModelException {
+ org.eclipse.jdt.internal.core.ClassFile classFile = (org.eclipse.jdt.internal.core.ClassFile)this.currentOpenable;
+ BinaryType binaryType = (BinaryType)classFile.getType();
+ IBinaryType info;
+ if (classFile.isOpen()) {
+ // reuse the info from the java model cache
+ info = (IBinaryType)binaryType.getRawInfo();
+ } else {
+ // create a temporary info
+ try {
+ IJavaElement pkg = classFile.getParent();
+ PackageFragmentRoot root = (PackageFragmentRoot)pkg.getParent();
+ if (root.isArchive()) {
+ // class file in a jar
+ String pkgPath = pkg.getElementName().replace('.', '/');
+ String classFilePath =
+ (pkgPath.length() > 0) ?
+ pkgPath + "/"/*nonNLS*/ + classFile.getElementName() :
+ classFile.getElementName();
+ ZipFile zipFile = null;
+ try {
+ zipFile = ((JarPackageFragmentRoot)root).getJar();
+ info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(
+ zipFile,
+ classFilePath);
+ } finally {
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ } else {
+ // class file in a directory
+ String osPath = this.currentResource.getFullPath().toOSString();
+ info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(osPath);
+ }
+ } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) {
+ e.printStackTrace();
+ return;
+ } catch (java.io.IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+
}
- protected Scanner getScanner() {
- return this.parser == null ? null : this.parser.scanner;
+
+ // check class definition
+ if (this.pattern.matchesBinary(info, null)) {
+ this.reportBinaryMatch(binaryType, info, IJavaSearchResultCollector.EXACT_MATCH);
}
- /**
- * Locate the matches in the given files and report them using the search requestor.
- */
- public void locateMatches(String[] filePaths, IWorkspace workspace)
- throws JavaModelException {
- Util.sort(filePaths); // sort by projects
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- HandleFactory factory = new HandleFactory(workspace.getRoot(), manager);
- JavaProject previousJavaProject = null;
- int length = filePaths.length;
- double increment = 100.0 / length;
- double totalWork = 0;
- int lastProgress = 0;
- boolean couldInitializePattern = false;
- this.potentialMatches = new PotentialMatch[10];
- this.potentialMatchesLength = 0;
- for (int i = 0; i < length; i++) {
- IProgressMonitor monitor = this.collector.getProgressMonitor();
- if (monitor != null && monitor.isCanceled()) {
- throw new OperationCanceledException();
+ boolean compilationAborted = false;
+ if (this.pattern.needsResolve) {
+ // resolve
+ BinaryTypeBinding binding = null;
+ try {
+ binding = this.lookupEnvironment.cacheBinaryType(info);
+ if (binding == null) { // it was already cached as a result of a previous query
+ char[][] compoundName = CharOperation.splitOn('.', binaryType.getFullyQualifiedName().toCharArray());
+ ReferenceBinding referenceBinding = this.lookupEnvironment.getCachedType(compoundName);
+ if (referenceBinding != null && (referenceBinding instanceof BinaryTypeBinding)) {
+ // if the binding could be found and if it comes from a source type,
+ binding = (BinaryTypeBinding)referenceBinding;
+ }
}
- String pathString = filePaths[i];
- Openable openable = factory.createOpenable(pathString);
- if (openable == null)
- continue; // match is outside classpath
- // create new parser and lookup environment if this is a new project
- IResource resource = null;
- try {
- JavaProject javaProject = (JavaProject) openable.getJavaProject();
- resource = openable.getUnderlyingResource();
- if (resource == null) { // case of a file in an external jar
- resource = javaProject.getProject();
+ // check methods
+ if (binding != null) {
+ MethodBinding[] methods = binding.methods();
+ for (int i = 0; i < methods.length; i++) {
+ MethodBinding method = methods[i];
+ if (this.pattern.matches(method)) {
+ IMethod methodHandle =
+ binaryType.getMethod(
+ new String(method.isConstructor() ? binding.compoundName[binding.compoundName.length-1] : method.selector),
+ Signature.getParameterTypes(new String(method.signature()).replace('/', '.'))
+ );
+ this.reportBinaryMatch(methodHandle, info, IJavaSearchResultCollector.EXACT_MATCH);
+ }
}
- if (!javaProject.equals(previousJavaProject)) {
- // locate matches in previous project
- if (previousJavaProject != null) {
- this.locateMatches();
- this.potentialMatchesLength = 0;
+ }
+
+ // check fields
+ if (binding != null) {
+ FieldBinding[] fields = binding.fields();
+ for (int i = 0; i < fields.length; i++) {
+ FieldBinding field = fields[i];
+ if (this.pattern.matches(field)) {
+ IField fieldHandle = binaryType.getField(new String(field.name));
+ this.reportBinaryMatch(fieldHandle, info, IJavaSearchResultCollector.EXACT_MATCH);
}
-
- // create parser for this project
- couldInitializePattern = this.createParser(javaProject);
- previousJavaProject = javaProject;
}
- if (!couldInitializePattern)
- continue;
- // the pattern could not be initialized: the match cannot be in this project
- } catch (JavaModelException e) {
- // file doesn't exist -> skip it
- continue;
}
+ } catch (AbortCompilation e) {
+ binding = null;
+ }
- // add potential match
- this.addPotentialMatch(resource, openable);
+ // no need to check binary info if resolve was successful
+ compilationAborted = binding == null;
+ if (!compilationAborted) return;
+ }
- if (monitor != null) {
- totalWork = totalWork + increment;
- int worked = (int) totalWork - lastProgress;
- monitor.worked(worked);
- lastProgress = (int) totalWork;
- }
+ // if compilation was aborted it is a problem with the class path:
+ // report as a potential match if binary info matches the pattern
+ int accuracy = compilationAborted ? IJavaSearchResultCollector.POTENTIAL_MATCH : IJavaSearchResultCollector.EXACT_MATCH;
+
+ // check methods
+ IBinaryMethod[] methods = info.getMethods();
+ int length = methods == null ? 0 : methods.length;
+ for (int i = 0; i < length; i++) {
+ IBinaryMethod method = methods[i];
+ if (this.pattern.matchesBinary(method, info)) {
+ IMethod methodHandle =
+ binaryType.getMethod(
+ new String(method.isConstructor() ? info.getName() : method.getSelector()),
+ Signature.getParameterTypes(new String(method.getMethodDescriptor()).replace('/', '.'))
+ );
+ this.reportBinaryMatch(methodHandle, info, accuracy);
}
+ }
- // last project
- if (previousJavaProject != null) {
- this.locateMatches();
- this.potentialMatchesLength = 0;
+ // check fields
+ IBinaryField[] fields = info.getFields();
+ length = fields == null ? 0 : fields.length;
+ for (int i = 0; i < length; i++) {
+ IBinaryField field = fields[i];
+ if (this.pattern.matchesBinary(field, info)) {
+ IField fieldHandle = binaryType.getField(new String(field.getName()));
+ this.reportBinaryMatch(fieldHandle, info, accuracy);
}
-
}
+}
+private void locateMatchesInCompilationUnit() throws CoreException {
+ // get source
+ final char[] source = getContents((IFile)this.currentResource);
+
+ // get main type name
+ String pathString = this.currentResource.toString();
+ int lastDot = pathString.lastIndexOf('/');
+ // remove folder path and extension ".java"
+ final char[] mainTypeName = pathString.substring(lastDot+1, pathString.length()-5).toCharArray();
+
+ // parse
+ ICompilationUnit sourceUnit = new ICompilationUnit() {
+ public char[] getContents() {
+ return source;
+ }
+ public char[] getFileName() {
+ return MatchLocator.this.currentResource.getName().toCharArray();
+ }
+ public char[] getMainTypeName() {
+ return mainTypeName;
+ }
+ };
+ MatchSet set = new MatchSet(this);
+ this.parser.matchSet = set;
+ CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0);
+ CompilationUnitDeclaration parsedUnit = this.parser.parse(sourceUnit, compilationResult);
+
+ if (parsedUnit != null) {
+ // report matches that don't need resolve
+ set.cuHasBeenResolved = false;
+ set.accuracy = IJavaSearchResultCollector.EXACT_MATCH;
+ set.reportMatching(parsedUnit);
+
+ // resolve if needed
+ if (set.needsResolve()) {
+ if (parsedUnit.types != null) {
+ /**
+ * First approximation: reset the lookup environment -> this will recreate the bindings for the current CU
+ * Optimization: the binding resolution should be done for all compilation units at once
+ */
+ this.lookupEnvironment.reset();
- /**
- * Locates the package declarations corresponding to this locator's pattern.
- */
- public void locatePackageDeclarations(IWorkspace workspace)
- throws JavaModelException {
- this.locatePackageDeclarations(this.pattern, workspace);
+ try {
+ lookupEnvironment.buildTypeBindings(parsedUnit);
+ if (parsedUnit.scope != null) {
+ lookupEnvironment.completeTypeBindings(parsedUnit, true);
+ parsedUnit.scope.faultInTypes();
+ parsedUnit.resolve();
+ //this.pattern.initializeFromLookupEnvironment(this.lookupEnvironment);
+ }
+ // report matches that needed resolve
+ set.cuHasBeenResolved = true;
+ set.accuracy = IJavaSearchResultCollector.EXACT_MATCH;
+ set.reportMatching(parsedUnit);
+ } catch (AbortCompilation e) {
+ // could not resolve (reasons include "could not find library class") -> ignore and report the unresolved nodes
+ set.cuHasBeenResolved = false;
+ set.accuracy = IJavaSearchResultCollector.POTENTIAL_MATCH;
+ set.reportMatching(parsedUnit);
+ }
+ }
+ }
}
-
- /**
- * Locates the package declarations corresponding to the search pattern.
- */
- private void locatePackageDeclarations(
- SearchPattern searchPattern,
- IWorkspace workspace)
- throws JavaModelException {
- if (searchPattern instanceof OrPattern) {
- OrPattern orPattern = (OrPattern) searchPattern;
- this.locatePackageDeclarations(orPattern.leftPattern, workspace);
- this.locatePackageDeclarations(orPattern.rightPattern, workspace);
- } else
- if (searchPattern instanceof PackageDeclarationPattern) {
- PackageDeclarationPattern pkgPattern =
- (PackageDeclarationPattern) searchPattern;
- String pkgName = new String(pkgPattern.pkgName);
- IJavaProject[] projects =
- JavaModelManager.getJavaModel(workspace).getJavaProjects();
- for (int i = 0, length = projects.length; i < length; i++) {
- IJavaProject javaProject = projects[i];
- IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
- for (int j = 0, rootsLength = roots.length; j < rootsLength; j++) {
- IJavaElement[] pkgs = roots[j].getChildren();
- for (int k = 0, pksLength = pkgs.length; k < pksLength; k++) {
- IJavaElement pkg = pkgs[k];
- if (pkgPattern
- .matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
- IResource resource = pkg.getUnderlyingResource();
- if (resource == null) { // case of a file in an external jar
- resource = javaProject.getProject();
- }
- this.potentialMatchesIndex = 0;
- this.potentialMatches =
- new PotentialMatch[] { new PotentialMatch(this, resource, null)};
- try {
- this.report(-1, -2, pkg, IJavaSearchResultCollector.EXACT_MATCH);
- } catch (CoreException e) {
- if (e instanceof JavaModelException) {
- throw (JavaModelException) e;
- } else {
- throw new JavaModelException(e);
- }
- }
+}
+/**
+ * Locates the package declarations corresponding to this locator's pattern.
+ */
+public void locatePackageDeclarations(IWorkspace workspace) throws JavaModelException {
+ this.locatePackageDeclarations(this.pattern, workspace);
+}
+/**
+ * Locates the package declarations corresponding to the search pattern.
+ */
+private void locatePackageDeclarations(SearchPattern searchPattern, IWorkspace workspace) throws JavaModelException {
+ if (searchPattern instanceof OrPattern) {
+ OrPattern orPattern = (OrPattern)searchPattern;
+ this.locatePackageDeclarations(orPattern.leftPattern, workspace);
+ this.locatePackageDeclarations(orPattern.rightPattern, workspace);
+ } else if (searchPattern instanceof PackageDeclarationPattern) {
+ PackageDeclarationPattern pkgPattern = (PackageDeclarationPattern)searchPattern;
+ String pkgName = new String(pkgPattern.pkgName);
+ IJavaProject[] projects = JavaModelManager.getJavaModel(workspace).getJavaProjects();
+ for (int i = 0, length = projects.length; i < length; i++) {
+ IJavaProject javaProject = projects[i];
+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ for (int j = 0, rootsLength = roots.length; j < rootsLength; j++) {
+ IJavaElement[] pkgs = roots[j].getChildren();
+ for (int k = 0, pksLength = pkgs.length; k < pksLength; k++) {
+ IJavaElement pkg = pkgs[k];
+ if (pkgPattern.matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
+ this.currentResource = pkg.getUnderlyingResource();
+ if (this.currentResource == null) { // case of a file in an external jar
+ this.currentResource = javaProject.getProject();
+ }
+ try {
+ this.report(-1, -2, pkg, IJavaSearchResultCollector.EXACT_MATCH);
+ } catch (CoreException e) {
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException)e;
+ } else {
+ throw new JavaModelException(e);
}
}
}
}
}
- }
-
- public void report(
- int sourceStart,
- int sourceEnd,
- IJavaElement element,
- int accuracy)
- throws CoreException {
- if (this.scope.encloses(element)) {
- this.collector.accept(
- this.getCurrentResource(),
- sourceStart,
- sourceEnd + 1,
- element,
- accuracy);
}
}
-
- public void reportBinaryMatch(
- IMember binaryMember,
- IBinaryType info,
- int accuracy)
- throws CoreException, JavaModelException {
- ISourceRange range = binaryMember.getNameRange();
- if (range.getOffset() == -1) {
- ClassFile classFile = (ClassFile) binaryMember.getClassFile();
- SourceMapper mapper = classFile.getSourceMapper();
- if (mapper != null) {
- IType type = classFile.getType();
- char[] contents = mapper.findSource(type, info);
- if (contents != null) {
- range = mapper.mapSource(type, contents, binaryMember);
- }
+}
+public void report(int sourceStart, int sourceEnd, IJavaElement element, int accuracy) throws CoreException {
+ if (this.scope.encloses(element)) {
+ this.collector.accept(
+ this.currentResource,
+ sourceStart,
+ sourceEnd + 1,
+ element,
+ accuracy
+ );
+ }
+}
+private void reportBinaryMatch(IMember binaryMember, IBinaryType info, int accuracy) throws CoreException, JavaModelException {
+ ISourceRange range = binaryMember.getNameRange();
+ if (range.getOffset() == -1) {
+ ClassFile classFile = (ClassFile)binaryMember.getClassFile();
+ SourceMapper mapper = classFile.getSourceMapper();
+ if (mapper != null) {
+ IType type = classFile.getType();
+ char[] contents = mapper.findSource(type, info);
+ if (contents != null) {
+ range = mapper.mapSource(type, contents, binaryMember);
}
}
- int startIndex = range.getOffset();
- int endIndex = startIndex + range.getLength() - 1;
- this.report(startIndex, endIndex, binaryMember, accuracy);
}
+ int startIndex = range.getOffset();
+ int endIndex = startIndex + range.getLength() - 1;
+ this.report(startIndex, endIndex, binaryMember, accuracy);
+}
+/**
+ * Reports the given field declaration to the search requestor.
+ * Its defining types have the given simple names.
+ */
+public void reportFieldDeclaration(
+ FieldDeclaration fieldDeclaration,
+ char[][] definingTypeNames,
+ int accuracy) throws CoreException {
+
+ // create field handle
+ IType type = this.createTypeHandle(definingTypeNames);
+ IField field = type.getField(new String(fieldDeclaration.name));
+
+ // accept field declaration
+ this.report(fieldDeclaration.sourceStart, fieldDeclaration.sourceEnd, field, accuracy);
+}
+/**
+ * Reports the given import to the search requestor.
+ */
+public void reportImport(ImportReference reference, int accuracy) throws CoreException {
- /**
- * Reports the given field declaration to the search requestor.
- * Its defining types have the given simple names.
- */
- public void reportFieldDeclaration(
- FieldDeclaration fieldDeclaration,
- char[][] definingTypeNames,
- int accuracy)
- throws CoreException {
-
- // create field handle
- IType type = this.createTypeHandle(definingTypeNames);
- IField field = type.getField(new String(fieldDeclaration.name));
-
- // accept field declaration
- this.report(
- fieldDeclaration.sourceStart,
- fieldDeclaration.sourceEnd,
- field,
- accuracy);
- }
-
- /**
- * Reports the given import to the search requestor.
- */
- public void reportImport(ImportReference reference, int accuracy)
- throws CoreException {
-
- // create defining import handle
- IImportDeclaration importHandle = this.createImportHandle(reference);
-
- // accept reference
- this.pattern.matchReportReference(reference, importHandle, accuracy, this);
+ // create defining import handle
+ IImportDeclaration importHandle = this.createImportHandle(reference);
+
+ // accept reference
+ this.pattern.matchReportReference(reference, importHandle, accuracy, this);
+}
+/**
+ * Reports the given method declaration to the search requestor.
+ * Its defining types have the given simple names.
+ */
+public void reportMethodDeclaration(
+ AbstractMethodDeclaration methodDeclaration,
+ char[][] definingTypeNames,
+ int accuracy) throws CoreException {
+
+ // create method handle
+ IMethod method = this.createMethodHandle(methodDeclaration, definingTypeNames);
+
+ // compute source positions of the selector
+ Scanner scanner = parser.scanner;
+ int nameSourceStart = methodDeclaration.sourceStart;
+ scanner.resetTo(nameSourceStart, methodDeclaration.sourceEnd);
+ try {
+ scanner.getNextToken();
+ } catch(InvalidInputException e) {
}
+ int nameSourceEnd = scanner.currentPosition-1;
- /**
- * Reports the given method declaration to the search requestor.
- * Its defining types have the given simple names.
- */
- public void reportMethodDeclaration(
- AbstractMethodDeclaration methodDeclaration,
- char[][] definingTypeNames,
- int accuracy)
- throws CoreException {
-
- // create method handle
- IMethod method = this.createMethodHandle(methodDeclaration, definingTypeNames);
-
- // compute source positions of the selector
- Scanner scanner = parser.scanner;
- int nameSourceStart = methodDeclaration.sourceStart;
- scanner.setSourceBuffer(
- this.potentialMatches[this.potentialMatchesIndex].getSource());
- scanner.resetTo(nameSourceStart, methodDeclaration.sourceEnd);
+ // accept method declaration
+ this.report(nameSourceStart, nameSourceEnd, method, accuracy);
+}
+/**
+ * Reports the given package declaration to the search requestor.
+ */
+public void reportPackageDeclaration(ImportReference node) {
+ // TBD
+}
+/**
+ * Reports the given package reference to the search requestor.
+ */
+public void reportPackageReference(ImportReference node) {
+ // TBD
+}
+/**
+ * Reports the given qualified reference to the search requestor.
+ */
+public void reportQualifiedReference(
+ int sourceStart,
+ int sourceEnd,
+ char[][] qualifiedName,
+ IJavaElement element,
+ int accuracy) throws CoreException {
+
+ // compute source positions of the qualified reference
+ Scanner scanner = parser.scanner;
+ scanner.resetTo(sourceStart, sourceEnd);
+
+ int refSourceStart = -1, refSourceEnd = -1;
+ int tokenNumber = qualifiedName.length;
+ int token = -1;
+ int previousValid = -1;
+ int i = 0;
+ do {
+ int currentPosition = scanner.currentPosition;
+ // read token
try {
- scanner.getNextToken();
- } catch (InvalidInputException e) {
+ token = scanner.getNextToken();
+ } catch(InvalidInputException e) {
}
- int nameSourceEnd = scanner.currentPosition - 1;
-
- // accept method declaration
- this.report(nameSourceStart, nameSourceEnd, method, accuracy);
- }
-
- /**
- * Reports the given package declaration to the search requestor.
- */
- public void reportPackageDeclaration(ImportReference node) {
- // TBD
- }
-
- /**
- * Reports the given package reference to the search requestor.
- */
- public void reportPackageReference(ImportReference node) {
- // TBD
- }
-
- /**
- * Reports the given qualified reference to the search requestor.
- */
- public void reportQualifiedReference(
- int sourceStart,
- int sourceEnd,
- char[][] qualifiedName,
- IJavaElement element,
- int accuracy)
- throws CoreException {
-
- // compute source positions of the qualified reference
- Scanner scanner = parser.scanner;
- scanner.setSourceBuffer(
- this.potentialMatches[this.potentialMatchesIndex].getSource());
- scanner.resetTo(sourceStart, sourceEnd);
-
- int refSourceStart = -1, refSourceEnd = -1;
- int tokenNumber = qualifiedName.length;
- int token = -1;
- int previousValid = -1;
- int i = 0;
- do {
- int currentPosition = scanner.currentPosition;
- // read token
- try {
- token = scanner.getNextToken();
- } catch (InvalidInputException e) {
+ if (token != TerminalSymbols.TokenNameEOF) {
+ char[] currentTokenSource = scanner.getCurrentTokenSource();
+ while (i < tokenNumber && !CharOperation.equals(currentTokenSource, qualifiedName[i++])) {
}
- if (token != TerminalSymbols.TokenNameEOF) {
- char[] currentTokenSource = scanner.getCurrentTokenSource();
- while (i < tokenNumber
- && !CharOperation.equals(currentTokenSource, qualifiedName[i++])) {
- }
- if (CharOperation.equals(currentTokenSource, qualifiedName[i - 1])
- && (previousValid == -1 || previousValid == i - 2)) {
- previousValid = i - 1;
- if (refSourceStart == -1) {
- refSourceStart = currentPosition;
- }
- refSourceEnd = scanner.currentPosition - 1;
- } else {
- i = 0;
- refSourceStart = -1;
- previousValid = -1;
- }
- // read '.'
- try {
- token = scanner.getNextToken();
- } catch (InvalidInputException e) {
+ if (CharOperation.equals(currentTokenSource, qualifiedName[i-1]) && (previousValid == -1 || previousValid == i-2)) {
+ previousValid = i-1;
+ if (refSourceStart == -1) {
+ refSourceStart = currentPosition;
}
+ refSourceEnd = scanner.currentPosition-1;
+ } else {
+ i = 0;
+ refSourceStart = -1;
+ previousValid = -1;
}
- }
- while (token != TerminalSymbols.TokenNameEOF && i < tokenNumber);
-
+ // read '.'
+ try {
+ token = scanner.getNextToken();
+ } catch(InvalidInputException e) {
+ }
+ }
+ } while (token != TerminalSymbols.TokenNameEOF && i < tokenNumber);
+
+ // accept method declaration
+ if (refSourceStart != -1) {
+ this.report(refSourceStart, refSourceEnd, element, accuracy);
+ } else {
+ this.report(sourceStart, sourceEnd, element, accuracy);
+ }
+}
+/**
+ * Reports the given reference to the search requestor.
+ * It is done in the given method and the method's defining types
+ * have the given simple names.
+ */
+public void reportReference(
+ AstNode reference,
+ AbstractMethodDeclaration methodDeclaration,
+ char[][] definingTypeNames,
+ int accuracy) throws CoreException {
+
+ // create defining method handle
+ IMethod method = this.createMethodHandle(methodDeclaration, definingTypeNames);
+
+ // accept reference
+ if (reference instanceof QualifiedNameReference || reference instanceof QualifiedTypeReference) {
+ this.pattern.matchReportReference((AstNode)reference, method, accuracy, this);
+ } else if (reference instanceof MessageSend) { // message ref are starting at the selector start
+ this.report((int)(((MessageSend)reference).nameSourcePosition >> 32), reference.sourceEnd, method, accuracy);
+ } else {
+ this.report(reference.sourceStart, reference.sourceEnd, method, accuracy);
+ }
+}
+/**
+ * Reports the given reference to the search requestor.
+ * It is done in the given field and given type.
+ * The field's defining types have the given simple names.
+ */
+public void reportReference(
+ AstNode reference,
+ TypeDeclaration typeDeclaration,
+ FieldDeclaration fieldDeclaration,
+ char[][] definingTypeNames,
+ int accuracy) throws CoreException {
+
+ if (fieldDeclaration.isField()) {
+ // create defining field handle
+ IField field = this.createFieldHandle(fieldDeclaration, definingTypeNames);
+
// accept reference
- if (refSourceStart != -1) {
- this.report(refSourceStart, refSourceEnd, element, accuracy);
+ if (reference instanceof QualifiedNameReference || reference instanceof QualifiedTypeReference) {
+ this.pattern.matchReportReference((AstNode)reference, field, accuracy, this);
+ } else if (reference instanceof MessageSend) { // message ref are starting at the selector start
+ this.report((int)(((MessageSend)reference).nameSourcePosition >> 32), reference.sourceEnd, field, accuracy);
} else {
- this.report(sourceStart, sourceEnd, element, accuracy);
+ this.report(reference.sourceStart, reference.sourceEnd, field, accuracy);
}
- }
-
- /**
- * Reports the given reference to the search requestor.
- * It is done in the given method and the method's defining types
- * have the given simple names.
- */
- public void reportReference(
- AstNode reference,
- AbstractMethodDeclaration methodDeclaration,
- char[][] definingTypeNames,
- int accuracy)
- throws CoreException {
-
- // create defining method handle
- IMethod method = this.createMethodHandle(methodDeclaration, definingTypeNames);
-
+ } else { // initializer
+ // create defining initializer
+ IInitializer initializer = this.createInitializerHandle(typeDeclaration, fieldDeclaration, definingTypeNames);
+
// accept reference
- if (reference instanceof QualifiedNameReference
- || reference instanceof QualifiedTypeReference) {
- this.pattern.matchReportReference((AstNode) reference, method, accuracy, this);
- } else
- if (reference instanceof MessageSend) {
- // message ref are starting at the selector start
- this.report(
- (int) (((MessageSend) reference).nameSourcePosition >> 32),
- reference.sourceEnd,
- method,
- accuracy);
- } else {
- this.report(reference.sourceStart, reference.sourceEnd, method, accuracy);
- }
- }
-
- /**
- * Reports the given reference to the search requestor.
- * It is done in the given field and given type.
- * The field's defining types have the given simple names.
- */
- public void reportReference(
- AstNode reference,
- TypeDeclaration typeDeclaration,
- FieldDeclaration fieldDeclaration,
- char[][] definingTypeNames,
- int accuracy)
- throws CoreException {
-
- if (fieldDeclaration.isField()) {
- // create defining field handle
- IField field = this.createFieldHandle(fieldDeclaration, definingTypeNames);
-
- // accept reference
- if (reference instanceof QualifiedNameReference
- || reference instanceof QualifiedTypeReference) {
- this.pattern.matchReportReference((AstNode) reference, field, accuracy, this);
- } else
- if (reference instanceof MessageSend) {
- // message ref are starting at the selector start
- this.report(
- (int) (((MessageSend) reference).nameSourcePosition >> 32),
- reference.sourceEnd,
- field,
- accuracy);
- } else {
- this.report(reference.sourceStart, reference.sourceEnd, field, accuracy);
- }
- } else { // initializer
- // create defining initializer
- IInitializer initializer =
- this.createInitializerHandle(
- typeDeclaration,
- fieldDeclaration,
- definingTypeNames);
-
- // accept reference
- if (reference instanceof QualifiedNameReference
- || reference instanceof QualifiedTypeReference) {
- this.pattern.matchReportReference(
- (AstNode) reference,
- initializer,
- accuracy,
- this);
- } else
- if (reference instanceof MessageSend) {
- // message ref are starting at the selector start
- this.report(
- (int) (((MessageSend) reference).nameSourcePosition >> 32),
- reference.sourceEnd,
- initializer,
- accuracy);
- } else {
- this.report(reference.sourceStart, reference.sourceEnd, initializer, accuracy);
- }
- }
- }
-
- /**
- * Reports the given super type reference to the search requestor.
- * It is done in the given defining type (with the given simple names).
- */
- public void reportSuperTypeReference(
- TypeReference typeRef,
- char[][] definingTypeNames,
- int accuracy)
- throws CoreException {
-
- // create defining type handle
- IType type = this.createTypeHandle(definingTypeNames);
-
- // accept type reference
- this.pattern.matchReportReference(typeRef, type, accuracy, this);
- }
-
- /**
- * Reports the given type declaration to the search requestor.
- * Its simple names are the names of its outer most type to this type.
- */
- public void reportTypeDeclaration(
- TypeDeclaration typeDeclaration,
- char[][] simpleTypeNames,
- int accuracy)
- throws CoreException {
-
- // create type handle
- IType type = this.createTypeHandle(simpleTypeNames);
-
- // accept class or interface declaration
- this.report(
- typeDeclaration.sourceStart,
- typeDeclaration.sourceEnd,
- type,
- accuracy);
- }
-
- private void addPotentialMatch(IResource resource, Openable openable)
- throws JavaModelException {
- try {
- if (this.potentialMatchesLength == this.potentialMatches.length) {
- System.arraycopy(
- this.potentialMatches,
- 0,
- this.potentialMatches = new PotentialMatch[this.potentialMatchesLength * 2],
- 0,
- this.potentialMatchesLength);
- }
- this.potentialMatches[this.potentialMatchesLength++] =
- new PotentialMatch(this, resource, openable);
- } catch (AbortCompilation e) {
- // problem with class path: it could not find base classes
- throw new JavaModelException(
- e,
- IJavaModelStatusConstants.BUILDER_INITIALIZATION_ERROR);
+ if (reference instanceof QualifiedNameReference || reference instanceof QualifiedTypeReference) {
+ this.pattern.matchReportReference((AstNode)reference, initializer, accuracy, this);
+ } else if (reference instanceof MessageSend) { // message ref are starting at the selector start
+ this.report((int)(((MessageSend)reference).nameSourcePosition >> 32), reference.sourceEnd, initializer, accuracy);
+ } else {
+ this.report(reference.sourceStart, reference.sourceEnd, initializer, accuracy);
}
}
+}
+/**
+ * Reports the given super type reference to the search requestor.
+ * It is done in the given defining type (with the given simple names).
+ */
+public void reportSuperTypeReference(
+ TypeReference typeRef,
+ char[][] definingTypeNames,
+ int accuracy) throws CoreException {
+
+ // create defining type handle
+ IType type = this.createTypeHandle(definingTypeNames);
+
+ // accept type reference
+ this.pattern.matchReportReference(typeRef, type, accuracy, this);
+}
+/**
+ * Reports the given type declaration to the search requestor.
+ * Its simple names are the names of its outer most type to this type.
+ */
+public void reportTypeDeclaration(
+ TypeDeclaration typeDeclaration,
+ char[][] simpleTypeNames,
+ int accuracy) throws CoreException {
+
+ // create type handle
+ IType type = this.createTypeHandle(simpleTypeNames);
+
+ // accept class or interface declaration
+ this.report(typeDeclaration.sourceStart, typeDeclaration.sourceEnd, type, accuracy);
+}
- /**
- * Create a new parser for the given project, as well as a lookup environment.
- * Asks the pattern to initialize itself from the lookup environment.
- * Returns whether it was able to initialize the pattern.
- */
- private boolean createParser(JavaProject project) throws JavaModelException {
- INameEnvironment nameEnvironment = project.getSearchableNameEnvironment();
- IProblemFactory problemFactory = new DefaultProblemFactory();
-
- CompilerOptions options = new CompilerOptions(null);
- ProblemReporter problemReporter =
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- problemFactory);
- this.lookupEnvironment =
- new LookupEnvironment(this, options, problemReporter, nameEnvironment);
- this.parser = new MatchLocatorParser(problemReporter);
- this.parsedUnits = new HashtableOfObject(10);
- return this.pattern.initializeFromLookupEnvironment(this.lookupEnvironment);
- }
-
- protected Openable getCurrentOpenable() {
- return this.potentialMatches[this.potentialMatchesIndex].openable;
- }
-
- /**
- * Locate the matches amongst the potential matches.
- */
- private void locateMatches() throws JavaModelException {
- // binding resolution
- this.lookupEnvironment.completeTypeBindings();
-
- // potential match resolution
- for (this.potentialMatchesIndex = 0;
- this.potentialMatchesIndex < this.potentialMatchesLength;
- this.potentialMatchesIndex++) {
- try {
- PotentialMatch potentialMatch =
- this.potentialMatches[this.potentialMatchesIndex];
- potentialMatch.locateMatches();
- potentialMatch.reset();
- } catch (AbortCompilation e) {
- // problem with class path: it could not find base classes
- throw new JavaModelException(
- e,
- IJavaModelStatusConstants.BUILDER_INITIALIZATION_ERROR);
- } catch (CoreException e) {
- if (e instanceof JavaModelException) {
- throw (JavaModelException) e;
- } else {
- throw new JavaModelException(e);
- }
- }
- }
- }
-} \ No newline at end of file
+/**
+ * Create a new parser for the given project, as well as a lookup environment.
+ * Asks the pattern to initialize itself from the lookup environment.
+ * Returns whether it was able to initialize the pattern.
+ */
+private boolean createParser(JavaProject project) throws JavaModelException {
+ INameEnvironment nameEnvironment = project.getSearchableNameEnvironment();
+ IProblemFactory problemFactory = new DefaultProblemFactory();
+
+ CompilerOptions options = new CompilerOptions(null);
+ ProblemReporter problemReporter =
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ problemFactory);
+ this.lookupEnvironment = new LookupEnvironment(this, options, problemReporter, nameEnvironment);
+ this.parser = new MatchLocatorParser(problemReporter);
+ return this.pattern.initializeFromLookupEnvironment(this.lookupEnvironment);
+}
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
index 2c8d886194..4370011145 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
@@ -24,77 +24,70 @@ public MatchLocatorParser(ProblemReporter problemReporter) {
}
protected void classInstanceCreation(boolean alwaysQualified) {
super.classInstanceCreation(alwaysQualified);
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
- }
+ this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
super.consumeExplicitConstructorInvocation(flag, recFlag);
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.astStack[this.astPtr]);
- }
+ this.matchSet.checkMatching(this.astStack[this.astPtr]);
}
protected void consumeFieldAccess(boolean isSuperAccess) {
super.consumeFieldAccess(isSuperAccess);
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
- }
+ this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
protected void consumeMethodInvocationName() {
super.consumeMethodInvocationName();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
- }
+ this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
protected void consumeMethodInvocationPrimary() {
super.consumeMethodInvocationPrimary();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
- }
+ this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
protected void consumeMethodInvocationSuper() {
super.consumeMethodInvocationSuper();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
- }
+ this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
protected void consumeSingleTypeImportDeclarationName() {
super.consumeSingleTypeImportDeclarationName();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.astStack[this.astPtr]);
- }
+ this.matchSet.checkMatching(this.astStack[this.astPtr]);
}
protected void consumeTypeImportOnDemandDeclarationName() {
super.consumeTypeImportOnDemandDeclarationName();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(this.astStack[this.astPtr]);
- }
+ this.matchSet.checkMatching(this.astStack[this.astPtr]);
}
protected TypeReference getTypeReference(int dim) {
TypeReference typeRef = super.getTypeReference(dim);
- if (this.matchSet != null) {
- this.matchSet.checkMatching(typeRef); // NB: Don't check container since type reference can happen anywhere
- }
+ this.matchSet.checkMatching(typeRef); // NB: Don't check container since type reference can happen anywhere
return typeRef;
}
protected NameReference getUnspecifiedReference() {
NameReference nameRef = super.getUnspecifiedReference();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(nameRef); // NB: Don't check container since unspecified reference can happen anywhere
- }
+ this.matchSet.checkMatching(nameRef); // NB: Don't check container since unspecified reference can happen anywhere
return nameRef;
}
protected NameReference getUnspecifiedReferenceOptimized() {
NameReference nameRef = super.getUnspecifiedReferenceOptimized();
- if (this.matchSet != null) {
- this.matchSet.checkMatching(nameRef); // NB: Don't check container since unspecified reference can happen anywhere
- }
+ this.matchSet.checkMatching(nameRef); // NB: Don't check container since unspecified reference can happen anywhere
return nameRef;
}
/**
+ * Parses the given source unit in 2 times:
+ * - first do a diet parse to determine the structure of the compilation unit
+ * - then do a method body parse of each method to determine the references
+ */
+public CompilationUnitDeclaration parse(
+ ICompilationUnit sourceUnit,
+ CompilationResult compilationResult) {
+
+ this.diet = true;
+ CompilationUnitDeclaration unit = super.parse(sourceUnit, compilationResult);
+ this.diet = false;
+ this.parseBodies(unit);
+ return unit;
+}
+/**
* Parses the method bodies in the given compilation unit
*/
-public void parseBodies(CompilationUnitDeclaration unit) {
+private void parseBodies(CompilationUnitDeclaration unit) {
TypeDeclaration[] types = unit.types;
if (types != null) {
for (int i = 0; i < types.length; i++) {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
index 1b1c8a51fe..fb5befed60 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
@@ -42,18 +42,18 @@ public MatchSet(MatchLocator locator) {
this.matchContainer = locator.pattern.matchContainer();
}
public void addPossibleMatch(AstNode node) {
- this.potentialMatchingNodes.put(node, new Integer(SearchPattern.POSSIBLE_MATCH));
+ this.potentialMatchingNodes.put(node, node);
}
public void addTrustedMatch(AstNode node) {
- this.matchingNodes.put(node, new Integer(SearchPattern.ACCURATE_MATCH));
+ this.matchingNodes.put(node, node);
}
public void checkMatching(AstNode node) {
- int matchLevel = this.locator.pattern.matchLevel(node, false);
+ int matchLevel = this.locator.pattern.matchLevel(node);
switch (matchLevel) {
case SearchPattern.POSSIBLE_MATCH:
this.addPossibleMatch(node);
break;
- case SearchPattern.ACCURATE_MATCH:
+ case SearchPattern.TRUSTED_MATCH:
this.addTrustedMatch(node);
}
}
@@ -109,15 +109,9 @@ private void reportMatching(AbstractMethodDeclaration method, char[][] definingT
AstNode[] nodes = this.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
for (int i = 0; i < nodes.length; i++) {
AstNode node = nodes[i];
- Integer level = (Integer)this.matchingNodes.remove(node);
+ this.matchingNodes.remove(node);
if ((this.matchContainer & SearchPattern.METHOD) != 0) {
- this.locator.reportReference(
- node,
- method,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportReference(node, method, definingTypeNames, this.accuracy);
}
}
if (this.potentialMatchingNodes(method.declarationSourceStart, method.declarationSourceEnd).length == 0) {
@@ -134,9 +128,8 @@ public void reportMatching(CompilationUnitDeclaration unit) throws CoreException
// move the potential matching nodes that exactly match the search pattern to the matching nodes set
for (Enumeration potentialMatches = this.potentialMatchingNodes.keys(); potentialMatches.hasMoreElements();) {
AstNode node = (AstNode) potentialMatches.nextElement();
- int level = this.locator.pattern.matchLevel(node, true);
- if (level == SearchPattern.ACCURATE_MATCH || level == SearchPattern.INACCURATE_MATCH) {
- this.matchingNodes.put(node, new Integer(level));
+ if (this.locator.pattern.matches(node)) {
+ this.matchingNodes.put(node, node);
}
}
this.potentialMatchingNodes = new Hashtable();
@@ -144,8 +137,8 @@ public void reportMatching(CompilationUnitDeclaration unit) throws CoreException
// package declaration
ImportReference pkg = unit.currentPackage;
- Integer level;
- if (pkg != null && (level = (Integer)this.matchingNodes.remove(pkg)) != null) {
+ if (pkg != null && this.matchingNodes.get(pkg) == pkg) {
+ this.matchingNodes.remove(pkg);
if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
this.locator.reportPackageDeclaration(pkg);
}
@@ -156,13 +149,10 @@ public void reportMatching(CompilationUnitDeclaration unit) throws CoreException
if (imports != null) {
for (int i = 0; i < imports.length; i++) {
ImportReference importRef = imports[i];
- if ((level = (Integer)this.matchingNodes.remove(importRef)) != null) {
+ if (this.matchingNodes.get(importRef) == importRef) {
+ this.matchingNodes.remove(importRef);
if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
- this.locator.reportImport(
- importRef,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportImport(importRef, this.accuracy);
}
}
}
@@ -173,14 +163,10 @@ public void reportMatching(CompilationUnitDeclaration unit) throws CoreException
if (types != null) {
for (int i = 0; i < types.length; i++) {
TypeDeclaration type = types[i];
- if ((level = (Integer)this.matchingNodes.remove(type)) != null) {
+ if (this.matchingNodes.get(type) == type) {
+ this.matchingNodes.remove(type);
if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
- this.locator.reportTypeDeclaration(
- type,
- new char[][] {type.name},
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportTypeDeclaration(type, new char[][] {type.name}, this.accuracy);
}
}
this.reportMatching(type, EMPTY_CHAR_CHAR);
@@ -196,16 +182,9 @@ private void reportMatching(FieldDeclaration field, char[][] definingTypeNames,
AstNode[] nodes = this.matchingNodes(field.declarationSourceStart, field.declarationSourceEnd);
for (int i = 0; i < nodes.length; i++) {
AstNode node = nodes[i];
- Integer level = (Integer)this.matchingNodes.remove(node);
+ this.matchingNodes.remove(node);
if ((this.matchContainer & SearchPattern.FIELD) != 0) {
- this.locator.reportReference(
- node,
- type,
- field,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportReference(node, type, field, definingTypeNames, this.accuracy);
}
}
}
@@ -216,21 +195,16 @@ private void reportMatching(FieldDeclaration field, char[][] definingTypeNames,
*/
private void reportMatching(TypeDeclaration type, char[][] enclosingTypeNames) throws CoreException {
char[][] definingTypeNames = CharOperation.arrayConcat(enclosingTypeNames, type.name);
- Integer level;
// fields
FieldDeclaration[] fields = type.fields;
if (fields != null) {
for (int i = 0; i < fields.length; i++) {
FieldDeclaration field = fields[i];
- if ((level = (Integer)this.matchingNodes.remove(field)) != null) {
+ if (this.matchingNodes.get(field) == field) {
+ this.matchingNodes.remove(field);
if ((this.matchContainer & SearchPattern.CLASS) != 0) {
- this.locator.reportFieldDeclaration(
- field,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportFieldDeclaration(field, definingTypeNames, this.accuracy);
}
}
this.reportMatching(field, definingTypeNames, type);
@@ -242,14 +216,10 @@ private void reportMatching(TypeDeclaration type, char[][] enclosingTypeNames) t
if (methods != null) {
for (int i = 0; i < methods.length; i++) {
AbstractMethodDeclaration method = methods[i];
- if ((level = (Integer)this.matchingNodes.remove(method)) != null) {
+ if (this.matchingNodes.get(method) == method) {
+ this.matchingNodes.remove(method);
if ((this.matchContainer & SearchPattern.CLASS) != 0) {
- this.locator.reportMethodDeclaration(
- method,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportMethodDeclaration(method, definingTypeNames, this.accuracy);
}
}
this.reportMatching(method, definingTypeNames);
@@ -261,15 +231,11 @@ private void reportMatching(TypeDeclaration type, char[][] enclosingTypeNames) t
if (memberTypes != null) {
for (int i = 0; i < memberTypes.length; i++) {
MemberTypeDeclaration memberType = memberTypes[i];
- if ((level = (Integer)this.matchingNodes.remove(memberType)) != null) {
+ if (this.matchingNodes.get(memberType) == memberType) {
+ this.matchingNodes.remove(memberType);
if ((this.matchContainer & SearchPattern.CLASS) != 0) {
char[][] memberTypeNames = CharOperation.arrayConcat(definingTypeNames, memberType.name);
- this.locator.reportTypeDeclaration(
- memberType,
- memberTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportTypeDeclaration(memberType, memberTypeNames, this.accuracy);
}
}
this.reportMatching(memberType, definingTypeNames);
@@ -278,28 +244,20 @@ private void reportMatching(TypeDeclaration type, char[][] enclosingTypeNames) t
// super types
TypeReference superClass = type.superclass;
- if (superClass != null && (level = (Integer)this.matchingNodes.remove(superClass)) != null) {
+ if (superClass != null && this.matchingNodes.get(superClass) == superClass) {
+ this.matchingNodes.remove(superClass);
if ((this.matchContainer & SearchPattern.CLASS) != 0) {
- this.locator.reportSuperTypeReference(
- superClass,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportSuperTypeReference(superClass, definingTypeNames, this.accuracy);
}
}
TypeReference[] superInterfaces = type.superInterfaces;
if (superInterfaces != null) {
for (int i = 0; i < superInterfaces.length; i++) {
TypeReference superInterface = superInterfaces[i];
- if ((level = (Integer)this.matchingNodes.get(superInterface)) != null) {
+ if (this.matchingNodes.get(superInterface) == superInterface) {
+ this.matchingNodes.remove(superInterface);
if ((this.matchContainer & SearchPattern.CLASS) != 0) {
- this.locator.reportSuperTypeReference(
- superInterface,
- definingTypeNames,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.locator.reportSuperTypeReference(superInterface, definingTypeNames, this.accuracy);
}
}
}
@@ -308,55 +266,17 @@ private void reportMatching(TypeDeclaration type, char[][] enclosingTypeNames) t
}
public String toString() {
StringBuffer result = new StringBuffer();
- result.append("Exact matches:"); //$NON-NLS-1$
+ result.append("Exact matches:"/*nonNLS*/);
for (Enumeration enum = this.matchingNodes.keys(); enum.hasMoreElements();) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
AstNode node = (AstNode)enum.nextElement();
- Object value = this.matchingNodes.get(node);
- if (value instanceof Integer) {
- result.append('\t');
- int accuracy = ((Integer)value).intValue();
- switch (accuracy) {
- case SearchPattern.IMPOSSIBLE_MATCH:
- result.append("IMPOSSIBLE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.POSSIBLE_MATCH:
- result.append("POSSIBLE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.INACCURATE_MATCH:
- result.append("INACCURATE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.ACCURATE_MATCH:
- result.append("ACCURATE_MATCH: "); //$NON-NLS-1$
- break;
- }
- }
- result.append(node.toString(0));
+ result.append(node.toString(1));
}
- result.append("\nPotential matches:"); //$NON-NLS-1$
+ result.append("\nPotential matches:"/*nonNLS*/);
for (Enumeration enum = this.potentialMatchingNodes.keys(); enum.hasMoreElements();) {
- result.append("\n"); //$NON-NLS-1$
+ result.append("\n"/*nonNLS*/);
AstNode node = (AstNode)enum.nextElement();
- Object value = this.potentialMatchingNodes.get(node);
- if (value instanceof Integer) {
- result.append("\t"); //$NON-NLS-1$
- int accuracy = ((Integer)value).intValue();
- switch (accuracy) {
- case SearchPattern.IMPOSSIBLE_MATCH:
- result.append("IMPOSSIBLE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.POSSIBLE_MATCH:
- result.append("POSSIBLE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.INACCURATE_MATCH:
- result.append("INACCURATE_MATCH: "); //$NON-NLS-1$
- break;
- case SearchPattern.ACCURATE_MATCH:
- result.append("ACCURATE_MATCH: "); //$NON-NLS-1$
- break;
- }
- }
- result.append(node.toString(0));
+ result.append(node.toString(1));
}
return result.toString();
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
index 462d7156b7..cb75308e1d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
@@ -70,7 +70,7 @@ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel,
}
}
public String getPatternName(){
- return "MethodDeclarationPattern: "; //$NON-NLS-1$
+ return "MethodDeclarationPattern: "/*nonNLS*/;
}
/**
* @see SearchPattern#indexEntryPrefix
@@ -90,149 +90,160 @@ protected int matchContainer() {
return CLASS;
}
/**
- * @see SearchPattern#matchesBinary(Object, Object)
+ * @see SearchPattern#matches(AstNode, boolean)
*/
-public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
- if (!(binaryInfo instanceof IBinaryMethod)) return false;
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof MethodDeclaration)) return false;
- IBinaryMethod method = (IBinaryMethod)binaryInfo;
+ MethodDeclaration method = (MethodDeclaration)node;
// selector
- if (!this.matchesName(this.selector, method.getSelector()))
+ if (!this.matchesName(this.selector, method.selector))
return false;
// declaring type
- IBinaryType declaringType = (IBinaryType)enclosingBinaryInfo;
- if (declaringType != null) {
- char[] declaringTypeName = (char[])declaringType.getName().clone();
- CharOperation.replace(declaringTypeName, '/', '.');
- if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringTypeName)) {
- return false;
+ MethodBinding binding = method.binding;
+ if (resolve && binding != null) {
+ ReferenceBinding declaringType = binding.declaringClass;
+ if (declaringType != null) {
+ if (!binding.isStatic() && !binding.isPrivate()) {
+ if (!this.matchesAsSubtype(declaringType, this.declaringSimpleName, this.declaringQualification))
+ return false;
+ } else {
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringType))
+ return false;
+ }
}
}
// return type
- String methodDescriptor = new String(method.getMethodDescriptor()).replace('/', '.');
- String returnTypeSignature = Signature.toString(Signature.getReturnType(methodDescriptor));
- if (!this.matchesType(this.returnSimpleName, this.returnQualification, returnTypeSignature.toCharArray())) {
- return false;
+ if (this.returnQualification == null) {
+ if (this.returnSimpleName != null) {
+ TypeReference methodReturnType = method.returnType;
+ if (methodReturnType != null) {
+ char[][] methodReturnTypeName = methodReturnType.getTypeName();
+ char[] sourceName = this.toArrayName(
+ methodReturnTypeName[methodReturnTypeName.length-1],
+ methodReturnType.dimensions());
+ if (!this.matchesName(this.returnSimpleName, sourceName))
+ return false;
+ }
+ }
+ } else {
+ if (resolve
+ && binding != null
+ && !this.matchesType(this.returnSimpleName, this.returnQualification, binding.returnType))
+ return false;
}
// parameter types
int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
if (parameterCount > -1) {
- String[] arguments = Signature.getParameterTypes(methodDescriptor);
- int argumentCount = arguments.length;
+ int argumentCount = method.arguments == null ? 0 : method.arguments.length;
if (parameterCount != argumentCount)
return false;
- for (int i = 0; i < parameterCount; i++) {
- char[] qualification = this.parameterQualifications[i];
- char[] type = this.parameterSimpleNames[i];
- if (!this.matchesType(type, qualification, Signature.toString(arguments[i]).toCharArray()))
- return false;
+
+ if (resolve && binding != null) {
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, binding.parameters[i]))
+ return false;
+ }
}
}
return true;
}
-
/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
+ * @see SearchPattern#matches(Binding)
*/
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof MethodDeclaration)) return IMPOSSIBLE_MATCH;
+public boolean matches(Binding binding) {
+ if (!(binding instanceof MethodBinding)) return false;
- MethodDeclaration method = (MethodDeclaration)node;
+ MethodBinding method = (MethodBinding)binding;
+
+ // selector
+ if (!this.matchesName(this.selector, method.selector))
+ return false;
- if (resolve) {
- return this.matchLevel(method.binding);
- } else {
- // selector
- if (!this.matchesName(this.selector, method.selector))
- return IMPOSSIBLE_MATCH;
-
- // return type
- TypeReference methodReturnType = method.returnType;
- if (methodReturnType != null) {
- char[][] methodReturnTypeName = methodReturnType.getTypeName();
- char[] sourceName = this.toArrayName(
- methodReturnTypeName[methodReturnTypeName.length-1],
- methodReturnType.dimensions());
- if (!this.matchesName(this.returnSimpleName, sourceName))
- return IMPOSSIBLE_MATCH;
- }
-
- // parameter types
- int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (parameterCount > -1) {
- int argumentCount = method.arguments == null ? 0 : method.arguments.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
+ // declaring type
+ ReferenceBinding declaringType = method.declaringClass;
+ if (declaringType != null) {
+ if (!method.isStatic() && !method.isPrivate()) {
+ if (!this.matchesAsSubtype(declaringType, this.declaringSimpleName, this.declaringQualification))
+ return false;
+ } else {
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringType))
+ return false;
}
+ }
- return POSSIBLE_MATCH;
+ // return type
+ if (!this.matchesType(this.returnSimpleName, this.returnQualification, method.returnType)) {
+ return false;
+ }
+
+ // parameter types
+ int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
+ if (parameterCount > -1) {
+ int argumentCount = method.parameters == null ? 0 : method.parameters.length;
+ if (parameterCount != argumentCount)
+ return false;
+ for (int i = 0; i < parameterCount; i++) {
+ char[] qualification = this.parameterQualifications[i];
+ char[] type = this.parameterSimpleNames[i];
+ if (!this.matchesType(type, qualification, method.parameters[i]))
+ return false;
+ }
}
-}
+ return true;
+}
/**
- * @see SearchPattern#matchLevel(Binding)
+ * @see SearchPattern#matchesBinary(Object, Object)
*/
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof MethodBinding)) return IMPOSSIBLE_MATCH;
- int level;
+public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
+ if (!(binaryInfo instanceof IBinaryMethod)) return false;
- MethodBinding method = (MethodBinding)binding;
+ IBinaryMethod method = (IBinaryMethod)binaryInfo;
// selector
- if (!this.matchesName(this.selector, method.selector))
- return IMPOSSIBLE_MATCH;
+ if (!this.matchesName(this.selector, method.getSelector()))
+ return false;
// declaring type
- ReferenceBinding declaringType = method.declaringClass;
- if (!method.isStatic() && !method.isPrivate()) {
- level = this.matchLevelAsSubtype(declaringType, this.declaringSimpleName, this.declaringQualification);
- } else {
- level = this.matchLevelForType(this.declaringSimpleName, this.declaringQualification, declaringType);
- }
- if (level == IMPOSSIBLE_MATCH) {
- return IMPOSSIBLE_MATCH;
+ IBinaryType declaringType = (IBinaryType)enclosingBinaryInfo;
+ if (declaringType != null) {
+ char[] declaringTypeName = (char[])declaringType.getName().clone();
+ CharOperation.replace(declaringTypeName, '/', '.');
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, declaringTypeName)) {
+ return false;
+ }
}
// return type
- int newLevel = this.matchLevelForType(this.returnSimpleName, this.returnQualification, method.returnType);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
+ String methodDescriptor = new String(method.getMethodDescriptor()).replace('/', '.');
+ String returnTypeSignature = Signature.toString(Signature.getReturnType(methodDescriptor));
+ if (!this.matchesType(this.returnSimpleName, this.returnQualification, returnTypeSignature.toCharArray())) {
+ return false;
}
// parameter types
int parameterCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
if (parameterCount > -1) {
- int argumentCount = method.parameters == null ? 0 : method.parameters.length;
+ String[] arguments = Signature.getParameterTypes(methodDescriptor);
+ int argumentCount = arguments.length;
if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
+ return false;
for (int i = 0; i < parameterCount; i++) {
char[] qualification = this.parameterQualifications[i];
char[] type = this.parameterSimpleNames[i];
- newLevel = this.matchLevelForType(type, qualification, method.parameters[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
+ if (!this.matchesType(type, qualification, Signature.toString(arguments[i]).toCharArray()))
+ return false;
}
}
- return level;
+ return true;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
index 5388e097cb..d1146efbd8 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
@@ -85,45 +85,45 @@ public String toString(){
if (declaringQualification != null) buffer.append(declaringQualification).append('.');
if (declaringSimpleName != null)
buffer.append(declaringSimpleName).append('.');
- else if (declaringQualification != null) buffer.append("*."); //$NON-NLS-1$
+ else if (declaringQualification != null) buffer.append("*."/*nonNLS*/);
if (selector != null) {
buffer.append(selector);
} else {
- buffer.append("*"); //$NON-NLS-1$
+ buffer.append("*"/*nonNLS*/);
}
buffer.append('(');
if (parameterSimpleNames == null) {
- buffer.append("..."); //$NON-NLS-1$
+ buffer.append("..."/*nonNLS*/);
} else {
for (int i = 0, max = parameterSimpleNames.length; i < max; i++){
- if (i > 0) buffer.append(", "); //$NON-NLS-1$
+ if (i > 0) buffer.append(", "/*nonNLS*/);
if (parameterQualifications[i] != null) buffer.append(parameterQualifications[i]).append('.');
if (parameterSimpleNames[i] == null) buffer.append('*'); else buffer.append(parameterSimpleNames[i]);
}
}
buffer.append(')');
if (returnQualification != null)
- buffer.append(" --> ").append(returnQualification).append('.'); //$NON-NLS-1$
- else if (returnSimpleName != null) buffer.append(" --> "); //$NON-NLS-1$
+ buffer.append(" --> "/*nonNLS*/).append(returnQualification).append('.');
+ else if (returnSimpleName != null) buffer.append(" --> "/*nonNLS*/);
if (returnSimpleName != null)
buffer.append(returnSimpleName);
- else if (returnQualification != null) buffer.append("*"); //$NON-NLS-1$
- buffer.append(", "); //$NON-NLS-1$
+ else if (returnQualification != null) buffer.append("*"/*nonNLS*/);
+ buffer.append(", "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
index 0b95a2c19e..03c11effa5 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
@@ -70,7 +70,7 @@ public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel,
}
}
public String getPatternName(){
- return "MethodReferencePattern: "; //$NON-NLS-1$
+ return "MethodReferencePattern: "/*nonNLS*/;
}
/**
* @see SearchPattern#indexEntryPrefix
@@ -84,120 +84,76 @@ public char[] indexEntryPrefix() {
isCaseSensitive);
}
/**
- * @see SearchPattern#matchContainer()
- */
-protected int matchContainer() {
- return METHOD | FIELD;
-}
-
-public boolean initializeFromLookupEnvironment(LookupEnvironment env) {
- this.allSuperDeclaringTypeNames = this.collectSuperTypeNames(this.declaringQualification, this.declaringSimpleName, this.matchMode, env);
- return this.allSuperDeclaringTypeNames == null || this.allSuperDeclaringTypeNames != NOT_FOUND_DECLARING_TYPE;
-}
-
-/**
* Returns whether the code gen will use an invoke virtual for
* this message send or not.
*/
-private boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) {
- return !method.isStatic() && !messageSend.isSuperAccess() && !method.isPrivate();
+private boolean isVirtualInvoke(MessageSend messageSend) {
+ return !messageSend.binding.isStatic() && !messageSend.isSuperAccess() && !messageSend.binding.isPrivate();
}
-
/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
+ * @see SearchPattern#matchContainer()
*/
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof MessageSend)) return IMPOSSIBLE_MATCH;
- MessageSend messageSend = (MessageSend)node;
-
- if (resolve) {
- return this.matchLevel(messageSend.binding, messageSend);
- } else {
- // selector
- if (this.selector != null && !this.matchesName(this.selector, messageSend.selector))
- return IMPOSSIBLE_MATCH;
-
- // argument types
- int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
- if (argumentCount > -1) {
- int parameterCount = messageSend.arguments == null ? 0 : messageSend.arguments.length;
- if (parameterCount != argumentCount)
- return IMPOSSIBLE_MATCH;
- }
-
- return POSSIBLE_MATCH;
- }
+protected int matchContainer() {
+ return METHOD | FIELD;
}
-
/**
- * @see SearchPattern#matchLevel(Binding)
+ * @see SearchPattern#matches(AstNode, boolean)
*/
-public int matchLevel(Binding binding, MessageSend messageSend) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof MethodBinding)) return IMPOSSIBLE_MATCH;
- int level;
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof MessageSend)) return false;
- MethodBinding method = (MethodBinding)binding;
+ MessageSend messageSend = (MessageSend)node;
// selector
- if (this.selector != null && !this.matchesName(this.selector, method.selector))
- return IMPOSSIBLE_MATCH;
+ if (this.selector != null && !this.matchesName(this.selector, messageSend.selector))
+ return false;
// receiver type
+ MethodBinding binding = messageSend.binding;
ReferenceBinding receiverType =
binding == null ?
null :
- (!isVirtualInvoke(method, messageSend) ? method.declaringClass : (ReferenceBinding)messageSend.receiverType);
- if (this.isVirtualInvoke(method, messageSend)) {
- level = this.matchLevelAsSubtype(receiverType, this.declaringSimpleName, this.declaringQualification);
- if (level == IMPOSSIBLE_MATCH) {
- level = this.matchLevelForType(this.allSuperDeclaringTypeNames, receiverType);
- if (level == IMPOSSIBLE_MATCH) {
- return IMPOSSIBLE_MATCH;
+ (!isVirtualInvoke(messageSend) ? binding.declaringClass : (ReferenceBinding)messageSend.receiverType);
+ if (resolve && receiverType != null) {
+ if (this.isVirtualInvoke(messageSend)) {
+ if (!this.matchesAsSubtype(receiverType, this.declaringSimpleName, this.declaringQualification)
+ && !this.matchesType(this.allSuperDeclaringTypeNames, receiverType)) {
+ return false;
}
+ } else {
+ if (!this.matchesType(this.declaringSimpleName, this.declaringQualification, receiverType))
+ return false;
}
- } else {
- level = this.matchLevelForType(this.declaringSimpleName, this.declaringQualification, receiverType);
- if (level == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH;
}
// return type
- int newLevel = this.matchLevelForType(this.returnSimpleName, this.returnQualification, method.returnType);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
+ if (resolve && binding != null) {
+ if (!this.matchesType(this.returnSimpleName, this.returnQualification, binding.returnType))
+ return false;
}
// argument types
int argumentCount = this.parameterSimpleNames == null ? -1 : this.parameterSimpleNames.length;
if (argumentCount > -1) {
- if (method.parameters == null) {
- level = INACCURATE_MATCH;
- } else {
- int parameterCount = method.parameters.length;
- if (parameterCount != argumentCount) return IMPOSSIBLE_MATCH;
+ int parameterCount = messageSend.arguments == null ? 0 : messageSend.arguments.length;
+ if (parameterCount != argumentCount)
+ return false;
+
+ if (resolve && binding != null) {
for (int i = 0; i < parameterCount; i++) {
char[] qualification = this.parameterQualifications[i];
char[] type = this.parameterSimpleNames[i];
- newLevel = this.matchLevelForType(type, qualification, method.parameters[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
+ if (!this.matchesType(type, qualification, binding.parameters[i]))
+ return false;
}
}
}
- return level;
+ return true;
+}
+
+public boolean initializeFromLookupEnvironment(LookupEnvironment env) {
+ this.allSuperDeclaringTypeNames = this.collectSuperTypeNames(this.declaringQualification, this.declaringSimpleName, this.matchMode, env);
+ return this.allSuperDeclaringTypeNames == null || this.allSuperDeclaringTypeNames != NOT_FOUND_DECLARING_TYPE;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
index 6976f87ce8..cf93522421 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
@@ -77,6 +77,18 @@ protected int matchContainer() {
| rightPattern.matchContainer();
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ return this.leftPattern.matches(node, resolve) || this.rightPattern.matches(node, resolve);
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ return this.leftPattern.matches(binding) || this.rightPattern.matches(binding);
+}
+/**
* see SearchPattern.matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -88,15 +100,14 @@ protected boolean matchIndexEntry() {
* @see SearchPattern#matchReportReference
*/
protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
- int leftLevel = this.leftPattern.matchLevel(reference, true);
- if (leftLevel == ACCURATE_MATCH || leftLevel == INACCURATE_MATCH) {
+ if (this.leftPattern.matches(reference)) {
this.leftPattern.matchReportReference(reference, element, accuracy, locator);
} else {
this.rightPattern.matchReportReference(reference, element, accuracy, locator);
}
}
public String toString(){
- return this.leftPattern.toString() + "\n| " + this.rightPattern.toString(); //$NON-NLS-1$
+ return this.leftPattern.toString() + "\n| "/*nonNLS*/ + this.rightPattern.toString();
}
/**
@@ -109,50 +120,4 @@ public boolean initializeFromLookupEnvironment(LookupEnvironment env) {
boolean rightInit = this.rightPattern.initializeFromLookupEnvironment(env);
return leftInit || rightInit;
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- switch (this.leftPattern.matchLevel(node, resolve)) {
- case IMPOSSIBLE_MATCH:
- return this.rightPattern.matchLevel(node, resolve);
- case POSSIBLE_MATCH:
- return POSSIBLE_MATCH;
- case INACCURATE_MATCH:
- int rightLevel = this.rightPattern.matchLevel(node, resolve);
- if (rightLevel != IMPOSSIBLE_MATCH) {
- return rightLevel;
- } else {
- return INACCURATE_MATCH;
- }
- case ACCURATE_MATCH:
- return ACCURATE_MATCH;
- default:
- return IMPOSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- switch (this.leftPattern.matchLevel(binding)) {
- case IMPOSSIBLE_MATCH:
- return this.rightPattern.matchLevel(binding);
- case POSSIBLE_MATCH:
- return POSSIBLE_MATCH;
- case INACCURATE_MATCH:
- int rightLevel = this.rightPattern.matchLevel(binding);
- if (rightLevel != IMPOSSIBLE_MATCH) {
- return rightLevel;
- } else {
- return INACCURATE_MATCH;
- }
- case ACCURATE_MATCH:
- return ACCURATE_MATCH;
- default:
- return IMPOSSIBLE_MATCH;
- }
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
index 2a44927b2f..4ed975732a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
@@ -51,6 +51,13 @@ protected int matchContainer() {
return 0;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ // used only in the case of a OrPattern
+ return true;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -59,32 +66,24 @@ protected boolean matchIndexEntry() {
}
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("PackageDeclarationPattern: <"); //$NON-NLS-1$
+ buffer.append("PackageDeclarationPattern: <"/*nonNLS*/);
if (this.pkgName != null) buffer.append(this.pkgName);
- buffer.append(">, "); //$NON-NLS-1$
+ buffer.append(">, "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- // used only in the case of a OrPattern
- return ACCURATE_MATCH;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
index 091c41c13b..cc402d86d4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
@@ -102,226 +102,168 @@ private boolean matches(char[][] tokens) {
return this.matchesName(this.pkgName, name);
}
/**
- * @see SearchPattern#matchIndexEntry
- */
-protected boolean matchIndexEntry() {
- switch(matchMode){
- case EXACT_MATCH :
- if (!CharOperation.equals(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
- return false;
- }
- break;
- case PREFIX_MATCH :
- if (!CharOperation.prefixEquals(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
- return false;
- }
- break;
- case PATTERN_MATCH :
- if (!CharOperation.match(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
- return false;
- }
- }
- return true;
-}
-/**
- * @see SearchPattern#matchReportReference
- */
-protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
- char[][] splitName = CharOperation.splitOn('.',
- this.pkgName == null ?
- new char[0] :
- this.pkgName);
- locator.reportQualifiedReference(reference.sourceStart, reference.sourceEnd, splitName, element, accuracy);
-}
-/**
- * @see AndPattern#resetQuery
+ * @see SearchPattern#matches(AstNode, boolean)
*/
-protected void resetQuery() {
- /* walk the segments from end to start as it will find less potential references using 'lang' than 'java' */
- this.currentSegment = this.segments.length - 1;
-}
-public String toString(){
- StringBuffer buffer = new StringBuffer(20);
- buffer.append("PackageReferencePattern: <"); //$NON-NLS-1$
- if (this.pkgName != null) buffer.append(this.pkgName);
- buffer.append(">, "); //$NON-NLS-1$
- switch(matchMode){
- case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
- break;
- case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
- break;
- case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
- break;
- }
- if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
- else
- buffer.append("case insensitive"); //$NON-NLS-1$
- return buffer.toString();
-}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
+protected boolean matches(AstNode node, boolean resolve) {
if (node instanceof QualifiedTypeReference) {
- return this.matchLevel((QualifiedTypeReference)node, resolve);
+ return this.matches((QualifiedTypeReference)node, resolve);
} else if (node instanceof ImportReference) {
- return this.matchLevel((ImportReference)node, resolve);
+ return this.matches((ImportReference)node, resolve);
} else if (node instanceof QualifiedNameReference) {
- return this.matchLevel((QualifiedNameReference)node, resolve);
+ return this.matches((QualifiedNameReference)node, resolve);
}
- return IMPOSSIBLE_MATCH;
+ return false;
}
-
/**
* Returns whether this package reference pattern matches the given import reference.
* Look at resolved information only if specified.
*/
-private int matchLevel(ImportReference importRef, boolean resolve) {
+private boolean matches(ImportReference importRef, boolean resolve) {
if (importRef.onDemand) {
- if (this.matches(importRef.tokens)) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
+ return this.matches(importRef.tokens);
} else {
int length = importRef.tokens.length - 1;
char[][] tokens = new char[length][];
System.arraycopy(importRef.tokens, 0, tokens, 0, length);
- if (this.matches(tokens)) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
+ return this.matches(tokens);
}
}
-
/**
* Returns whether this package reference pattern matches the given qualified name reference.
* Look at resolved information only if specified.
*/
-private int matchLevel(QualifiedNameReference qNameRef, boolean resolve) {
- if (!resolve) {
- if (this.pkgName == null) {
- return POSSIBLE_MATCH;
- } else {
+private boolean matches(QualifiedNameReference qNameRef, boolean resolve) {
+ Binding binding = qNameRef.binding;
+ if (!resolve || binding == null || !binding.isValidBinding()) {
+ if (this.pkgName != null) {
switch (this.matchMode) {
case EXACT_MATCH:
case PREFIX_MATCH:
- if (CharOperation.prefixEquals(this.pkgName, CharOperation.concatWith(qNameRef.tokens, '.'), this.isCaseSensitive)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
+ return CharOperation.prefixEquals(this.pkgName, CharOperation.concatWith(qNameRef.tokens, '.'), this.isCaseSensitive);
case PATTERN_MATCH:
- char[] pattern = this.pkgName[this.pkgName.length-1] == '*' ? this.pkgName : CharOperation.concat(this.pkgName, ".*".toCharArray()); //$NON-NLS-1$
- if (CharOperation.match(pattern, CharOperation.concatWith(qNameRef.tokens, '.'), this.isCaseSensitive)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- default:
- return IMPOSSIBLE_MATCH;
+ char[] pattern = this.pkgName[this.pkgName.length-1] == '*' ? this.pkgName : CharOperation.concat(this.pkgName, ".*"/*nonNLS*/.toCharArray());
+ return CharOperation.match(pattern, CharOperation.concatWith(qNameRef.tokens, '.'), this.isCaseSensitive);
}
}
} else {
- Binding binding = qNameRef.binding;
- if (binding == null) {
- return INACCURATE_MATCH;
- } else {
- TypeBinding typeBinding = null;
- char[][] tokens = qNameRef.tokens;
- int lastIndex = tokens.length-1;
- switch (qNameRef.bits & Statement.RestrictiveFlagMASK) {
- case BindingIds.FIELD : // reading a field
- typeBinding = ((FieldBinding)binding).declaringClass;
- // no valid match amongst fields
- int otherBindingsCount = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
- lastIndex -= otherBindingsCount + 1;
- if (lastIndex < 0) return IMPOSSIBLE_MATCH;
- break;
- case BindingIds.LOCAL : // reading a local variable
- return IMPOSSIBLE_MATCH; // no package match in it
- case BindingIds.TYPE : //=============only type ==============
- typeBinding = (TypeBinding)binding;
- }
- if (typeBinding instanceof ArrayBinding) {
- typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
- }
- if (typeBinding == null) {
- return INACCURATE_MATCH;
- } else {
- if (typeBinding instanceof ReferenceBinding) {
- PackageBinding pkgBinding = ((ReferenceBinding)typeBinding).fPackage;
- if (pkgBinding == null) {
- return INACCURATE_MATCH;
- } else if (this.matches(pkgBinding.compoundName)) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- } else {
- return IMPOSSIBLE_MATCH;
- }
- }
+ TypeBinding typeBinding = null;
+ char[][] tokens = qNameRef.tokens;
+ int lastIndex = tokens.length-1;
+ switch (qNameRef.bits & Statement.RestrictiveFlagMASK) {
+ case BindingIds.FIELD : // reading a field
+ typeBinding = ((FieldBinding)binding).declaringClass;
+ // no valid match amongst fields
+ int otherBindingsCount = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
+ lastIndex -= otherBindingsCount + 1;
+ if (lastIndex < 0) return false;
+ break;
+ case BindingIds.LOCAL : // reading a local variable
+ return false; // no package match in it
+ case BindingIds.TYPE : //=============only type ==============
+ typeBinding = (TypeBinding)binding;
+ }
+ if (typeBinding instanceof ArrayBinding) {
+ typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
}
+ if (typeBinding instanceof ReferenceBinding) {
+ PackageBinding pkgBinding = ((ReferenceBinding)typeBinding).fPackage;
+ return this.matches(pkgBinding.compoundName);
+ }
+ return false;
}
+ return true;
}
-
/**
* Returns whether this package reference pattern matches the given type reference.
* Look at resolved information only if specified.
*/
-private int matchLevel(QualifiedTypeReference typeRef, boolean resolve) {
+private boolean matches(QualifiedTypeReference typeRef, boolean resolve) {
if (!resolve) {
- if (this.pkgName == null) {
- return POSSIBLE_MATCH;
- } else {
+ if (this.pkgName != null) {
switch (this.matchMode) {
case EXACT_MATCH:
case PREFIX_MATCH:
- if (CharOperation.prefixEquals(this.pkgName, CharOperation.concatWith(typeRef.tokens, '.'), this.isCaseSensitive)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
+ return CharOperation.prefixEquals(this.pkgName, CharOperation.concatWith(typeRef.tokens, '.'), this.isCaseSensitive);
case PATTERN_MATCH:
- char[] pattern = this.pkgName[this.pkgName.length-1] == '*' ? this.pkgName : CharOperation.concat(this.pkgName, ".*".toCharArray()); //$NON-NLS-1$
- if (CharOperation.match(pattern, CharOperation.concatWith(typeRef.tokens, '.'), this.isCaseSensitive)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- default:
- return IMPOSSIBLE_MATCH;
+ char[] pattern = this.pkgName[this.pkgName.length-1] == '*' ? this.pkgName : CharOperation.concat(this.pkgName, ".*"/*nonNLS*/.toCharArray());
+ return CharOperation.match(pattern, CharOperation.concatWith(typeRef.tokens, '.'), this.isCaseSensitive);
}
}
} else {
TypeBinding typeBinding = typeRef.binding;
- if (typeBinding == null) {
- return INACCURATE_MATCH;
- } else {
+ if (typeBinding != null){
if (typeBinding instanceof ArrayBinding) {
typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
}
- if (typeBinding == null) {
- return INACCURATE_MATCH;
- } else if (typeBinding instanceof ReferenceBinding) {
+ if (typeBinding instanceof ReferenceBinding) {
PackageBinding pkgBinding = ((ReferenceBinding)typeBinding).fPackage;
- if (this.matches(pkgBinding.compoundName)) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- } else {
- return IMPOSSIBLE_MATCH;
+ return this.matches(pkgBinding.compoundName);
}
+ return false;
}
}
+ return true;
+}
+/**
+ * @see SearchPattern#matchIndexEntry
+ */
+protected boolean matchIndexEntry() {
+ switch(matchMode){
+ case EXACT_MATCH :
+ if (!CharOperation.equals(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
+ return false;
+ }
+ break;
+ case PREFIX_MATCH :
+ if (!CharOperation.prefixEquals(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
+ return false;
+ }
+ break;
+ case PATTERN_MATCH :
+ if (!CharOperation.match(this.segments[this.currentSegment], this.decodedSegment, isCaseSensitive)){
+ return false;
+ }
+ }
+ return true;
+}
+/**
+ * @see SearchPattern#matchReportReference
+ */
+protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
+ char[][] splitName = CharOperation.splitOn('.',
+ this.pkgName == null ?
+ new char[0] :
+ this.pkgName);
+ locator.reportQualifiedReference(reference.sourceStart, reference.sourceEnd, splitName, element, accuracy);
+}
+/**
+ * @see AndPattern#resetQuery
+ */
+protected void resetQuery() {
+ /* walk the segments from end to start as it will find less potential references using 'lang' than 'java' */
+ this.currentSegment = this.segments.length - 1;
+}
+public String toString(){
+ StringBuffer buffer = new StringBuffer(20);
+ buffer.append("PackageReferencePattern: <"/*nonNLS*/);
+ if (this.pkgName != null) buffer.append(this.pkgName);
+ buffer.append(">, "/*nonNLS*/);
+ switch(matchMode){
+ case EXACT_MATCH :
+ buffer.append("exact match, "/*nonNLS*/);
+ break;
+ case PREFIX_MATCH :
+ buffer.append("prefix match, "/*nonNLS*/);
+ break;
+ case PATTERN_MATCH :
+ buffer.append("pattern match, "/*nonNLS*/);
+ break;
+ }
+ if (isCaseSensitive)
+ buffer.append("case sensitive"/*nonNLS*/);
+ else
+ buffer.append("case insensitive"/*nonNLS*/);
+ return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java
deleted file mode 100644
index c5537fae60..0000000000
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java
+++ /dev/null
@@ -1,309 +0,0 @@
-package org.eclipse.jdt.internal.core.search.matching;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.core.*;
-
-import java.io.*;
-import java.util.zip.ZipFile;
-
-public class PotentialMatch {
- private MatchLocator locator;
- public IResource resource;
- public Openable openable;
- private CompilationUnitDeclaration parsedUnit;
- private MatchSet matchSet;
-public PotentialMatch(MatchLocator locator, IResource resource, Openable openable) {
- this.locator = locator;
- this.resource = resource;
- this.openable = openable;
- if (openable instanceof CompilationUnit) {
- this.buildTypeBindings();
- }
-}
-private void buildTypeBindings() {
- // get main type name
- String fileName = this.resource.getFullPath().lastSegment();
- // remove extension ".java"
- final char[] mainTypeName = fileName.substring(0, fileName.length()-5).toCharArray();
-
- // get qualified name
- CompilationUnit cu = (CompilationUnit)this.openable;
- char[] qualifiedName = cu.getType(new String(mainTypeName)).getFullyQualifiedName().toCharArray();
-
- // create match set
- this.matchSet = new MatchSet(this.locator);
- this.locator.parser.matchSet = this.matchSet;
-
- this.parsedUnit = (CompilationUnitDeclaration)this.locator.parsedUnits.get(qualifiedName);
- if (this.parsedUnit == null) {
- // get source
- final char[] source = this.getSource();
-
- // source unit
- ICompilationUnit sourceUnit = new ICompilationUnit() {
- public char[] getContents() {
- return source;
- }
- public char[] getFileName() {
- return PotentialMatch.this.resource.getName().toCharArray();
- }
- public char[] getMainTypeName() {
- return mainTypeName;
- }
- };
-
- // diet parse
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0);
- this.parsedUnit = this.locator.parser.dietParse(sourceUnit, compilationResult);
-
- // initial type binding creation
- this.locator.lookupEnvironment.buildTypeBindings(this.parsedUnit);
- } else {
- // free memory
- this.locator.parsedUnits.put(qualifiedName, null);
- }
-}
-public static char[] getContents(IFile file) {
- BufferedInputStream input = null;
- try {
- input = new BufferedInputStream(file.getContents(true));
- StringBuffer buffer= new StringBuffer();
- int nextChar = input.read();
- while (nextChar != -1) {
- buffer.append( (char)nextChar );
- nextChar = input.read();
- }
- int length = buffer.length();
- char[] result = new char[length];
- buffer.getChars(0, length, result, 0);
- return result;
- } catch (IOException e) {
- return null;
- } catch (CoreException e) {
- return null;
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- // nothing can be done if the file cannot be closed
- }
- }
- }
-}
-public char[] getSource() {
- return getContents((IFile)this.resource);
-}
-public void locateMatches() throws CoreException {
- if (this.openable instanceof CompilationUnit) {
- this.locateMatchesInCompilationUnit();
- } else if (this.openable instanceof org.eclipse.jdt.internal.core.ClassFile) {
- this.locateMatchesInClassFile();
- }
-}
-/**
- * Locate declaration in the current class file. This class file is always in a jar.
- */
-private void locateMatchesInClassFile() throws CoreException, JavaModelException {
- org.eclipse.jdt.internal.core.ClassFile classFile = (org.eclipse.jdt.internal.core.ClassFile)this.openable;
- BinaryType binaryType = (BinaryType)classFile.getType();
- IBinaryType info;
- if (classFile.isOpen()) {
- // reuse the info from the java model cache
- info = (IBinaryType)binaryType.getRawInfo();
- } else {
- // create a temporary info
- try {
- IJavaElement pkg = classFile.getParent();
- PackageFragmentRoot root = (PackageFragmentRoot)pkg.getParent();
- if (root.isArchive()) {
- // class file in a jar
- String pkgPath = pkg.getElementName().replace('.', '/');
- String classFilePath =
- (pkgPath.length() > 0) ?
- pkgPath + "/" + classFile.getElementName() : //$NON-NLS-1$
- classFile.getElementName();
- ZipFile zipFile = null;
- try {
- zipFile = ((JarPackageFragmentRoot)root).getJar();
- info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(
- zipFile,
- classFilePath);
- } finally {
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- } else {
- // class file in a directory
- String osPath = this.resource.getFullPath().toOSString();
- info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(osPath);
- }
- } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) {
- e.printStackTrace();
- return;
- } catch (java.io.IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- }
-
- }
-
- // check class definition
- if (this.locator.pattern.matchesBinary(info, null)) {
- this.locator.reportBinaryMatch(binaryType, info, IJavaSearchResultCollector.EXACT_MATCH);
- }
-
- boolean compilationAborted = false;
- if (this.locator.pattern.needsResolve) {
- // resolve
- BinaryTypeBinding binding = null;
- try {
- binding = this.locator.lookupEnvironment.cacheBinaryType(info);
- if (binding == null) { // it was already cached as a result of a previous query
- char[][] compoundName = CharOperation.splitOn('.', binaryType.getFullyQualifiedName().toCharArray());
- ReferenceBinding referenceBinding = this.locator.lookupEnvironment.getCachedType(compoundName);
- if (referenceBinding != null && (referenceBinding instanceof BinaryTypeBinding)) {
- // if the binding could be found and if it comes from a source type,
- binding = (BinaryTypeBinding)referenceBinding;
- }
- }
-
- // check methods
- if (binding != null) {
- MethodBinding[] methods = binding.methods();
- for (int i = 0; i < methods.length; i++) {
- MethodBinding method = methods[i];
- int level = this.locator.pattern.matchLevel(method);
- if (level != SearchPattern.IMPOSSIBLE_MATCH) {
- IMethod methodHandle =
- binaryType.getMethod(
- new String(method.isConstructor() ? binding.compoundName[binding.compoundName.length-1] : method.selector),
- Signature.getParameterTypes(new String(method.signature()).replace('/', '.'))
- );
- this.locator.reportBinaryMatch(
- methodHandle,
- info,
- level == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
- }
- }
- }
-
- // check fields
- if (binding != null) {
- FieldBinding[] fields = binding.fields();
- for (int i = 0; i < fields.length; i++) {
- FieldBinding field = fields[i];
- int level = this.locator.pattern.matchLevel(field);
- if (level != SearchPattern.IMPOSSIBLE_MATCH) {
- IField fieldHandle = binaryType.getField(new String(field.name));
- this.locator.reportBinaryMatch(
- fieldHandle,
- info,
- level == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
- }
- }
- }
- } catch (AbortCompilation e) {
- binding = null;
- }
-
- // no need to check binary info if resolve was successful
- compilationAborted = binding == null;
- if (!compilationAborted) return;
- }
-
- // if compilation was aborted it is a problem with the class path:
- // report as a potential match if binary info matches the pattern
- int accuracy = compilationAborted ? IJavaSearchResultCollector.POTENTIAL_MATCH : IJavaSearchResultCollector.EXACT_MATCH;
-
- // check methods
- IBinaryMethod[] methods = info.getMethods();
- int length = methods == null ? 0 : methods.length;
- for (int i = 0; i < length; i++) {
- IBinaryMethod method = methods[i];
- if (this.locator.pattern.matchesBinary(method, info)) {
- IMethod methodHandle =
- binaryType.getMethod(
- new String(method.isConstructor() ? info.getName() : method.getSelector()),
- Signature.getParameterTypes(new String(method.getMethodDescriptor()).replace('/', '.'))
- );
- this.locator.reportBinaryMatch(methodHandle, info, accuracy);
- }
- }
-
- // check fields
- IBinaryField[] fields = info.getFields();
- length = fields == null ? 0 : fields.length;
- for (int i = 0; i < length; i++) {
- IBinaryField field = fields[i];
- if (this.locator.pattern.matchesBinary(field, info)) {
- IField fieldHandle = binaryType.getField(new String(field.getName()));
- this.locator.reportBinaryMatch(fieldHandle, info, accuracy);
- }
- }
-}
-private void locateMatchesInCompilationUnit() throws CoreException {
- if (this.parsedUnit != null) {
- this.locator.parser.matchSet = this.matchSet;
- this.locator.parser.scanner.setSourceBuffer(this.getSource());
- this.locator.parser.parseBodies(this.parsedUnit);
- // report matches that don't need resolve
- this.matchSet.cuHasBeenResolved = false;
- this.matchSet.accuracy = IJavaSearchResultCollector.EXACT_MATCH;
- this.matchSet.reportMatching(parsedUnit);
-
- // resolve if needed
- if (this.matchSet.needsResolve()) {
- if (this.parsedUnit.types != null) {
- try {
- if (this.parsedUnit.scope != null) {
- this.parsedUnit.scope.faultInTypes();
- this.parsedUnit.resolve();
- }
- // report matches that needed resolve
- this.matchSet.cuHasBeenResolved = true;
- this.matchSet.accuracy = IJavaSearchResultCollector.EXACT_MATCH;
- this.matchSet.reportMatching(this.parsedUnit);
- } catch (AbortCompilation e) {
- // could not resolve (reasons include "could not find library class") -> ignore and report the unresolved nodes
- this.matchSet.cuHasBeenResolved = false;
- this.matchSet.accuracy = IJavaSearchResultCollector.POTENTIAL_MATCH;
- this.matchSet.reportMatching(this.parsedUnit);
- }
- }
- }
- }
-}
-/**
- * Free memory.
- */
-public void reset() {
- this.parsedUnit = null;
- this.matchSet = null;
-}
-public String toString() {
- return this.openable.toString();
-}
-}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
index c822dd014b..491bb23c81 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
@@ -33,14 +33,14 @@ public abstract class SearchPattern implements ISearchPattern, IIndexConstants,
/* match level */
public static final int IMPOSSIBLE_MATCH = 0;
public static final int POSSIBLE_MATCH = 1;
+ public static final int TRUSTED_MATCH = 2;
+
/* match container */
public static final int COMPILATION_UNIT = 1;
public static final int CLASS = 2;
public static final int FIELD = 4;
public static final int METHOD = 8;
- public static final int ACCURATE_MATCH = 2;
- public static final int INACCURATE_MATCH = 3;
public static final char[][][] NOT_FOUND_DECLARING_TYPE = new char[0][][];
public SearchPattern(int matchMode, boolean isCaseSensitive) {
@@ -54,7 +54,7 @@ public SearchPattern(int matchMode, boolean isCaseSensitive) {
*/
private static SearchPattern createConstructorPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)", true); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)"/*nonNLS*/, true);
final int InsideName = 1;
final int InsideParameter = 2;
String lastToken = null;
@@ -71,7 +71,7 @@ private static SearchPattern createConstructorPattern(String patternString, int
// read declaring type and selector
case InsideName :
- if (token.equals(".")){ //$NON-NLS-1$
+ if (token.equals("."/*nonNLS*/)){
if (declaringQualification == null){
if (typeName == null) return null;
declaringQualification = typeName;
@@ -79,12 +79,12 @@ private static SearchPattern createConstructorPattern(String patternString, int
declaringQualification += token + typeName;
}
typeName = null;
- } else if (token.equals("(")){ //$NON-NLS-1$
+ } else if (token.equals("("/*nonNLS*/)){
parameterTypes = new String[5];
parameterCount = 0;
mode = InsideParameter;
- } else if (token.equals(" ")){ //$NON-NLS-1$
- if (!(" ".equals(lastToken) || ".".equals(lastToken))){ //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (token.equals(" "/*nonNLS*/)){
+ if (!(" "/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(lastToken))){
break;
}
} else { // name
@@ -94,15 +94,15 @@ private static SearchPattern createConstructorPattern(String patternString, int
break;
// read parameter types
case InsideParameter :
- if (token.equals(" ")){ //$NON-NLS-1$
- } else if (token.equals(",")){ //$NON-NLS-1$
+ if (token.equals(" "/*nonNLS*/)){
+ } else if (token.equals(","/*nonNLS*/)){
if (parameterType == null) return null;
if (parameterTypes.length == parameterCount){
System.arraycopy(parameterTypes, 0, parameterTypes = new String[parameterCount*2], 0, parameterCount);
}
parameterTypes[parameterCount++] = parameterType;
parameterType = null;
- } else if (token.equals (")")){ //$NON-NLS-1$
+ } else if (token.equals (")"/*nonNLS*/)){
foundClosingParenthesis = true;
if (parameterType != null){
if (parameterTypes.length == parameterCount){
@@ -115,7 +115,7 @@ private static SearchPattern createConstructorPattern(String patternString, int
if (parameterType == null){
parameterType = token;
} else {
- if (!(".".equals(lastToken) || ".".equals(token) || "[]".equals(token))) return null; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (!("."/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(token) || "[]"/*nonNLS*/.equals(token))) return null;
parameterType += token;
}
}
@@ -176,7 +176,7 @@ private static SearchPattern createConstructorPattern(String patternString, int
*/
private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)", true); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)"/*nonNLS*/, true);
final int InsideDeclaringPart = 1;
final int InsideType = 2;
String lastToken = null;
@@ -191,7 +191,7 @@ private static SearchPattern createFieldPattern(String patternString, int limitT
// read declaring type and fieldName
case InsideDeclaringPart :
- if (token.equals(".")){ //$NON-NLS-1$
+ if (token.equals("."/*nonNLS*/)){
if (declaringType == null){
if (fieldName == null) return null;
declaringType = fieldName;
@@ -199,8 +199,8 @@ private static SearchPattern createFieldPattern(String patternString, int limitT
declaringType += token + fieldName;
}
fieldName = null;
- } else if (token.equals(" ")){ //$NON-NLS-1$
- if (!(" ".equals(lastToken) || ".".equals(lastToken))){ //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (token.equals(" "/*nonNLS*/)){
+ if (!(" "/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(lastToken))){
mode = InsideType;
}
} else { // name
@@ -210,11 +210,11 @@ private static SearchPattern createFieldPattern(String patternString, int limitT
break;
// read type
case InsideType:
- if (!token.equals(" ")){ //$NON-NLS-1$
+ if (!token.equals(" "/*nonNLS*/)){
if (type == null){
type = token;
} else {
- if (!(!(".".equals(lastToken) || ".".equals(token) || "[]".equals(token)))) return null; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (!(!("."/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(token) || "[]"/*nonNLS*/.equals(token)))) return null;
type += token;
}
}
@@ -281,7 +281,7 @@ private static SearchPattern createFieldPattern(String patternString, int limitT
*/
private static SearchPattern createMethodPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)", true); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(patternString, " .(,)"/*nonNLS*/, true);
final int InsideSelector = 1;
final int InsideParameter = 2;
final int InsideReturnType = 3;
@@ -299,7 +299,7 @@ private static SearchPattern createMethodPattern(String patternString, int limit
// read declaring type and selector
case InsideSelector :
- if (token.equals(".")){ //$NON-NLS-1$
+ if (token.equals("."/*nonNLS*/)){
if (declaringType == null){
if (selector == null) return null;
declaringType = selector;
@@ -307,12 +307,12 @@ private static SearchPattern createMethodPattern(String patternString, int limit
declaringType += token + selector;
}
selector = null;
- } else if (token.equals("(")){ //$NON-NLS-1$
+ } else if (token.equals("("/*nonNLS*/)){
parameterTypes = new String[5];
parameterCount = 0;
mode = InsideParameter;
- } else if (token.equals(" ")){ //$NON-NLS-1$
- if (!(" ".equals(lastToken) || ".".equals(lastToken))){ //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (token.equals(" "/*nonNLS*/)){
+ if (!(" "/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(lastToken))){
mode = InsideReturnType;
}
} else { // name
@@ -322,15 +322,15 @@ private static SearchPattern createMethodPattern(String patternString, int limit
break;
// read parameter types
case InsideParameter :
- if (token.equals(" ")){ //$NON-NLS-1$
- } else if (token.equals(",")){ //$NON-NLS-1$
+ if (token.equals(" "/*nonNLS*/)){
+ } else if (token.equals(","/*nonNLS*/)){
if (parameterType == null) return null;
if (parameterTypes.length == parameterCount){
System.arraycopy(parameterTypes, 0, parameterTypes = new String[parameterCount*2], 0, parameterCount);
}
parameterTypes[parameterCount++] = parameterType;
parameterType = null;
- } else if (token.equals (")")){ //$NON-NLS-1$
+ } else if (token.equals (")"/*nonNLS*/)){
foundClosingParenthesis = true;
if (parameterType != null){
if (parameterTypes.length == parameterCount){
@@ -343,18 +343,18 @@ private static SearchPattern createMethodPattern(String patternString, int limit
if (parameterType == null){
parameterType = token;
} else {
- if (!(".".equals(lastToken) || ".".equals(token) || "[]".equals(token))) return null; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (!("."/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(token) || "[]"/*nonNLS*/.equals(token))) return null;
parameterType += token;
}
}
break;
// read return type
case InsideReturnType:
- if (!token.equals(" ")){ //$NON-NLS-1$
+ if (!token.equals(" "/*nonNLS*/)){
if (returnType == null){
returnType = token;
} else {
- if (!(!(".".equals(lastToken) || ".".equals(token) || "[]".equals(token)))) return null; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (!(!("."/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(token) || "[]"/*nonNLS*/.equals(token)))) return null;
returnType += token;
}
}
@@ -643,16 +643,16 @@ private static SearchPattern createTypePattern(String fullyQualifiedName, int li
*/
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- StringTokenizer tokenizer = new StringTokenizer(patternString, " .", true); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(patternString, " ."/*nonNLS*/, true);
String type = null;
String lastToken = null;
while (tokenizer.hasMoreTokens()){
String token = tokenizer.nextToken();
- if (!token.equals(" ")){ //$NON-NLS-1$
+ if (!token.equals(" "/*nonNLS*/)){
if (type == null){
type = token;
} else {
- if (!(".".equals(lastToken) || ".".equals(token) || "[]".equals(token))) return null; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (!("."/*nonNLS*/.equals(lastToken) || "."/*nonNLS*/.equals(token) || "[]"/*nonNLS*/.equals(token))) return null;
type += token;
}
}
@@ -753,6 +753,24 @@ public abstract char[] indexEntryPrefix();
*/
protected abstract int matchContainer();
/**
+ * Finds out whether the given resolved ast node matches this search pattern.
+ */
+public boolean matches(AstNode node) {
+ return this.matches(node, true);
+}
+/**
+ * Returns whether this pattern matches the given node.
+ * Look at resolved information only if specified.
+ */
+protected abstract boolean matches(AstNode node, boolean resolve);
+/**
+ * Finds out whether the given binding matches this search pattern.
+ * Default is to return false.
+ */
+public boolean matches(Binding binding) {
+ return false;
+}
+/**
* Finds out whether the given binary info matches this search pattern.
* Default is to return false.
*/
@@ -802,10 +820,43 @@ protected boolean matchesType(char[] simpleNamePattern, char[] qualificationPatt
);
}
/**
+ * Returns whether the given type binding matches the given simple name pattern
+ * and qualification pattern.
+ */
+protected boolean matchesType(char[] simpleNamePattern, char[] qualificationPattern, TypeBinding type) {
+ if (type == null) return false;
+ return
+ this.matchesType(
+ simpleNamePattern,
+ qualificationPattern,
+ type.qualifiedPackageName().length == 0 ?
+ type.qualifiedSourceName() :
+ CharOperation.concat(type.qualifiedPackageName(), type.qualifiedSourceName(), '.')
+ );
+}
+/**
* Checks whether an entry matches the current search pattern
*/
protected abstract boolean matchIndexEntry();
/**
+ * Finds out whether the given ast node matches this search pattern.
+ * Returns IMPOSSIBLE_MATCH if it doesn't.
+ * Returns TRUSTED_MATCH if it matches exactly this search pattern (ie.
+ * it doesn't need to be resolved or it has already been resolved.)
+ * Returns POSSIBLE_MATCH if it potentially matches
+ * this search pattern and it needs to be resolved to get more information.
+ */
+public int matchLevel(AstNode node) {
+ if (this.matches(node, false)) {
+ if (this.needsResolve) {
+ return POSSIBLE_MATCH;
+ } else {
+ return TRUSTED_MATCH;
+ }
+ }
+ return IMPOSSIBLE_MATCH;
+}
+/**
* Reports the match of the given reference.
*/
protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
@@ -825,7 +876,7 @@ protected char[] toArrayName(char[] simpleName, int dimensions) {
return result;
}
public String toString(){
- return "SearchPattern"; //$NON-NLS-1$
+ return "SearchPattern"/*nonNLS*/;
}
/**
@@ -923,103 +974,44 @@ public boolean initializeFromLookupEnvironment(LookupEnvironment env) {
}
/**
- * Finds out whether the given ast node matches this search pattern.
- * Returns IMPOSSIBLE_MATCH if it doesn't.
- * Returns POSSIBLE_MATCH if it potentially matches this search pattern
- * and it has not been reolved, and it needs to be resolved to get more information.
- * Returns ACCURATE_MATCH if it matches exactly this search pattern (ie.
- * it doesn't need to be resolved or it has already been resolved.)
- * Returns INACCURATE_MATCH if it potentially exactly this search pattern (ie.
- * it has already been resolved but resolving failed.)
- */
-public abstract int matchLevel(AstNode node, boolean resolve);
-
-/**
- * Finds out whether the given binding matches this search pattern.
- * Returns ACCURATE_MATCH if it does.
- * Returns INACCURATE_MATCH if resolve failed.
- * Default is to return INACCURATE_MATCH.
- */
-public int matchLevel(Binding binding) {
- return INACCURATE_MATCH;
-}
-
-/**
* Returns whether the given reference type binding matches or is a subtype of a type
* that matches the given simple name pattern and qualification pattern.
- * Returns ACCURATE_MATCH if it does.
- * Returns INACCURATE_MATCH if resolve fails
- * Returns IMPOSSIBLE_MATCH if it doesn't.
*/
-protected int matchLevelAsSubtype(ReferenceBinding type, char[] simpleNamePattern, char[] qualificationPattern) {
- if (type == null) return INACCURATE_MATCH;
-
- int level;
-
+protected boolean matchesAsSubtype(ReferenceBinding type, char[] simpleNamePattern, char[] qualificationPattern) {
// matches type
- if ((level = this.matchLevelForType(simpleNamePattern, qualificationPattern, type)) != IMPOSSIBLE_MATCH)
- return level;
+ if (this.matchesType(simpleNamePattern, qualificationPattern, type))
+ return true;
// matches superclass
- if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) {
- if ((level = this.matchLevelAsSubtype(type.superclass(), simpleNamePattern, qualificationPattern)) != IMPOSSIBLE_MATCH) {
- return level;
- }
+ ReferenceBinding superclass = type.superclass();
+ if (superclass != null) {
+ if (this.matchesAsSubtype(superclass, simpleNamePattern, qualificationPattern))
+ return true;
}
// matches interfaces
ReferenceBinding[] interfaces = type.superInterfaces();
- if (interfaces == null) {
- return INACCURATE_MATCH;
- } else {
- for (int i = 0; i < interfaces.length; i++) {
- if ((level = this.matchLevelAsSubtype(interfaces[i], simpleNamePattern, qualificationPattern)) != IMPOSSIBLE_MATCH) {
- return level;
- };
- }
+ for (int i = 0; i < interfaces.length; i++) {
+ if (this.matchesAsSubtype(interfaces[i], simpleNamePattern, qualificationPattern))
+ return true;
}
- return IMPOSSIBLE_MATCH;
+ return false;
}
/**
* Returns whether one of the given declaring types is the given receiver type.
- * Returns ACCURATE_MATCH if it does.
- * Returns INACCURATE_MATCH if resolve failed.
- * Returns IMPOSSIBLE_MATCH if it doesn't.
*/
-protected int matchLevelForType(char[][][] declaringTypes, ReferenceBinding receiverType) {
- if (receiverType == null) return INACCURATE_MATCH;
+protected boolean matchesType(char[][][] declaringTypes, ReferenceBinding receiverType) {
if (declaringTypes == null) {
- return INACCURATE_MATCH; // we were not able to compute the declaring types, default to inaccurate
+ return true; // we were not able to compute the declaring types, default to true
} else {
for (int i = 0, max = declaringTypes.length; i < max; i++) {
if (CharOperation.equals(declaringTypes[i], receiverType.compoundName)) {
- return ACCURATE_MATCH;
+ return true;
}
}
- return IMPOSSIBLE_MATCH;
- }
-}
-
-/**
- * Returns whether the given type binding matches the given simple name pattern
- * and qualification pattern.
- * Returns ACCURATE_MATCH if it does.
- * Returns INACCURATE_MATCH if resolve failed.
- * Returns IMPOSSIBLE_MATCH if it doesn't.
- */
-protected int matchLevelForType(char[] simpleNamePattern, char[] qualificationPattern, TypeBinding type) {
- if (type == null) return INACCURATE_MATCH;
- if (this.matchesType(
- simpleNamePattern,
- qualificationPattern,
- type.qualifiedPackageName().length == 0 ?
- type.qualifiedSourceName() :
- CharOperation.concat(type.qualifiedPackageName(), type.qualifiedSourceName(), '.'))) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
+ return false;
}
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
index 68caa7ce95..f4902c3894 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
@@ -15,6 +15,20 @@ public SuperInterfaceReferencePattern(char[] superQualification, char[] superSim
super(superQualification, superSimpleName, matchMode, isCaseSensitive);
}
/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof ReferenceBinding)) return false;
+
+ ReferenceBinding[] superInterfaces = ((ReferenceBinding)binding).superInterfaces();
+ for (int i = 0, max = superInterfaces.length; i < max; i++){
+ if (this.matchesType(this.superSimpleName, this.superQualification, superInterfaces[i])){
+ return true;
+ }
+ }
+ return false;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -24,24 +38,24 @@ protected boolean matchIndexEntry() {
}
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("SuperInterfaceReferencePattern: <"); //$NON-NLS-1$
+ buffer.append("SuperInterfaceReferencePattern: <"/*nonNLS*/);
if (superSimpleName != null) buffer.append(superSimpleName);
- buffer.append(">, "); //$NON-NLS-1$
+ buffer.append(">, "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
@@ -64,30 +78,4 @@ public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
}
return false;
}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof ReferenceBinding)) return IMPOSSIBLE_MATCH;
-
- // super interfaces
- int level = IMPOSSIBLE_MATCH;
- ReferenceBinding type = (ReferenceBinding) binding;
- ReferenceBinding[] superInterfaces = type.superInterfaces();
- for (int i = 0, max = superInterfaces.length; i < max; i++){
- int newLevel = this.matchLevelForType(this.superSimpleName, this.superQualification, superInterfaces[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- break;
- case ACCURATE_MATCH:
- return ACCURATE_MATCH;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
- }
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
index 6af78e9009..ef066c1735 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
@@ -109,6 +109,51 @@ protected int matchContainer() {
return CLASS;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof TypeReference)) return false;
+
+ TypeReference typeRef = (TypeReference)node;
+ if (!resolve) {
+ if (this.superSimpleName != null) {
+ char[] typeRefSimpleName = null;
+ if (typeRef instanceof SingleTypeReference) {
+ typeRefSimpleName = ((SingleTypeReference)typeRef).token;
+ } else { // QualifiedTypeReference
+ char[][] tokens = ((QualifiedTypeReference)typeRef).tokens;
+ typeRefSimpleName = tokens[tokens.length-1];
+ }
+ if (!this.matchesName(this.superSimpleName, typeRefSimpleName))
+ return false;
+ }
+ } else {
+ TypeBinding binding = typeRef.binding;
+ if (binding != null && !this.matchesType(this.superSimpleName, this.superQualification, binding))
+ return false;
+ }
+ return true;
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof ReferenceBinding)) return false;
+
+ ReferenceBinding type = (ReferenceBinding) binding;
+ if (this.matchesType(this.superSimpleName, this.superQualification, type.superclass())){
+ return true;
+ }
+
+ ReferenceBinding[] superInterfaces = type.superInterfaces();
+ for (int i = 0, max = superInterfaces.length; i < max; i++){
+ if (this.matchesType(this.superSimpleName, this.superQualification, superInterfaces[i])){
+ return true;
+ }
+ }
+ return false;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -136,24 +181,24 @@ protected boolean matchIndexEntry() {
}
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("SuperTypeReferencePattern: <"); //$NON-NLS-1$
+ buffer.append("SuperTypeReferencePattern: <"/*nonNLS*/);
if (superSimpleName != null) buffer.append(superSimpleName);
- buffer.append(">, "); //$NON-NLS-1$
+ buffer.append(">, "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
@@ -185,73 +230,4 @@ public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
}
return false;
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof TypeReference)) return IMPOSSIBLE_MATCH;
-
- TypeReference typeRef = (TypeReference)node;
- if (resolve) {
- TypeBinding binding = typeRef.binding;
- if (binding == null) {
- return INACCURATE_MATCH;
- } else {
- return this.matchLevelForType(this.superSimpleName, this.superQualification, binding);
- }
- } else {
- if (this.superSimpleName == null) {
- return POSSIBLE_MATCH;
- } else {
- char[] typeRefSimpleName = null;
- if (typeRef instanceof SingleTypeReference) {
- typeRefSimpleName = ((SingleTypeReference)typeRef).token;
- } else { // QualifiedTypeReference
- char[][] tokens = ((QualifiedTypeReference)typeRef).tokens;
- typeRefSimpleName = tokens[tokens.length-1];
- }
- if (this.matchesName(this.superSimpleName, typeRefSimpleName))
- return POSSIBLE_MATCH;
- else
- return IMPOSSIBLE_MATCH;
- }
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof ReferenceBinding)) return IMPOSSIBLE_MATCH;
-
- // super class
- ReferenceBinding type = (ReferenceBinding) binding;
- int level = this.matchLevelForType(this.superSimpleName, this.superQualification, type.superclass());
- switch (level) {
- case IMPOSSIBLE_MATCH:
- break; // try to find match in super interfaces
- case ACCURATE_MATCH:
- return ACCURATE_MATCH;
- default: // ie. INACCURATE_MATCH
- break; // try to find accurate match in super interfaces
- }
-
- // super interfaces
- ReferenceBinding[] superInterfaces = type.superInterfaces();
- for (int i = 0, max = superInterfaces.length; i < max; i++){
- int newLevel = this.matchLevelForType(this.superSimpleName, this.superQualification, superInterfaces[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- break;
- case ACCURATE_MATCH:
- return ACCURATE_MATCH;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
- }
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
index d8e7984bcf..6756791a61 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
@@ -116,6 +116,56 @@ protected int matchContainer() {
return COMPILATION_UNIT | CLASS;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (!(node instanceof TypeDeclaration)) return false;
+
+ TypeDeclaration type = (TypeDeclaration)node;
+
+ // type name
+ if (this.simpleName != null && !this.matchesName(this.simpleName, type.name))
+ return false;
+
+ if (resolve) {
+ // fully qualified name
+ TypeBinding binding = type.binding;
+ if (binding != null && !this.matches(binding)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof TypeBinding)) return false;
+
+ TypeBinding type = (TypeBinding)binding;
+
+ // fully qualified name
+ char[] enclosingTypeName = this.enclosingTypeNames == null ? null : CharOperation.concatWith(this.enclosingTypeNames, '.');
+ if (!this.matchesType(this.simpleName, this.qualification, enclosingTypeName, type)) {
+ return false;
+ }
+
+ // class or interface
+ switch (this.classOrInterface) {
+ case CLASS_SUFFIX:
+ if (type.isInterface())
+ return false;
+ break;
+ case INTERFACE_SUFFIX:
+ if (!type.isInterface())
+ return false;
+ break;
+ }
+
+ return true;
+}
+/**
* @see SearchPattern#matchesBinary(Object, Object)
*/
public boolean matchesBinary(Object binaryInfo, Object enclosingBinaryInfo) {
@@ -163,6 +213,26 @@ protected boolean matchesType(char[] simpleNamePattern, char[] qualificationPatt
}
}
/**
+ * Returns whether the given type binding matches the given simple name pattern
+ * qualification pattern and enclosing type name pattern.
+ */
+protected boolean matchesType(char[] simpleNamePattern, char[] qualificationPattern, char[] enclosingNamePattern, TypeBinding type) {
+ if (enclosingNamePattern == null) {
+ return this.matchesType(simpleNamePattern, qualificationPattern, type);
+ } else {
+ char[] pattern;
+ if (qualificationPattern == null) {
+ return matchesType(simpleNamePattern, enclosingNamePattern, type);
+ } else {
+ // pattern was created from a Java element: qualification is the package name.
+ char[] fullQualificationPattern = CharOperation.concat(qualificationPattern, enclosingNamePattern, '.');
+ return
+ this.matchesType(simpleNamePattern, fullQualificationPattern, type)
+ && CharOperation.equals(qualification, CharOperation.concatWith(type.getPackage().compoundName, '.'));
+ }
+ }
+}
+/**
* see SearchPattern.matchIndexEntry
*/
protected boolean matchIndexEntry(){
@@ -212,17 +282,17 @@ public String toString(){
StringBuffer buffer = new StringBuffer(20);
switch (classOrInterface){
case CLASS_SUFFIX :
- buffer.append("ClassDeclarationPattern: pkg<"); //$NON-NLS-1$
+ buffer.append("ClassDeclarationPattern: pkg<"/*nonNLS*/);
break;
case INTERFACE_SUFFIX :
- buffer.append("InterfaceDeclarationPattern: pkg<"); //$NON-NLS-1$
+ buffer.append("InterfaceDeclarationPattern: pkg<"/*nonNLS*/);
break;
default :
- buffer.append("TypeDeclarationPattern: pkg<"); //$NON-NLS-1$
+ buffer.append("TypeDeclarationPattern: pkg<"/*nonNLS*/);
break;
}
if (qualification != null) buffer.append(qualification);
- buffer.append(">, enclosing<"); //$NON-NLS-1$
+ buffer.append(">, enclosing<"/*nonNLS*/);
if (enclosingTypeNames != null) {
for (int i = 0; i < enclosingTypeNames.length; i++){
buffer.append(enclosingTypeNames[i]);
@@ -230,92 +300,24 @@ public String toString(){
buffer.append('.');
}
}
- buffer.append(">, type<"); //$NON-NLS-1$
+ buffer.append(">, type<"/*nonNLS*/);
if (simpleName != null) buffer.append(simpleName);
- buffer.append(">, "); //$NON-NLS-1$
+ buffer.append(">, "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (!(node instanceof TypeDeclaration)) return IMPOSSIBLE_MATCH;
-
- TypeDeclaration type = (TypeDeclaration)node;
-
- if (resolve) {
- return this.matchLevel(type.binding);
- } else {
- // type name
- if (this.simpleName != null && !this.matchesName(this.simpleName, type.name))
- return IMPOSSIBLE_MATCH;
- else
- return POSSIBLE_MATCH;
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof TypeBinding)) return IMPOSSIBLE_MATCH;
-
- TypeBinding type = (TypeBinding)binding;
-
- // class or interface
- switch (this.classOrInterface) {
- case CLASS_SUFFIX:
- if (type.isInterface())
- return IMPOSSIBLE_MATCH;
- break;
- case INTERFACE_SUFFIX:
- if (!type.isInterface())
- return IMPOSSIBLE_MATCH;
- break;
- }
-
- // fully qualified name
- char[] enclosingTypeName = this.enclosingTypeNames == null ? null : CharOperation.concatWith(this.enclosingTypeNames, '.');
- return this.matchLevelForType(this.simpleName, this.qualification, enclosingTypeName, type);
-}
-
-/**
- * Returns whether the given type binding matches the given simple name pattern
- * qualification pattern and enclosing type name pattern.
- */
-protected int matchLevelForType(char[] simpleNamePattern, char[] qualificationPattern, char[] enclosingNamePattern, TypeBinding type) {
- if (enclosingNamePattern == null) {
- return this.matchLevelForType(simpleNamePattern, qualificationPattern, type);
- } else {
- char[] pattern;
- if (qualificationPattern == null) {
- return matchLevelForType(simpleNamePattern, enclosingNamePattern, type);
- } else {
- // pattern was created from a Java element: qualification is the package name.
- char[] fullQualificationPattern = CharOperation.concat(qualificationPattern, enclosingNamePattern, '.');
- if ( CharOperation.equals(qualification, CharOperation.concatWith(type.getPackage().compoundName, '.'))) {
- return this.matchLevelForType(simpleNamePattern, fullQualificationPattern, type);
- } else {
- return IMPOSSIBLE_MATCH;
- }
- }
- }
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
index ea7708bffb..687ab12993 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
@@ -135,6 +135,183 @@ protected int matchContainer() {
return COMPILATION_UNIT | CLASS | METHOD | FIELD;
}
/**
+ * @see SearchPattern#matches(AstNode, boolean)
+ */
+protected boolean matches(AstNode node, boolean resolve) {
+ if (node instanceof TypeReference) {
+ return this.matches((TypeReference)node, resolve);
+ } else if (node instanceof NameReference) {
+ return this.matches((NameReference)node, resolve);
+ } else if (node instanceof ImportReference) {
+ return this.matches((ImportReference)node, resolve);
+ }
+ return false;
+}
+/**
+ * Returns whether this type pattern matches the given import reference.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(ImportReference importRef, boolean resolve) {
+
+ if (importRef.onDemand) return false;
+
+ char[][] tokens = importRef.tokens;
+ int importLength = tokens.length;
+
+ if (this.qualification != null){
+ char[][] qualificationTokens = CharOperation.splitOn('.', this.qualification);
+ int qualificationLength = qualificationTokens.length;
+ if (qualificationLength+1 > importLength) return false;
+ for (int i = 0; i < qualificationLength; i++){
+ if (!this.matchesName(qualificationTokens[i], tokens[i])) {
+ return false;
+ }
+ }
+ if (this.simpleName != null
+ && !this.matchesName(this.simpleName, tokens[qualificationLength])) {
+ return false;
+ }
+ } else {
+ if (this.simpleName != null) {
+ for (int i = 0; i < importLength; i++){
+ if (this.matchesName(this.simpleName, tokens[i])){
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ return true;
+}
+/**
+ * Returns whether this type pattern matches the given name reference.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(NameReference nameRef, boolean resolve) {
+ Binding binding = nameRef.binding;
+ if (!resolve || binding == null || !binding.isValidBinding()) {
+ if (this.simpleName != null) {
+ if (nameRef instanceof SingleNameReference) {
+ return this.matchesName(this.simpleName, ((SingleNameReference)nameRef).token);
+ } else { // QualifiedNameReference
+ char[][] tokens = ((QualifiedNameReference)nameRef).tokens;
+ for (int i = 0, max = tokens.length; i < max; i++){
+ if (this.matchesName(this.simpleName, tokens[i])) return true;
+ }
+ return false;
+ }
+ }
+ } else {
+ if (nameRef instanceof SingleNameReference){
+ if (binding instanceof TypeBinding){
+ if (!this.matchesType(this.simpleName, this.qualification, (TypeBinding) binding)){
+ return false;
+ }
+ } else {
+ return false; // must be a type binding
+ }
+ } else { // QualifiedNameReference
+ TypeBinding typeBinding = null;
+ QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
+ char[][] tokens = qNameRef.tokens;
+ int lastIndex = tokens.length-1;
+ switch (qNameRef.bits & Statement.RestrictiveFlagMASK) {
+ case BindingIds.FIELD : // reading a field
+ typeBinding = ((FieldBinding)binding).declaringClass;
+ // no valid match amongst fields
+ int otherBindingsCount = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
+ lastIndex -= otherBindingsCount + 1;
+ if (lastIndex < 0) return false;
+ break;
+ case BindingIds.LOCAL : // reading a local variable
+ return false; // no type match in it
+ case BindingIds.TYPE : //=============only type ==============
+ typeBinding = (TypeBinding)binding;
+ }
+ // try to match all enclosing types for which the token matches as well.
+ while (typeBinding != null && lastIndex >= 0){
+ if (matchesName(this.simpleName, tokens[lastIndex--])
+ && matchesType(this.simpleName, this.qualification, typeBinding)) return true;
+ //&& matchesAsSubtype(this.simpleName, this.qualification, typeBinding)) return true;
+ if (typeBinding instanceof ReferenceBinding){
+ typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
+ } else {
+ typeBinding = null;
+ }
+ }
+ return false;
+ }
+ }
+ return true;
+}
+/**
+ * Returns whether this type pattern matches the given type reference.
+ * Look at resolved information only if specified.
+ */
+private boolean matches(TypeReference typeRef, boolean resolve) {
+ if (!resolve) {
+ if (this.simpleName != null) {
+ if (typeRef instanceof SingleTypeReference) {
+ return this.matchesName(this.simpleName, ((SingleTypeReference)typeRef).token);
+ } else { // QualifiedTypeReference
+ char[][] tokens = ((QualifiedTypeReference)typeRef).tokens;
+ for (int i = 0, max = tokens.length; i < max; i++){
+ if (this.matchesName(this.simpleName, tokens[i])) return true;
+ }
+ return false;
+ }
+ }
+ } else {
+
+ TypeBinding typeBinding = typeRef.binding;
+ if (typeBinding != null){
+ if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
+ if (typeRef instanceof SingleTypeReference){
+ if (!this.matchesType(this.simpleName, this.qualification, typeBinding)){
+ return false;
+ }
+ } else { // QualifiedTypeReference
+ QualifiedTypeReference qNameRef = (QualifiedTypeReference)typeRef;
+ char[][] tokens = qNameRef.tokens;
+ int lastIndex = tokens.length-1;
+ // try to match all enclosing types for which the token matches as well.
+ while (typeBinding != null && lastIndex >= 0){
+ if (matchesName(this.simpleName, tokens[lastIndex--])
+ && matchesType(this.simpleName, this.qualification, typeBinding)) return true;
+ //&& matchesAsSubtype(this.simpleName, this.qualification, typeBinding)) return true;
+ if (typeBinding instanceof ReferenceBinding){
+ typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
+ } else {
+ typeBinding = null;
+ }
+ }
+ return false;
+ }
+ }
+
+ }
+ return true;
+}
+/**
+ * @see SearchPattern#matches(Binding)
+ */
+public boolean matches(Binding binding) {
+ if (!(binding instanceof ReferenceBinding)) return false;
+
+ ReferenceBinding type = (ReferenceBinding) binding;
+ if (this.matchesType(this.simpleName, this.qualification, type.superclass())){
+ return true;
+ }
+
+ ReferenceBinding[] superInterfaces = type.superInterfaces();
+ for (int i = 0, max = superInterfaces.length; i < max; i++){
+ if (this.matchesType(this.simpleName, this.qualification, superInterfaces[i])){
+ return true;
+ }
+ }
+ return false;
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -179,6 +356,26 @@ protected boolean matchIndexEntry() {
return true;
}
/**
+ * @see SearchPattern#matchLevel
+ */
+public int matchLevel(AstNode node) {
+ if (node instanceof NameReference) {
+ if (this.matches((NameReference)node, false)) {
+ return POSSIBLE_MATCH; // always need to resolve name reference
+ } else {
+ return IMPOSSIBLE_MATCH;
+ }
+ } else if (node instanceof ImportReference) {
+ if (this.matches((ImportReference)node, false)) {
+ return POSSIBLE_MATCH;
+ } else {
+ return IMPOSSIBLE_MATCH;
+ }
+ } else {
+ return super.matchLevel(node);
+ }
+}
+/**
* @see SearchPattern#matchReportReference
*/
protected void matchReportReference(AstNode reference, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
@@ -218,239 +415,26 @@ protected void resetQuery() {
}
public String toString(){
StringBuffer buffer = new StringBuffer(20);
- buffer.append("TypeReferencePattern: pkg<"); //$NON-NLS-1$
+ buffer.append("TypeReferencePattern: pkg<"/*nonNLS*/);
if (qualification != null) buffer.append(qualification);
- buffer.append(">, type<"); //$NON-NLS-1$
+ buffer.append(">, type<"/*nonNLS*/);
if (simpleName != null) buffer.append(simpleName);
- buffer.append(">, "); //$NON-NLS-1$
+ buffer.append(">, "/*nonNLS*/);
switch(matchMode){
case EXACT_MATCH :
- buffer.append("exact match, "); //$NON-NLS-1$
+ buffer.append("exact match, "/*nonNLS*/);
break;
case PREFIX_MATCH :
- buffer.append("prefix match, "); //$NON-NLS-1$
+ buffer.append("prefix match, "/*nonNLS*/);
break;
case PATTERN_MATCH :
- buffer.append("pattern match, "); //$NON-NLS-1$
+ buffer.append("pattern match, "/*nonNLS*/);
break;
}
if (isCaseSensitive)
- buffer.append("case sensitive"); //$NON-NLS-1$
+ buffer.append("case sensitive"/*nonNLS*/);
else
- buffer.append("case insensitive"); //$NON-NLS-1$
+ buffer.append("case insensitive"/*nonNLS*/);
return buffer.toString();
}
-
-/**
- * @see SearchPattern#matchLevel(AstNode, boolean)
- */
-public int matchLevel(AstNode node, boolean resolve) {
- if (node instanceof TypeReference) {
- return this.matchLevel((TypeReference)node, resolve);
- } else if (node instanceof NameReference) {
- return this.matchLevel((NameReference)node, resolve);
- } else if (node instanceof ImportReference) {
- return this.matchLevel((ImportReference)node, resolve);
- }
- return IMPOSSIBLE_MATCH;
-}
-
-/**
- * Returns whether this type pattern matches the given import reference.
- * Look at resolved information only if specified.
- */
-private int matchLevel(ImportReference importRef, boolean resolve) {
-
- if (importRef.onDemand) return IMPOSSIBLE_MATCH;
-
- char[][] tokens = importRef.tokens;
- int importLength = tokens.length;
-
- if (this.qualification != null){
- char[][] qualificationTokens = CharOperation.splitOn('.', this.qualification);
- int qualificationLength = qualificationTokens.length;
- if (qualificationLength+1 > importLength) return IMPOSSIBLE_MATCH;
- for (int i = 0; i < qualificationLength; i++){
- if (!this.matchesName(qualificationTokens[i], tokens[i])) {
- return IMPOSSIBLE_MATCH;
- }
- }
- if (this.simpleName == null || this.matchesName(this.simpleName, tokens[qualificationLength])) {
- return ACCURATE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- } else {
- if (this.simpleName == null) {
- return ACCURATE_MATCH;
- } else {
- for (int i = 0; i < importLength; i++){
- if (this.matchesName(this.simpleName, tokens[i])){
- return ACCURATE_MATCH;
- }
- }
- return IMPOSSIBLE_MATCH;
- }
- }
-}
-
-/**
- * Returns whether this type pattern matches the given name reference.
- * Look at resolved information only if specified.
- */
-private int matchLevel(NameReference nameRef, boolean resolve) {
- if (!resolve) {
- if (this.simpleName == null) {
- return POSSIBLE_MATCH;
- } else {
- if (nameRef instanceof SingleNameReference) {
- if (this.matchesName(this.simpleName, ((SingleNameReference)nameRef).token)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- } else { // QualifiedNameReference
- char[][] tokens = ((QualifiedNameReference)nameRef).tokens;
- for (int i = 0, max = tokens.length; i < max; i++){
- if (this.matchesName(this.simpleName, tokens[i]))
- return POSSIBLE_MATCH;
- }
- return IMPOSSIBLE_MATCH;
- }
- }
- } else {
- Binding binding = nameRef.binding;
- if (binding == null) {
- return INACCURATE_MATCH;
- } else {
- if (nameRef instanceof SingleNameReference) {
- if (binding instanceof TypeBinding) {
- return this.matchLevelForType(this.simpleName, this.qualification, (TypeBinding) binding);
- } else {
- return IMPOSSIBLE_MATCH; // must be a type binding
- }
- } else { // QualifiedNameReference
- TypeBinding typeBinding = null;
- QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
- char[][] tokens = qNameRef.tokens;
- int lastIndex = tokens.length-1;
- switch (qNameRef.bits & Statement.RestrictiveFlagMASK) {
- case BindingIds.FIELD : // reading a field
- typeBinding = ((FieldBinding)binding).declaringClass;
- // no valid match amongst fields
- int otherBindingsCount = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
- lastIndex -= otherBindingsCount + 1;
- if (lastIndex < 0) return IMPOSSIBLE_MATCH;
- break;
- case BindingIds.LOCAL : // reading a local variable
- return IMPOSSIBLE_MATCH; // no type match in it
- case BindingIds.TYPE : //=============only type ==============
- typeBinding = (TypeBinding)binding;
- }
- // try to match all enclosing types for which the token matches as well.
- while (typeBinding != null && lastIndex >= 0){
- if (this.matchesName(this.simpleName, tokens[lastIndex--])) {
- int level = this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
- if (level != IMPOSSIBLE_MATCH) {
- return level;
- }
- }
- if (typeBinding instanceof ReferenceBinding){
- typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
- } else {
- typeBinding = null;
- }
- }
- return IMPOSSIBLE_MATCH;
- }
- }
- }
-}
-
-/**
- * Returns whether this type pattern matches the given type reference.
- * Look at resolved information only if specified.
- */
-private int matchLevel(TypeReference typeRef, boolean resolve) {
- if (!resolve) {
- if (this.simpleName == null) {
- return POSSIBLE_MATCH;
- } else {
- if (typeRef instanceof SingleTypeReference) {
- if (this.matchesName(this.simpleName, ((SingleTypeReference)typeRef).token)) {
- return POSSIBLE_MATCH;
- } else {
- return IMPOSSIBLE_MATCH;
- }
- } else { // QualifiedTypeReference
- char[][] tokens = ((QualifiedTypeReference)typeRef).tokens;
- for (int i = 0, max = tokens.length; i < max; i++){
- if (this.matchesName(this.simpleName, tokens[i])) {
- return POSSIBLE_MATCH;
- }
- }
- return IMPOSSIBLE_MATCH;
- }
- }
- } else {
- TypeBinding typeBinding = typeRef.binding;
- if (typeBinding == null) {
- return INACCURATE_MATCH;
- } else {
- if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
- if (typeRef instanceof SingleTypeReference){
- return this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
- } else { // QualifiedTypeReference
- QualifiedTypeReference qNameRef = (QualifiedTypeReference)typeRef;
- char[][] tokens = qNameRef.tokens;
- int lastIndex = tokens.length-1;
- // try to match all enclosing types for which the token matches as well.
- while (typeBinding != null && lastIndex >= 0){
- if (matchesName(this.simpleName, tokens[lastIndex--])) {
- int level = this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
- if (level != IMPOSSIBLE_MATCH) {
- return level;
- }
- }
- if (typeBinding instanceof ReferenceBinding){
- typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
- } else {
- typeBinding = null;
- }
- }
- return IMPOSSIBLE_MATCH;
- }
- }
-
- }
-}
-
-/**
- * @see SearchPattern#matchLevel(Binding)
- */
-public int matchLevel(Binding binding) {
- if (binding == null) return INACCURATE_MATCH;
- if (!(binding instanceof ReferenceBinding)) return IMPOSSIBLE_MATCH;
-
- ReferenceBinding type = (ReferenceBinding) binding;
- int level = this.matchLevelForType(this.simpleName, this.qualification, type.superclass());
- if (level != IMPOSSIBLE_MATCH) {
- return level;
- }
-
- ReferenceBinding[] superInterfaces = type.superInterfaces();
- for (int i = 0, max = superInterfaces.length; i < max; i++){
- int newLevel = this.matchLevelForType(this.simpleName, this.qualification, superInterfaces[i]);
- switch (newLevel) {
- case IMPOSSIBLE_MATCH:
- return IMPOSSIBLE_MATCH;
- case ACCURATE_MATCH: // keep previous level
- break;
- default: // ie. INACCURATE_MATCH
- level = newLevel;
- break;
- }
- }
- return level;
-}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties
new file mode 100644
index 0000000000..1653c0f25a
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties
@@ -0,0 +1,6 @@
+### Eclipse Java Core Search messages.
+
+engine.searching = Searching...
+exception.wrongFormat = Wrong format
+process.name = Java indexing: {0}
+manager.filesToIndex = {0} files to index \ No newline at end of file
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
index e6cd6472e9..c6d4dd3df1 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
@@ -137,24 +137,24 @@ protected void notifyIdle(long idlingTime){
*/
public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgressMonitor progress) {
- if (VERBOSE) System.out.println("-> performing concurrent job : START - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : START - "/*nonNLS*/ + searchJob);
boolean status = FAILED;
if (awaitingJobsCount() > 0){
switch(waitingPolicy){
case ForceImmediate :
- if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - ForceImmediate - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - ForceImmediate - "/*nonNLS*/ + searchJob);
boolean wasEnabled = isEnabled();
try {
disable(); // pause indexing
status = searchJob.execute();
- if (VERBOSE) System.out.println("-> performing concurrent job : END - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : END - "/*nonNLS*/ + searchJob);
} finally {
if (wasEnabled) enable();
}
return status;
case CancelIfNotReady :
- if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - CancelIfNotReady - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - CancelIfNotReady - "/*nonNLS*/ + searchJob);
progress.setCanceled(true);
break;
@@ -166,9 +166,9 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress
if (progress != null && progress.isCanceled()) throw new OperationCanceledException();
currentJob = currentJob(); // currentJob can be null when jobs have been added to the queue but job manager is not enabled
if (currentJob != null && currentJob != previousJob){
- if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - WaitUntilReady - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : NOT READY - WaitUntilReady - "/*nonNLS*/ + searchJob);
if (progress != null){
- progress.subTask(Util.bind("manager.filesToIndex", Integer.toString(awaitingWork))); //$NON-NLS-1$
+ progress.subTask(Util.bind("manager.filesToIndex"/*nonNLS*/, Integer.toString(awaitingWork)));
}
previousJob = currentJob;
}
@@ -180,7 +180,7 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress
}
}
status = searchJob.execute();
- if (VERBOSE) System.out.println("-> performing concurrent job : END - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> performing concurrent job : END - "/*nonNLS*/ + searchJob);
return status;
}
public abstract String processName();
@@ -194,7 +194,7 @@ public synchronized void request(IJob job) {
jobStart = 0;
}
awaitingJobs[jobEnd] = job;
- if (VERBOSE) System.out.println("-> requesting job: " + job); //$NON-NLS-1$
+ if (VERBOSE) System.out.println("-> requesting job: "/*nonNLS*/ + job);
}
/**
@@ -230,8 +230,8 @@ public void run(){
idlingStart = -1;
}
if (VERBOSE){
- System.out.println("-> executing: " + job); //$NON-NLS-1$
- System.out.println("\t" + awaitingJobsCount() + " awaiting jobs."); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("-> executing: "/*nonNLS*/ + job);
+ System.out.println("\t"/*nonNLS*/ + awaitingJobsCount() + " awaiting jobs."/*nonNLS*/);
}
try {
executing = true;

Back to the top